diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-12-23 16:00:07 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-12-23 16:00:07 +0100 |
commit | 3fca34362115c256fffce3dd68ff878c86153c95 (patch) | |
tree | 9110b50243fd614a6e829c765d3e107ae6d3b776 /tests | |
parent | 417b92df7023a32c0b2775d59f1816b629e0a9b9 (diff) | |
download | cmocka-3fca34362115c256fffce3dd68ff878c86153c95.tar.gz cmocka-3fca34362115c256fffce3dd68ff878c86153c95.tar.bz2 cmocka-3fca34362115c256fffce3dd68ff878c86153c95.zip |
tests: Add test_assert_macros.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/test_assert_macros.c | 33 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..019cb3e --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,14 @@ +project(tests C) + +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/include +) + +set(CMOCKA_TESTS + test_assert_macros) + +foreach(_CMOCKA_TEST ${CMOCKA_TESTS}) + add_cmocka_test(${_CMOCKA_TEST} ${_CMOCKA_TEST}.c ${CMOCKA_SHARED_LIBRARY}) +endforeach() diff --git a/tests/test_assert_macros.c b/tests/test_assert_macros.c new file mode 100644 index 0000000..7f643b7 --- /dev/null +++ b/tests/test_assert_macros.c @@ -0,0 +1,33 @@ +#include <stdarg.h> +#include <stddef.h> +#include <setjmp.h> +#include <cmocka.h> + +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <fcntl.h> + +/************************************** + *** assert_return_code + **************************************/ +static void test_assert_return_code(void **state) +{ + struct stat sb; + int rc; + + (void)state; /* unused */ + + rc = stat(".", &sb); + assert_return_code(rc, 0); + + assert_true(S_ISDIR(sb.st_mode)); +} + +int main(void) { + const UnitTest tests[] = { + unit_test(test_assert_return_code), + }; + return run_tests(tests); +} |