]> git.siccegge.de Git - frida/frida.git/commitdiff
Properly allow plugins to load for testing
authorChristoph Egger <Christoph.Egger@fau.de>
Wed, 18 Mar 2015 16:57:29 +0000 (17:57 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Wed, 18 Mar 2015 16:57:29 +0000 (17:57 +0100)
Loads stuff from the cmake binary directory for testing -- so tests use
the newly built plugins and not some old installed ones (or fail if none
exist)

CMakeLists.txt
src/Config.hxx.in
src/bindings/Guile.cxx
src/main.cxx
src/test.cxx

index 242fbfc49a1e4c2545fe68d0e9ee4df70dfcad82..aa3d082c7df988faafe09e9403572fce74e2d61b 100644 (file)
@@ -15,6 +15,7 @@ find_package(PkgConfig)
 pkg_check_modules(LOG4CXX REQUIRED liblog4cxx)
 pkg_check_modules(GUILE REQUIRED guile-2.0)
 FIND_PACKAGE(SWIG REQUIRED)
+find_program(SWIG_EXECUTABLE NAMES swig3.0)
 INCLUDE(${SWIG_USE_FILE})
 
 add_definitions(${LOG4CXX_CFLAGS})
@@ -134,10 +135,9 @@ 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 ${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})
-
-
+target_link_libraries(fridatest gmock gtest ${QT_LIBRARIES} ${LLVM_LDFLAGS} -lLLVM-3.5 ${LLVM_SYSTEM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} ${QUAZIP_LIBRARIES})
+target_compile_options(fridatest PRIVATE -DCONFIG_TEST)
 
 install(TARGETS frida
   RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
index 6ad3f497291a04afdbc35678fddc1d2570d8dc84..394e5d6afcada335c6e24739bd3a7e06998c9339 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef INCLUDE__Config_hxx_
 #define INCLUDE__Config_hxx_
 
-#cmakedefine CMAKE_INSTALL_FULL_LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@"
+#ifdef CONFIG_TEST
+# define CONFIG_LIBDIR "@CMAKE_CURRENT_BINARY_DIR@"
+#else
+# define CONFIG_LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@"
+#endif
 
 #endif /* INCLUDE__Config_hxx_ */
index 86ab6dd1338e2abafdd9b4c5b29f6762736bfd3c..c452e7667dafc5225251274d99ca9782f929a5b2 100644 (file)
@@ -13,7 +13,7 @@ GuileInterpreter::GuileInterpreter() {
 
        scm_c_use_module("system repl server");
        scm_call_0(scm_c_public_ref("system repl server", "spawn-server"));
-       scm_c_load_extension(CMAKE_INSTALL_FULL_LIBDIR "/frida/plugins/Interpreter/libguile-frida-binding",
+       scm_c_load_extension(CONFIG_LIBDIR "/frida/plugins/Interpreter/libguile-frida-binding",
                             "scm_init_frida_module");
 
        guile_output_port = scm_open_output_string();
index a627b61dc7a391263adcb6bef67af3e431f5133c..d284d4fcb0a3e685d797877182465505f9bb25a7 100644 (file)
@@ -33,7 +33,7 @@ int main(int argc, char** argv)
 
        QApplication::setApplicationName("frida");
        QApplication::setApplicationVersion("0.0");
-       QApplication::addLibraryPath(CMAKE_INSTALL_FULL_LIBDIR "/frida/plugins/Interpreter");
+       QApplication::addLibraryPath(CONFIG_LIBDIR "/frida/plugins/Interpreter");
 #ifdef ARGPARSE
        parser.addHelpOption();
        parser.addVersionOption();
index 596fe3d8e4735fb5cbf33f30b3baef55ec6ce966..9f73274dc04cbbe0c82a47c0f978fc7519d3a69b 100644 (file)
@@ -1,14 +1,20 @@
 #include <gtest/gtest.h>
+#include "log4cxx/logger.h"
+#include "log4cxx/basicconfigurator.h"
+#include <QApplication>
+#include "Config.hxx"
 
 char* TEST_DATA_DIRECTORY;
 
 int main(int argc, char **argv) {
-  testing::InitGoogleTest(&argc, argv);
+       testing::InitGoogleTest(&argc, argv);
+       log4cxx::BasicConfigurator::configure();
 
-  if (argc > 1)
-         TEST_DATA_DIRECTORY = argv[1];
-  else
-         TEST_DATA_DIRECTORY = "./";
+       QApplication::addLibraryPath(CONFIG_LIBDIR);
+       if (argc > 1)
+               TEST_DATA_DIRECTORY = argv[1];
+       else
+               TEST_DATA_DIRECTORY = "./";
 
-  return RUN_ALL_TESTS();
+       return RUN_ALL_TESTS();
 }