diff --git a/CMakeLists.txt b/CMakeLists.txt index b349cfa..ad1dd54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -280,25 +280,18 @@ endif (POD2MAN) if (BUILD_UNIT_TESTS) enable_testing() - message("-- Including vendored googletest") set(GOOGLETEST_DIR vendor/github.com/google/googletest) add_subdirectory(${GOOGLETEST_DIR}) link_directories(${CMAKE_BINARY_DIR}/${GOOGLETEST_DIR}/googletest) - message("-- Including vendored benchmark library") set(GOOGLEBENCH_DIR vendor/github.com/google/benchmark) set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "benchmark tests") add_subdirectory(${GOOGLEBENCH_DIR}) link_directories(${CMAKE_BINARY_DIR}/${GOOGLEBENCH_DIR}) - file(GLOB_RECURSE TEST_SOURCES "encfs/*_test.cpp") - add_executable (unittests ${TEST_SOURCES}) - target_link_libraries(unittests gtest gtest_main encfs) - add_test(unit unittests) + # Unit tests. + add_subdirectory(test) - file(GLOB_RECURSE BENCH_SOURCES "encfs/*_bench.cpp") - add_executable (benchmarks ${BENCH_SOURCES}) - target_link_libraries(benchmarks benchmark encfs) + # Integration test target - runs against built encfs. + add_custom_target(integration COMMAND ${CMAKE_CURRENT_LIST_DIR}/integration.sh) endif () - -add_custom_target(tests COMMAND ${CMAKE_CURRENT_LIST_DIR}/test.sh) diff --git a/integration.sh b/integration.sh new file mode 100755 index 0000000..032adcc --- /dev/null +++ b/integration.sh @@ -0,0 +1,6 @@ +#!/bin/bash -eux + +# Make sure we are in the directory this script is in. +cd "$(dirname "$0")" + +perl -MTest::Harness -e '$$Test::Harness::debug=1; runtests @ARGV;' integration/*.t.pl diff --git a/tests/benchmark-reverse.pl b/integration/benchmark-reverse.pl similarity index 97% rename from tests/benchmark-reverse.pl rename to integration/benchmark-reverse.pl index e91b08f..d40888b 100755 --- a/tests/benchmark-reverse.pl +++ b/integration/benchmark-reverse.pl @@ -5,7 +5,7 @@ use File::Temp; use warnings; -require("tests/common.pl"); +require("integration/common.pl"); sub mount_encfs_reverse { my $p = shift; diff --git a/tests/benchmark.pl b/integration/benchmark.pl similarity index 96% rename from tests/benchmark.pl rename to integration/benchmark.pl index 8355065..cea4049 100755 --- a/tests/benchmark.pl +++ b/integration/benchmark.pl @@ -5,7 +5,7 @@ use File::Temp; use warnings; -require("tests/common.pl"); +require("integration/common.pl"); # Create a new empty working directory sub newWorkingDir { @@ -58,7 +58,7 @@ sub mount_ecryptfs { mkdir($c); mkdir($p); - system("expect -c \"spawn mount -t ecryptfs $c $p\" ./tests/mount-ecryptfs.expect > /dev/null") == 0 + system("expect -c \"spawn mount -t ecryptfs $c $p\" ./integration/mount-ecryptfs.expect > /dev/null") == 0 or die("ecryptfs mount failed - are you root?"); print "# ecryptfs mounted on $p\n"; diff --git a/tests/common.pl b/integration/common.pl similarity index 100% rename from tests/common.pl rename to integration/common.pl diff --git a/tests/mount-ecryptfs.expect b/integration/mount-ecryptfs.expect similarity index 100% rename from tests/mount-ecryptfs.expect rename to integration/mount-ecryptfs.expect diff --git a/tests/normal.t.pl b/integration/normal.t.pl similarity index 99% rename from tests/normal.t.pl rename to integration/normal.t.pl index 5011c09..3d184ad 100755 --- a/tests/normal.t.pl +++ b/integration/normal.t.pl @@ -8,7 +8,7 @@ use File::Copy; use File::Temp; use IO::Handle; -require("tests/common.pl"); +require("integration/common.pl"); my $tempDir = $ENV{'TMPDIR'} || "/tmp"; diff --git a/tests/reverse.t.pl b/integration/reverse.t.pl similarity index 99% rename from tests/reverse.t.pl rename to integration/reverse.t.pl index d8277a9..e38d48a 100755 --- a/tests/reverse.t.pl +++ b/integration/reverse.t.pl @@ -9,7 +9,7 @@ use File::Temp; use IO::Handle; use Errno qw(EROFS); -require("tests/common.pl"); +require("integration/common.pl"); my $tempDir = $ENV{'TMPDIR'} || "/tmp"; diff --git a/tests/stress_tests/fsstress-encfs.sh b/integration/stress_tests/fsstress-encfs.sh similarity index 100% rename from tests/stress_tests/fsstress-encfs.sh rename to integration/stress_tests/fsstress-encfs.sh diff --git a/test.sh b/test.sh deleted file mode 100755 index 66b4b14..0000000 --- a/test.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -eux - -# Make sure we are in the directory this script is in. -cd "$(dirname "$0")" - -# This is very noisy so run it silently at first. Run it again with -# output if the first run fails. -./build/checkops &> /dev/null || ./build/checkops - -perl -MTest::Harness -e '$$Test::Harness::debug=1; runtests @ARGV;' tests/*.t.pl diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..44a427f --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,10 @@ +file(GLOB_RECURSE TEST_SOURCES "*_test.cpp") +add_executable (unittests ${TEST_SOURCES}) +target_link_libraries(unittests gtest gtest_main encfs) +add_test(unit unittests) + +file(GLOB_RECURSE BENCH_SOURCES "*_bench.cpp") +add_executable (benchmarks ${BENCH_SOURCES}) +target_link_libraries(benchmarks benchmark encfs) + +add_custom_target(integration COMMAND ${CMAKE_CURRENT_LIST_DIR}/integration.sh) diff --git a/encfs/Cipher_test.cpp b/test/Cipher_test.cpp similarity index 96% rename from encfs/Cipher_test.cpp rename to test/Cipher_test.cpp index 00d45b0..da3ab9d 100644 --- a/encfs/Cipher_test.cpp +++ b/test/Cipher_test.cpp @@ -1,12 +1,12 @@ #include "gtest/gtest.h" -#include "BlockNameIO.h" -#include "Cipher.h" -#include "CipherKey.h" -#include "DirNode.h" -#include "FSConfig.h" -#include "FileUtils.h" -#include "StreamNameIO.h" +#include "encfs/BlockNameIO.h" +#include "encfs/Cipher.h" +#include "encfs/CipherKey.h" +#include "encfs/DirNode.h" +#include "encfs/FSConfig.h" +#include "encfs/FileUtils.h" +#include "encfs/StreamNameIO.h" using namespace encfs; using namespace testing; diff --git a/encfs/MemoryPool_bench.cpp b/test/MemoryPool_bench.cpp similarity index 90% rename from encfs/MemoryPool_bench.cpp rename to test/MemoryPool_bench.cpp index 9326e43..00ccaff 100644 --- a/encfs/MemoryPool_bench.cpp +++ b/test/MemoryPool_bench.cpp @@ -1,6 +1,6 @@ #include "benchmark/benchmark.h" -#include "MemoryPool.h" +#include "encfs/MemoryPool.h" using namespace encfs; diff --git a/encfs/MemoryPool_test.cpp b/test/MemoryPool_test.cpp similarity index 88% rename from encfs/MemoryPool_test.cpp rename to test/MemoryPool_test.cpp index bae4061..4c99b76 100644 --- a/encfs/MemoryPool_test.cpp +++ b/test/MemoryPool_test.cpp @@ -1,6 +1,6 @@ #include "gtest/gtest.h" -#include "MemoryPool.h" +#include "encfs/MemoryPool.h" using namespace encfs; diff --git a/encfs/main_bench.cpp b/test/main_bench.cpp similarity index 100% rename from encfs/main_bench.cpp rename to test/main_bench.cpp