]> git.siccegge.de Git - frida/frida.git/commitdiff
Allow tests to properly run from out-of-tree build directories
authorChristoph Egger <Christoph.Egger@fau.de>
Wed, 4 Mar 2015 15:10:43 +0000 (16:10 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Wed, 4 Mar 2015 15:10:43 +0000 (16:10 +0100)
Fixup gtest so it still finds the testcases if testing is started in a
out-of-tree build.

CMakeLists.txt
src/core/tests/BasicBlockTest.cxx
src/core/tests/FunctionTest.cxx
src/test.cxx

index 7b8663434be6b35fe27badfd74ac85a01d69e8b5..ae7acd742a6a7c72319c71652154f26c0787e889 100644 (file)
@@ -101,5 +101,5 @@ qt5_use_modules(fridatest Widgets)
 #ADD_SUBDIRECTORY(/usr/src/gtest gtest)
 ADD_SUBDIRECTORY(/usr/src/gmock gmock)
 enable_testing()
-target_link_libraries(fridatest gmock gtest gmock_main ${QT_LIBRARIES} ${LLVM_LDFLAGS} -lLLVM-3.5 ${LLVM_SYSTEM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} ${QUAZIP_LIBRARIES})
-add_test(NAME fridatest COMMAND fridatest WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+target_link_libraries(fridatest gmock gtest ${QT_LIBRARIES} ${LLVM_LDFLAGS} -lLLVM-3.5 ${LLVM_SYSTEM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} ${QUAZIP_LIBRARIES})
+add_test(NAME fridatest COMMAND fridatest ${CMAKE_SOURCE_DIR})
index 0980af52f860e545dc3e889e6df309fca28a6461..27072c8cf733db3c181848049805b5dbd4bdfc09 100644 (file)
@@ -5,8 +5,10 @@
 #include "core/InformationManager.hxx"
 #include "core/BasicBlock.hxx"
 
+extern char * TEST_DATA_DIRECTORY;
+
 TEST(BasicBlockTest, deserializeValidInstance) {
-       QFile file("testdata/core/BasicBlock/valid.xml");
+       QFile file(QString(TEST_DATA_DIRECTORY) + "/testdata/core/BasicBlock/valid.xml");
        InformationManager manager;
        file.open(QFile::ReadOnly | QFile::Text);
        QXmlStreamReader reader(&file);
@@ -22,7 +24,7 @@ TEST(BasicBlockTest, deserializeValidInstance) {
 }
 
 TEST(BasicBlockTest, deserializeInvalidInstance) {
-       QFile file("testdata/core/BasicBlock/invalid.xml");
+       QFile file(QString(TEST_DATA_DIRECTORY) + "/testdata/core/BasicBlock/invalid.xml");
        InformationManager manager;
        file.open(QFile::ReadOnly | QFile::Text);
        QXmlStreamReader reader(&file);
@@ -34,7 +36,7 @@ TEST(BasicBlockTest, deserializeInvalidInstance) {
 }
 
 TEST(BasicBlockTest, deserializeThenSerializeIsIdentity) {
-       QFile infile("testdata/core/BasicBlock/valid.xml");
+       QFile infile(QString(TEST_DATA_DIRECTORY) + "/testdata/core/BasicBlock/valid.xml");
        QTemporaryFile outfile;
 
        InformationManager manager;
index 5357bb906aab3f5e6c6ace6b7d770b0f683cb1d8..0d3e56d5791c95b12387356f0ac08f098fe053c4 100644 (file)
@@ -5,8 +5,10 @@
 #include "core/BasicBlock.hxx"
 #include "core/Function.hxx"
 
+extern char * TEST_DATA_DIRECTORY;
+
 TEST(FunctionTest, deserializeValidInstance) {
-       QFile file("testdata/core/Function/valid.xml");
+       QFile file(QString(TEST_DATA_DIRECTORY) + "/testdata/core/Function/valid.xml");
        InformationManager manager;
        file.open(QFile::ReadOnly | QFile::Text);
        QXmlStreamReader reader(&file);
index 100ee322f922a9a81b175b52f8a4b333c38d864f..596fe3d8e4735fb5cbf33f30b3baef55ec6ce966 100644 (file)
@@ -1,2 +1,14 @@
 #include <gtest/gtest.h>
 
+char* TEST_DATA_DIRECTORY;
+
+int main(int argc, char **argv) {
+  testing::InitGoogleTest(&argc, argv);
+
+  if (argc > 1)
+         TEST_DATA_DIRECTORY = argv[1];
+  else
+         TEST_DATA_DIRECTORY = "./";
+
+  return RUN_ALL_TESTS();
+}