From: Erik van der Kouwe Date: Tue, 12 Jan 2010 09:53:39 +0000 (+0000) Subject: Add tests for sigsetjmp/siglongjmp X-Git-Tag: v3.1.6~92 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=483160f3d48b7cfd4272b59f3265345fc6e6d918;p=minix.git Add tests for sigsetjmp/siglongjmp --- diff --git a/test/test37.c b/test/test37.c index 0193db288..cb21f1ec3 100644 --- a/test/test37.c +++ b/test/test37.c @@ -56,6 +56,8 @@ _PROTOTYPE(void test37l, (void)); _PROTOTYPE(void func_m1, (void)); _PROTOTYPE(void func_m2, (void)); _PROTOTYPE(void test37m, (void)); +_PROTOTYPE(void test37p, (void)); +_PROTOTYPE(void test37q, (void)); _PROTOTYPE(void longjerr, (void)); _PROTOTYPE(void catch14, (int signo, int code, struct sigcontext * scp)); _PROTOTYPE(void test37n, (void)); @@ -70,7 +72,7 @@ int main(argc, argv) int argc; char *argv[]; { - int i, m = 0xFFFF; + int i, m = 0377777; sync(); @@ -99,6 +101,8 @@ char *argv[]; if (m & 0010000) test37m(); if (m & 0020000) test37n(); if (m & 0040000) test37o(); + if (m & 0100000) test37p(); + if (m & 0200000) test37q(); } quit(); @@ -871,26 +875,32 @@ void test37l() * signal mask is properly restored. */ -void test37m() -{ - jmp_buf jb; - sigset_t ss; - - subtest = 13; - clearsigstate(); - - ss = 0x32; - if (sigprocmask(SIG_SETMASK, &ss, (sigset_t *)NULL) == -1) e(1); - if (setjmp(jb)) { - if (sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &ss) == -1) e(2); - if (ss != 0x32) e(388); - return; - } - ss = 0x3abc; - if (sigprocmask(SIG_SETMASK, &ss, (sigset_t *)NULL) == -1) e(4); - longjmp(jb, 1); +#define TEST_SETJMP(_name, _subtest, _type, _setjmp, _longjmp, _save) \ +void _name(void) \ +{ \ + _type jb; \ + sigset_t ss, ssexp; \ + \ + subtest = _subtest; \ + clearsigstate(); \ + \ + ss = 0x32; \ + if (sigprocmask(SIG_SETMASK, &ss, (sigset_t *)NULL) == -1) e(1); \ + if (_setjmp) { \ + if (sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &ss) == -1) e(2); \ + ssexp = _save ? 0x32 : 0x3abc; \ + if ((ss ^ ssexp) & ~(1 << SIGKILL)) e(388); \ + return; \ + } \ + ss = 0x3abc; \ + if (sigprocmask(SIG_SETMASK, &ss, (sigset_t *)NULL) == -1) e(4); \ + _longjmp; \ } +TEST_SETJMP(test37m, 13, jmp_buf, setjmp(jb), longjmp(jb, 1), 1) +TEST_SETJMP(test37p, 16, sigjmp_buf, sigsetjmp(jb, 0), siglongjmp(jb, 1), 0) +TEST_SETJMP(test37q, 17, sigjmp_buf, sigsetjmp(jb, 1), siglongjmp(jb, 1), 1) + void longjerr() { e(5);