summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-09-12 07:18:00 +0200
committerMitya Selivanov <automainint@guattari.tech>2023-09-12 07:18:00 +0200
commitb5f549cc9f984a4af363ef41696815a789ce3d13 (patch)
tree25dd07aa3a1ef43804bc1c3cfb084536c11c7108 /source
parentf0e738028819ac988dbd825cf1962188c9e5cdc3 (diff)
downloadkit-b5f549cc9f984a4af363ef41696815a789ce3d13.zip
kit_test: signals
Diffstat (limited to 'source')
-rw-r--r--source/kit/kit_test.h38
-rw-r--r--source/tests/test_signals.cpp12
2 files changed, 5 insertions, 45 deletions
diff --git a/source/kit/kit_test.h b/source/kit/kit_test.h
index b102b73..20155af 100644
--- a/source/kit/kit_test.h
+++ b/source/kit/kit_test.h
@@ -411,20 +411,8 @@ static void kit_test_handle_signal(int signum) {
}
static void kit_test_setup_signals() {
- int i;
-
- for (i = 0; i < sizeof kit_signums_ / sizeof *kit_signums_; i++) {
-# if (defined(_WIN32) && !defined(__CYGWIN__)) || \
- !defined(_POSIX_C_SOURCE)
+ for (int i = 0; i < sizeof kit_signums_ / sizeof *kit_signums_; i++)
signal(kit_signums_[i], kit_test_handle_signal);
-# else
- struct sigaction action;
- memset(&action, 0, sizeof action);
- action.sa_handler = kit_test_handle_signal;
-
- sigaction(kit_signums_[i], &action, NULL);
-# endif
- }
}
static int kit_run_test_(volatile int i) {
@@ -795,31 +783,13 @@ void kit_bench_register(char const *name, char const *file,
}
}
-static jmp_buf kit_bench_restore_execution;
-
-static void kit_bench_handle_signal(int signum) {
- longjmp(kit_bench_restore_execution, signum);
-}
-
static void kit_bench_setup_signals() {
- int i;
-
- for (i = 0; i < sizeof kit_signums_ / sizeof *kit_signums_; i++) {
-# if (defined(_WIN32) && !defined(__CYGWIN__)) || \
- !defined(_POSIX_C_SOURCE)
- signal(kit_signums_[i], kit_bench_handle_signal);
-# else
- struct sigaction action;
- memset(&action, 0, sizeof action);
- action.sa_handler = kit_bench_handle_signal;
-
- sigaction(kit_signums_[i], &action, NULL);
-# endif
- }
+ for (int i = 0; i < sizeof kit_signums_ / sizeof *kit_signums_; i++)
+ signal(kit_signums_[i], kit_test_handle_signal);
}
static int kit_run_bench_(volatile int i) {
- int signum = setjmp(kit_bench_restore_execution);
+ int signum = setjmp(kit_test_restore_execution);
if (signum != 0) {
kit_benchs_list.v[i].signal = signum;
diff --git a/source/tests/test_signals.cpp b/source/tests/test_signals.cpp
index 6b0fb28..a721f46 100644
--- a/source/tests/test_signals.cpp
+++ b/source/tests/test_signals.cpp
@@ -17,17 +17,7 @@ TEST("invalid access") {
}
int main(int argc, char **argv) {
- // FIXME
- // On Windows, doesn't work for some reason...
- // Both MSVC and MinGW.
- //
-
-#ifndef _WIN32
- if (run_tests(argc, argv) != 1)
- return 1;
-#endif
-
- return 0;
+ return run_tests(argc, argv) ? 0 : 1;
}
#undef KIT_TEST_FILE