refactor(tests): remove copying files to output directory; tests accept path to expected instead

This commit is contained in:
vsariola 2021-01-05 18:18:48 +02:00
parent 588488ce54
commit 1be75362d0
2 changed files with 6 additions and 13 deletions

View File

@ -35,18 +35,9 @@ function(regression_test testname)
add_executable(${testname} ${source} test_renderer.c) add_executable(${testname} ${source} test_renderer.c)
endif() endif()
add_test(${testname} ${testname}) add_test(${testname} ${testname} ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}.raw)
target_link_libraries(${testname} ${HEADERLIB}) target_link_libraries(${testname} ${HEADERLIB})
set (rawinput ${CMAKE_CURRENT_SOURCE_DIR}/expected_output/${testname}.raw)
set (rawoutput ${CMAKE_CURRENT_BINARY_DIR}/expected_output/${testname}.raw)
add_custom_target(${testname}_rawcopy
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${rawinput} ${rawoutput}
)
add_dependencies(${testname} ${testname}_rawcopy)
target_include_directories(${testname} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(${testname} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(${testname} PUBLIC TEST_NAME="${testname}") target_compile_definitions(${testname} PUBLIC TEST_NAME="${testname}")

View File

@ -28,6 +28,10 @@ int main(int argc, char* argv[]) {
float max_diff; float max_diff;
float diff; float diff;
if (argc < 2) {
fprintf(stderr, "usage: [test] path/to/expected_wave.raw");
}
#ifdef SU_LOAD_GMDLS #ifdef SU_LOAD_GMDLS
su_load_gmdls(); su_load_gmdls();
#endif #endif
@ -45,9 +49,7 @@ int main(int argc, char* argv[]) {
fwrite((void*)buf, sizeof(SUsample), SU_BUFFER_LENGTH, f); fwrite((void*)buf, sizeof(SUsample), SU_BUFFER_LENGTH, f);
fclose(f); fclose(f);
snprintf(filename, sizeof filename, "%s%s%s", expected_output_folder, test_name, ".raw"); f = fopen(argv[1], "rb");
f = fopen(filename, "rb");
if (f == NULL) { if (f == NULL) {
printf("No expected waveform found!\n"); printf("No expected waveform found!\n");