Use CTest for testing
This commit is contained in:
parent
cab0a4e96a
commit
0babf5193b
6 changed files with 37 additions and 14 deletions
|
@ -133,7 +133,6 @@ add_custom_target(uninstall
|
|||
########################################################################
|
||||
option(BUILD_DOCUMENTATION "Create and install the HTML based API
|
||||
documentation (requires Doxygen)" OFF)
|
||||
option(BUILD_TEST "Build the test elements." ON)
|
||||
|
||||
find_package(Doxygen)
|
||||
if(BUILD_DOCUMENTATION)
|
||||
|
@ -156,14 +155,19 @@ if(BUILD_DOCUMENTATION)
|
|||
# install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION share/doc)
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
# Build tests
|
||||
########################################################################
|
||||
include(CTest) # note: this adds a BUILD_TESTING which defaults to ON
|
||||
|
||||
########################################################################
|
||||
# Add subdirectories
|
||||
########################################################################
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(src)
|
||||
if(BUILD_TEST)
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif(BUILD_TEST)
|
||||
endif(BUILD_TESTING)
|
||||
add_subdirectory(conf)
|
||||
|
||||
# use space-separation format for the pc file
|
||||
|
|
|
@ -362,8 +362,7 @@ int bitbuffer_find_repeated_row(bitbuffer_t *bits, unsigned min_repeats, unsigne
|
|||
}
|
||||
|
||||
|
||||
// Test code
|
||||
// gcc -I include/ -std=gnu11 -D _TEST src/bitbuffer.c
|
||||
// Unit testing
|
||||
#ifdef _TEST
|
||||
int main(int argc, char **argv) {
|
||||
fprintf(stderr, "bitbuffer:: test\n");
|
||||
|
|
|
@ -258,8 +258,8 @@ int parse_file_info(char const *filename, file_info_t *info)
|
|||
return info->format;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
// e.g. gcc -Wall -std=c99 -DTEST -I include -o fileformat-tests src/fileformat.c && ./fileformat-tests
|
||||
// Unit testing
|
||||
#ifdef _TEST
|
||||
void assert_file_type(int check, char const *spec)
|
||||
{
|
||||
file_info_t info = {0};
|
||||
|
@ -335,4 +335,4 @@ int main(int argc, char **argv)
|
|||
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
}
|
||||
#endif
|
||||
#endif /* _TEST */
|
||||
|
|
|
@ -201,8 +201,7 @@ char *getkwargs(char **s, char **key, char **val)
|
|||
return k;
|
||||
}
|
||||
|
||||
// Test code
|
||||
// gcc -I include/ -std=c99 -D _TEST src/optparse.c && ./a.out
|
||||
// Unit testing
|
||||
#ifdef _TEST
|
||||
#define ASSERT_EQUALS(a,b) if ((a) == (b)) { ++passed; } else { ++failed; fprintf(stderr, "FAIL: %d <> %d\n", (a), (b)); }
|
||||
int main(int argc, char **argv)
|
||||
|
|
|
@ -247,16 +247,15 @@ int add_bytes(uint8_t const message[], unsigned num_bytes)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Test code
|
||||
// gcc -I include/ -std=gnu99 -D _TEST src/util.c
|
||||
// Unit testing
|
||||
#ifdef _TEST
|
||||
int main(int argc, char **argv) {
|
||||
fprintf(stderr, "util:: test\n");
|
||||
|
||||
uint8_t msg[] = {0x08, 0x0a, 0xe8, 0x80};
|
||||
|
||||
fprintf(stderr, "util::crc8(): odd parity: %02X\n", crc8(msg, 3, 0x80));
|
||||
fprintf(stderr, "util::crc8(): even parity: %02X\n", crc8(msg, 4, 0x80));
|
||||
fprintf(stderr, "util::crc8(): odd parity: %02X\n", crc8(msg, 3, 0x80, 0x00));
|
||||
fprintf(stderr, "util::crc8(): even parity: %02X\n", crc8(msg, 4, 0x80, 0x00));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,30 @@ add_executable(data-test data-test.c)
|
|||
|
||||
target_link_libraries(data-test data)
|
||||
|
||||
add_test(data-test data-test)
|
||||
|
||||
add_executable(baseband-test baseband-test.c ../src/baseband.c)
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(baseband-test m)
|
||||
endif()
|
||||
|
||||
#add_test(baseband-test baseband-test)
|
||||
|
||||
########################################################################
|
||||
# Define and build all unit tests
|
||||
########################################################################
|
||||
# target_compile_definitions was only added in CMake 2.8.11
|
||||
add_definitions(-D_TEST)
|
||||
foreach(testSrc bitbuffer.c fileformat.c optparse.c util.c)
|
||||
get_filename_component(testName ${testSrc} NAME_WE)
|
||||
|
||||
add_executable(test_${testName} ../src/${testSrc})
|
||||
|
||||
add_test(${testName}_test test_${testName})
|
||||
endforeach(testSrc)
|
||||
|
||||
########################################################################
|
||||
# Define integration tests
|
||||
########################################################################
|
||||
add_test(rtl_433_help rtl_433 -h)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue