summaryrefslogtreecommitdiff
path: root/source/test
diff options
context:
space:
mode:
authorMitya Selivanov <0x7fffff@guattari.ru>2022-08-19 16:09:33 +0400
committerMitya Selivanov <0x7fffff@guattari.ru>2022-08-19 16:09:33 +0400
commit5ad5cb5a1b5642f40e3df158ff1979de8487dc10 (patch)
tree0be28d04e4af7a7cec160a79bfc80d3b2a23712e /source/test
parent45459652d69f053ec5690a8a7734054c652934d3 (diff)
downloadkit-5ad5cb5a1b5642f40e3df158ff1979de8487dc10.zip
Signals for test environment
Diffstat (limited to 'source/test')
-rw-r--r--source/test/programs/CMakeLists.txt10
-rw-r--r--source/test/programs/signals.c18
-rw-r--r--source/test/programs/too_many_tests.c2
-rw-r--r--source/test/unittests/test_duration.test.c2
4 files changed, 31 insertions, 1 deletions
diff --git a/source/test/programs/CMakeLists.txt b/source/test/programs/CMakeLists.txt
index 24932bd..9c58599 100644
--- a/source/test/programs/CMakeLists.txt
+++ b/source/test/programs/CMakeLists.txt
@@ -28,4 +28,14 @@ if(KIT_ENABLE_TESTING)
cpp_example_test
PROPERTIES
TIMEOUT "30")
+
+ add_executable(signals signals.c)
+ target_link_libraries(signals ${KIT_TEST_LIBRARY})
+ add_test(
+ NAME signals_test
+ COMMAND signals)
+ set_tests_properties(
+ signals_test
+ PROPERTIES
+ TIMEOUT "30")
endif()
diff --git a/source/test/programs/signals.c b/source/test/programs/signals.c
new file mode 100644
index 0000000..935623a
--- /dev/null
+++ b/source/test/programs/signals.c
@@ -0,0 +1,18 @@
+#include "../../kit_test/test.h"
+
+#include <stdlib.h>
+
+TEST("abort") {
+ abort();
+}
+
+TEST("invalid access") {
+ *(volatile int *) NULL = 42;
+}
+
+int main(int argc, char **argv) {
+ if (run_tests(argc, argv) != 1)
+ return 1;
+
+ return 0;
+}
diff --git a/source/test/programs/too_many_tests.c b/source/test/programs/too_many_tests.c
index 9893e84..bc7b543 100644
--- a/source/test/programs/too_many_tests.c
+++ b/source/test/programs/too_many_tests.c
@@ -4,7 +4,7 @@ void bar(int index, kit_test_report_fn report) { }
int main(int argc, char **argv) {
for (int i = 0; i <= KIT_TESTS_SIZE_LIMIT; i++)
- test_register("foo", bar);
+ test_register("foo", __FILE__, bar);
if (run_tests(argc, argv) != 1)
return 1;
diff --git a/source/test/unittests/test_duration.test.c b/source/test/unittests/test_duration.test.c
index 5d9e578..0912d9f 100644
--- a/source/test/unittests/test_duration.test.c
+++ b/source/test/unittests/test_duration.test.c
@@ -1,6 +1,8 @@
#define KIT_TEST_FILE test_duration
#include "../../kit_test/test.h"
+#include <stdlib.h>
+
#if defined(_WIN32) && !defined(__CYGWIN__)
__declspec(dllimport) void __stdcall Sleep(unsigned long timeout);
static void kit_sleep(int ms) {