Add unit test for AppDir::deployExecutable

This commit is contained in:
Alexis Lopez Zubieta
2018-10-12 17:56:42 +02:00
committed by TheAssassin
parent a0503a7102
commit 4c9943f0d1
5 changed files with 44 additions and 3 deletions

View File

@@ -87,4 +87,28 @@ namespace AppDirUnitTests {
if (!libsimple_library_found)
FAIL();
}
TEST_F(AppDirUnitTestsFixture, deployExecutable) {
path exePath = SIMPLE_EXECUTABLE_PATH;
appDir.deployExecutable(exePath);
appDir.executeDeferredOperations();
bool libsimple_library_found = false;
bool simple_executable_found = false;
recursive_directory_iterator end_itr; // default construction yields past-the-end
for (recursive_directory_iterator itr(tmpAppDir);
itr != end_itr && (!libsimple_library_found || !simple_executable_found);
itr++) {
const auto path = relative(itr->path(), tmpAppDir).filename().string();
if (path.find("libsimple_library") != std::string::npos)
libsimple_library_found = true;
if (path.find("simple_executable") != std::string::npos)
simple_executable_found = true;
}
if (!libsimple_library_found || !simple_executable_found)
FAIL();
}
}

View File

@@ -3,11 +3,16 @@ if(NOT TARGET gtest)
endif()
add_subdirectory(simple_library)
add_subdirectory(simple_executable)
add_executable(AppDirUnitTests AppDirUnitTests.cpp)
target_link_libraries(AppDirUnitTests PRIVATE linuxdeploy_core)
target_include_directories(AppDirUnitTests PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_compile_definitions(AppDirUnitTests PRIVATE -DSIMPLE_LIBRARY_PATH="$<TARGET_LINKER_FILE:simple_library>")
target_compile_definitions(AppDirUnitTests PRIVATE
-DSIMPLE_LIBRARY_PATH="$<TARGET_FILE:simple_library>"
-DSIMPLE_EXECUTABLE_PATH="$<TARGET_FILE:simple_executable>"
)
add_gtest(AppDirUnitTests)
add_dependencies(AppDirUnitTests simple_library)
add_dependencies(AppDirUnitTests simple_library simple_executable)

View File

@@ -0,0 +1,2 @@
add_executable(simple_executable simple_executable.cpp)
target_link_libraries(simple_executable simple_library pthread)

View File

@@ -0,0 +1,10 @@
#include <cstdio>
extern "C" { void hello_world(); }
int main() {
printf("Hello World");
hello_world();
return 0;
}

View File

@@ -1,2 +1,2 @@
add_library(simple_library SHARED simple_library.cpp)
target_link_libraries(simple_library cairo)
target_link_libraries(simple_library CImg)