aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-12-13 10:54:53 +0100
committerAndreas Schneider <asn@cryptomilk.org>2013-12-13 10:55:40 +0100
commitbe3f313e87096dc8c1ffce00550a7d803635c721 (patch)
tree25068c1e44ee93fc3c95b72dd3eee7fed0cd5a24 /example
parent443bc01435f83d02e8a08e6c2ab10851b1b27652 (diff)
downloadcmocka-be3f313e87096dc8c1ffce00550a7d803635c721.tar.gz
cmocka-be3f313e87096dc8c1ffce00550a7d803635c721.tar.xz
cmocka-be3f313e87096dc8c1ffce00550a7d803635c721.zip
example: Add the most simple test with cmocka.
Diffstat (limited to 'example')
-rw-r--r--example/CMakeLists.txt9
-rw-r--r--example/simple_test.c17
2 files changed, 25 insertions, 1 deletions
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 2f52cf2..98a3d6a 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -15,12 +15,19 @@ set_source_files_properties(
PROPERTIES
COMPILE_FLAGS -DUNIT_TESTING=1)
+### The most simple test
+add_executable(simple_test simple_test.c)
+target_link_libraries(simple_test ${CMOCKA_SHARED_LIBRARY})
+
+add_test(simple_test ${CMAKE_CURRENT_BINARY_DIR}/simple_test)
+
+### Test different fixture setups
add_executable(fixture_test fixture_test.c)
target_link_libraries(fixture_test ${CMOCKA_SHARED_LIBRARY})
add_test(fixture_test ${CMAKE_CURRENT_BINARY_DIR}/fixture_test)
-# segfault test
+### Test the exception handler with a segfault
add_executable(segfault_test segfault_test.c)
target_link_libraries(segfault_test ${CMOCKA_SHARED_LIBRARY})
diff --git a/example/simple_test.c b/example/simple_test.c
new file mode 100644
index 0000000..dce78d2
--- /dev/null
+++ b/example/simple_test.c
@@ -0,0 +1,17 @@
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+/* A test case that does nothing and succeeds. */
+static void null_test_success(void **state) {
+ (void) state; /* unused */
+}
+
+int main(void) {
+ const UnitTest tests[] = {
+ unit_test(null_test_success),
+ };
+
+ return run_tests(tests);
+}