diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2012-12-14 12:00:49 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2012-12-14 12:00:49 (GMT) |
commit | d0c948844f398f291c1d014ff1a2791414b74d9c (patch) | |
tree | c397827fd1dff67cb7bba0ac422a26efe6ace6da /src/tests | |
parent | dd767425b489541585c526ebfb629538269afd54 (diff) |
Copy example files to build directory and set constants to find them
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/tests/tng_io_testing.c | 20 | ||||
-rw-r--r-- | src/tests/tng_io_testing.h.in | 6 |
3 files changed, 27 insertions, 4 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 9b9afe5..6747eb6 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,5 +1,10 @@ include_directories(${TRAJECTORY_SOURCE_DIR}/src/lib) link_directories(${TRAJECTORY_BINARY_DIR}/src/lib) +set(EXAMPLE_FILES_DIR ${CMAKE_BINARY_DIR}/example_files/ CACHE STRING "Directory where to find input test files and save output files.") + +configure_file(tng_io_testing.h.in ${CMAKE_BINARY_DIR}/generated/tng_io_testing.h) +include_directories(${CMAKE_BINARY_DIR}/generated/) + add_executable(tng_testing tng_io_testing.c) target_link_libraries(tng_testing tng_io)
\ No newline at end of file diff --git a/src/tests/tng_io_testing.c b/src/tests/tng_io_testing.c index 34234ec..1506f68 100644 --- a/src/tests/tng_io_testing.c +++ b/src/tests/tng_io_testing.c @@ -2,9 +2,7 @@ #include <stdlib.h> #include <string.h> #include "tng_io.h" - - - +#include "tng_io_testing.h" static tng_function_status tng_test_setup_molecules(tng_trajectory_t traj) { @@ -301,7 +299,11 @@ static tng_function_status tng_test_write_and_read_traj(tng_trajectory_t traj) free(data); tng_trajectory_destroy(traj); +#ifdef EXAMPLE_FILES_DIR + tng_input_file_set(traj, EXAMPLE_FILES_DIR "tng_test.tng"); +#else tng_input_file_set(traj, "/tmp/tng_test.tng"); +#endif stat = tng_file_headers_read(traj, TNG_SKIP_HASH); @@ -407,9 +409,15 @@ int main() tng_time_get_str(&traj, time_str); printf("Creation time: %s\n", time_str); - + +#ifdef EXAMPLE_FILES_DIR + tng_input_file_set(&traj, EXAMPLE_FILES_DIR "tng_example.tng"); + tng_output_file_set(&traj, EXAMPLE_FILES_DIR "tng_example_out.tng"); +#else tng_input_file_set(&traj, "tng_example.tng"); tng_output_file_set(&traj, "/tmp/tng_example_out.tng"); +#endif + // if(tng_test_endianness(&traj) != TNG_SUCCESS) // { @@ -448,7 +456,11 @@ int main() } +#ifdef EXAMPLE_FILES_DIR + tng_output_file_set(&traj, EXAMPLE_FILES_DIR "tng_test.tng"); +#else tng_output_file_set(&traj, "/tmp/tng_test.tng"); +#endif if(tng_test_write_and_read_traj(&traj) == TNG_CRITICAL) { diff --git a/src/tests/tng_io_testing.h.in b/src/tests/tng_io_testing.h.in new file mode 100644 index 0000000..b0d45a1 --- /dev/null +++ b/src/tests/tng_io_testing.h.in @@ -0,0 +1,6 @@ +#ifndef _TNG_IO_TESTING_H +#define _TNG_IO_TESTING_H + +#define EXAMPLE_FILES_DIR "@EXAMPLE_FILES_DIR@" + +#endif
\ No newline at end of file |