# HG changeset patch # User Tassilo Philipp # Date 1663603868 -7200 # Node ID f29db2bf3c0e0c3c74bd4522a7eb34b0edb1380d # Parent 1d6e51b1d4c7c57f1feaad660478b42c5ba98aaa - added exception handling to test/call{,back}_suite_aggrs - test/callback_suite_aggrs: added missing memory cleanup diff -r 1d6e51b1d4c7 -r f29db2bf3c0e test/call_suite_aggrs/globals.c --- a/test/call_suite_aggrs/globals.c Mon Sep 19 16:59:52 2022 +0200 +++ b/test/call_suite_aggrs/globals.c Mon Sep 19 18:11:08 2022 +0200 @@ -3,7 +3,7 @@ Package: dyncall Library: test File: test/call_suite_aggrs/globals.c - Description: + Description: License: Copyright (c) 2022 Tassilo Philipp @@ -27,7 +27,7 @@ #include #include -#define X(CH,T) T *V_##CH; T *K_##CH; +#define X(CH,T) T *V_##CH; T *K_##CH; DEF_TYPES #undef X @@ -117,8 +117,8 @@ { int i; for(i=0;i +#include +#include #include "../common/platformInit.h" #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */ @@ -225,9 +227,22 @@ return !failure; } + +jmp_buf jbuf; +void segv_handler(int sig) +{ + longjmp(jbuf, 1); +} + + int main(int argc, char* argv[]) { - int total, i; + int r = 0, i; + + signal(SIGSEGV, segv_handler); +#if !defined(DC_WINDOWS) + signal(SIGBUS, segv_handler); +#endif dcTest_initPlatform(); @@ -235,19 +250,20 @@ G_callvm = (DCCallVM*) dcNewCallVM(32768); dcReset(G_callvm); - total = run_all(); + if(setjmp(jbuf) == 0) + r = run_all(); - /* free all DCaggrs created on the fly */ - for(i=0; i=0; --i) dcFreeAggr(((DCaggr*(*)())G_agg_touchAfuncs[i])()); dcFree(G_callvm); deinit_test_data(G_maxargs); - printf("result: call_suite_aggrs: %d\n", total); + printf("result: call_suite_aggrs: %d\n", r); dcTest_deInitPlatform(); - return !total; + return !r; } diff -r 1d6e51b1d4c7 -r f29db2bf3c0e test/callback_suite_aggrs/globals.c --- a/test/callback_suite_aggrs/globals.c Mon Sep 19 16:59:52 2022 +0200 +++ b/test/callback_suite_aggrs/globals.c Mon Sep 19 18:11:08 2022 +0200 @@ -3,7 +3,7 @@ Package: dyncall Library: test File: test/callback_suite_aggrs/globals.c - Description: + Description: License: Copyright (c) 2022 Tassilo Philipp @@ -117,8 +117,8 @@ { int i; for(i=0;i #include #include +#include +#include #include "dyncall_callback.h" #include "globals.h" #include "../common/platformInit.h" @@ -273,12 +275,24 @@ } +jmp_buf jbuf; +void segv_handler(int sig) +{ + longjmp(jbuf, 1); +} + + #define Error(X, Y, N) { fprintf(stderr, X, Y); print_usage(N); exit(1); } int main(int argc, char* argv[]) { int from = 0, to = G_ncases-1; - int i, pos = 0, total; + int i, pos = 0, r = 0; + + signal(SIGSEGV, segv_handler); +#if !defined(DC_WINDOWS) + signal(SIGBUS, segv_handler); +#endif dcTest_initPlatform(); @@ -308,13 +322,19 @@ init_test_data(); - total = run_all(from, to); + if(setjmp(jbuf) == 0) + r = run_all(from, to); + + /* free all DCaggrs created on the fly (backwards b/c they are interdependency-ordered */ + for(i=G_naggs-1; i>=0; --i) + dcFreeAggr(((DCaggr*(*)())G_agg_touchAfuncs[i])()); + deinit_test_data(); - printf("result: callback_suite_aggrs: %d\n", total); + printf("result: callback_suite_aggrs: %d\n", r); dcTest_deInitPlatform(); - return !total; + return !r; }