Home | History | Annotate | Line # | Download | only in setjmp
t_setjmp.c revision 1.7
      1  1.7  riastrad /* $NetBSD: t_setjmp.c,v 1.7 2025/04/24 01:41:48 riastradh Exp $ */
      2  1.1  pgoyette 
      3  1.1  pgoyette /*-
      4  1.1  pgoyette  * Copyright (c) 2008 The NetBSD Foundation, Inc.
      5  1.1  pgoyette  * All rights reserved.
      6  1.1  pgoyette  *
      7  1.1  pgoyette  * Redistribution and use in source and binary forms, with or without
      8  1.1  pgoyette  * modification, are permitted provided that the following conditions
      9  1.1  pgoyette  * are met:
     10  1.1  pgoyette  * 1. Redistributions of source code must retain the above copyright
     11  1.1  pgoyette  *    notice, this list of conditions and the following disclaimer.
     12  1.1  pgoyette  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  pgoyette  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  pgoyette  *    documentation and/or other materials provided with the distribution.
     15  1.1  pgoyette  *
     16  1.1  pgoyette  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.1  pgoyette  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.1  pgoyette  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.1  pgoyette  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.1  pgoyette  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1  pgoyette  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1  pgoyette  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1  pgoyette  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1  pgoyette  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1  pgoyette  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  pgoyette  * POSSIBILITY OF SUCH DAMAGE.
     27  1.1  pgoyette  */
     28  1.1  pgoyette 
     29  1.1  pgoyette /*
     30  1.1  pgoyette  * Copyright (c) 1994 Christopher G. Demetriou
     31  1.1  pgoyette  * All rights reserved.
     32  1.6  riastrad  *
     33  1.1  pgoyette  * Redistribution and use in source and binary forms, with or without
     34  1.1  pgoyette  * modification, are permitted provided that the following conditions
     35  1.1  pgoyette  * are met:
     36  1.1  pgoyette  * 1. Redistributions of source code must retain the above copyright
     37  1.1  pgoyette  *    notice, this list of conditions and the following disclaimer.
     38  1.1  pgoyette  * 2. Redistributions in binary form must reproduce the above copyright
     39  1.1  pgoyette  *    notice, this list of conditions and the following disclaimer in the
     40  1.1  pgoyette  *    documentation and/or other materials provided with the distribution.
     41  1.1  pgoyette  * 3. All advertising materials mentioning features or use of this software
     42  1.1  pgoyette  *    must display the following acknowledgement:
     43  1.1  pgoyette  *          This product includes software developed for the
     44  1.1  pgoyette  *          NetBSD Project.  See http://www.NetBSD.org/ for
     45  1.1  pgoyette  *          information about NetBSD.
     46  1.1  pgoyette  * 4. The name of the author may not be used to endorse or promote products
     47  1.1  pgoyette  *    derived from this software without specific prior written permission.
     48  1.6  riastrad  *
     49  1.1  pgoyette  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     50  1.1  pgoyette  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     51  1.1  pgoyette  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     52  1.1  pgoyette  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     53  1.1  pgoyette  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     54  1.1  pgoyette  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     55  1.1  pgoyette  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     56  1.1  pgoyette  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     57  1.1  pgoyette  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     58  1.1  pgoyette  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     59  1.6  riastrad  *
     60  1.1  pgoyette  * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
     61  1.1  pgoyette  */
     62  1.1  pgoyette 
     63  1.1  pgoyette #include <sys/cdefs.h>
     64  1.1  pgoyette __COPYRIGHT("@(#) Copyright (c) 2008\
     65  1.1  pgoyette  The NetBSD Foundation, inc. All rights reserved.");
     66  1.7  riastrad __RCSID("$NetBSD: t_setjmp.c,v 1.7 2025/04/24 01:41:48 riastradh Exp $");
     67  1.1  pgoyette 
     68  1.1  pgoyette #include <sys/types.h>
     69  1.1  pgoyette 
     70  1.7  riastrad #include <dlfcn.h>
     71  1.1  pgoyette #include <errno.h>
     72  1.1  pgoyette #include <setjmp.h>
     73  1.1  pgoyette #include <signal.h>
     74  1.3  christos #include <stdbool.h>
     75  1.1  pgoyette #include <stdio.h>
     76  1.1  pgoyette #include <stdlib.h>
     77  1.1  pgoyette #include <string.h>
     78  1.1  pgoyette #include <unistd.h>
     79  1.1  pgoyette 
     80  1.1  pgoyette #include <atf-c.h>
     81  1.1  pgoyette 
     82  1.6  riastrad #include "h_macros.h"
     83  1.1  pgoyette 
     84  1.6  riastrad enum test {
     85  1.6  riastrad 	TEST_SETJMP,
     86  1.6  riastrad 	TEST_U_SETJMP,
     87  1.6  riastrad 	TEST_SIGSETJMP_SAVE,
     88  1.6  riastrad 	TEST_SIGSETJMP_NOSAVE,
     89  1.6  riastrad 	TEST_LONGJMP_ZERO,
     90  1.6  riastrad 	TEST_U_LONGJMP_ZERO,
     91  1.7  riastrad 
     92  1.7  riastrad 	TEST_COMPAT13_SETJMP,
     93  1.7  riastrad 	TEST_COMPAT13_SIGSETJMP_SAVE,
     94  1.7  riastrad 	TEST_COMPAT13_SIGSETJMP_NOSAVE,
     95  1.7  riastrad 	TEST_COMPAT13_LONGJMP_ZERO,
     96  1.6  riastrad };
     97  1.1  pgoyette 
     98  1.7  riastrad /*
     99  1.7  riastrad  * Optional compat13 functions from when sigcontext was expanded.
    100  1.7  riastrad  * Fortunately the only change visible to the caller is that the size
    101  1.7  riastrad  * of jmp_buf increased, so we can always use the old symbols with new
    102  1.7  riastrad  * jmp_buf arrays.
    103  1.7  riastrad  */
    104  1.7  riastrad int (*compat13_sigsetjmp)(sigjmp_buf, int);
    105  1.7  riastrad void (*compat13_siglongjmp)(sigjmp_buf, int);
    106  1.7  riastrad int (*compat13_setjmp)(jmp_buf);
    107  1.7  riastrad void (*compat13_longjmp)(jmp_buf, int);
    108  1.7  riastrad 
    109  1.7  riastrad /*
    110  1.7  riastrad  * compatsigsys(signo)
    111  1.7  riastrad  *
    112  1.7  riastrad  *	Signal handler for SIGSYS in case compat_13_sigreturn13 is not
    113  1.7  riastrad  *	implemented by the kernel -- we will just skip the test in that
    114  1.7  riastrad  *	case.
    115  1.7  riastrad  */
    116  1.7  riastrad static void
    117  1.7  riastrad compatsigsys(int signo)
    118  1.7  riastrad {
    119  1.7  riastrad 
    120  1.7  riastrad 	atf_tc_skip("no compat syscalls to test");
    121  1.7  riastrad }
    122  1.7  riastrad 
    123  1.7  riastrad static void
    124  1.7  riastrad compatsetup(void)
    125  1.7  riastrad {
    126  1.7  riastrad 
    127  1.7  riastrad 	/*
    128  1.7  riastrad 	 * Grab the libc library symbols if available.
    129  1.7  riastrad 	 */
    130  1.7  riastrad 	if ((compat13_sigsetjmp = dlsym(RTLD_SELF, "sigsetjmp")) == NULL ||
    131  1.7  riastrad 	    (compat13_siglongjmp = dlsym(RTLD_SELF, "siglongjmp")) == NULL ||
    132  1.7  riastrad 	    (compat13_setjmp = dlsym(RTLD_SELF, "setjmp")) == NULL ||
    133  1.7  riastrad 	    (compat13_longjmp = dlsym(RTLD_SELF, "longjmp")) == NULL)
    134  1.7  riastrad 		atf_tc_skip("no compat functions to test");
    135  1.7  riastrad 
    136  1.7  riastrad 	/*
    137  1.7  riastrad 	 * Arrange for SIGSYS to skip the test -- this happens if the
    138  1.7  riastrad 	 * libc stub has the function, but the kernel isn't built with
    139  1.7  riastrad 	 * support for the compat13 sigreturn syscall for longjmp.
    140  1.7  riastrad 	 */
    141  1.7  riastrad 	REQUIRE_LIBC(signal(SIGSYS, &compatsigsys), SIG_ERR);
    142  1.7  riastrad }
    143  1.7  riastrad 
    144  1.1  pgoyette static int expectsignal;
    145  1.1  pgoyette 
    146  1.1  pgoyette static void
    147  1.2  christos aborthandler(int signo __unused)
    148  1.1  pgoyette {
    149  1.1  pgoyette 	ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded");
    150  1.1  pgoyette 	atf_tc_pass();
    151  1.1  pgoyette }
    152  1.1  pgoyette 
    153  1.1  pgoyette static void
    154  1.6  riastrad h_check(enum test test)
    155  1.1  pgoyette {
    156  1.1  pgoyette 	struct sigaction sa;
    157  1.1  pgoyette 	jmp_buf jb;
    158  1.1  pgoyette 	sigjmp_buf sjb;
    159  1.1  pgoyette 	sigset_t ss;
    160  1.1  pgoyette 	int i, x;
    161  1.3  christos 	volatile bool did_longjmp;
    162  1.1  pgoyette 
    163  1.1  pgoyette 	i = getpid();
    164  1.3  christos 	did_longjmp = false;
    165  1.1  pgoyette 
    166  1.6  riastrad 	switch (test) {
    167  1.7  riastrad 	case TEST_COMPAT13_SETJMP:
    168  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_SAVE:
    169  1.7  riastrad 	case TEST_COMPAT13_LONGJMP_ZERO:
    170  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_NOSAVE:
    171  1.7  riastrad 		compatsetup();
    172  1.7  riastrad 		break;
    173  1.7  riastrad 	default:
    174  1.7  riastrad 		break;
    175  1.7  riastrad 	}
    176  1.7  riastrad 
    177  1.7  riastrad 	switch (test) {
    178  1.6  riastrad 	case TEST_SETJMP:
    179  1.6  riastrad 	case TEST_SIGSETJMP_SAVE:
    180  1.6  riastrad 	case TEST_LONGJMP_ZERO:
    181  1.7  riastrad 	case TEST_COMPAT13_SETJMP:
    182  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_SAVE:
    183  1.7  riastrad 	case TEST_COMPAT13_LONGJMP_ZERO:
    184  1.1  pgoyette 		expectsignal = 0;
    185  1.6  riastrad 		break;
    186  1.6  riastrad 	case TEST_U_SETJMP:
    187  1.6  riastrad 	case TEST_SIGSETJMP_NOSAVE:
    188  1.6  riastrad 	case TEST_U_LONGJMP_ZERO:
    189  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_NOSAVE:
    190  1.1  pgoyette 		expectsignal = 1;
    191  1.6  riastrad 		break;
    192  1.6  riastrad 	default:
    193  1.1  pgoyette 		atf_tc_fail("unknown test");
    194  1.6  riastrad 	}
    195  1.1  pgoyette 
    196  1.1  pgoyette 	sa.sa_handler = aborthandler;
    197  1.1  pgoyette 	sigemptyset(&sa.sa_mask);
    198  1.1  pgoyette 	sa.sa_flags = 0;
    199  1.6  riastrad 	RL(sigaction(SIGABRT, &sa, NULL));
    200  1.6  riastrad 	RL(sigemptyset(&ss));
    201  1.6  riastrad 	RL(sigaddset(&ss, SIGABRT));
    202  1.6  riastrad 	RL(sigprocmask(SIG_BLOCK, &ss, NULL));
    203  1.6  riastrad 
    204  1.6  riastrad 	switch (test) {
    205  1.6  riastrad 	case TEST_SETJMP:
    206  1.6  riastrad 	case TEST_LONGJMP_ZERO:
    207  1.1  pgoyette 		x = setjmp(jb);
    208  1.6  riastrad 		break;
    209  1.7  riastrad 	case TEST_COMPAT13_SETJMP:
    210  1.7  riastrad 	case TEST_COMPAT13_LONGJMP_ZERO:
    211  1.7  riastrad 		x = (*compat13_setjmp)(jb);
    212  1.7  riastrad 		break;
    213  1.6  riastrad 	case TEST_U_SETJMP:
    214  1.6  riastrad 	case TEST_U_LONGJMP_ZERO:
    215  1.1  pgoyette 		x = _setjmp(jb);
    216  1.6  riastrad 		break;
    217  1.6  riastrad 	case TEST_SIGSETJMP_SAVE:
    218  1.6  riastrad 	case TEST_SIGSETJMP_NOSAVE:
    219  1.1  pgoyette 		x = sigsetjmp(sjb, !expectsignal);
    220  1.6  riastrad 		break;
    221  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_SAVE:
    222  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_NOSAVE:
    223  1.7  riastrad 		x = (*compat13_sigsetjmp)(sjb, !expectsignal);
    224  1.7  riastrad 		break;
    225  1.6  riastrad 	default:
    226  1.6  riastrad 		atf_tc_fail("unknown test");
    227  1.6  riastrad 	}
    228  1.1  pgoyette 
    229  1.1  pgoyette 	if (x != 0) {
    230  1.6  riastrad 		switch (test) {
    231  1.6  riastrad 		case TEST_LONGJMP_ZERO:
    232  1.6  riastrad 		case TEST_U_LONGJMP_ZERO:
    233  1.7  riastrad 		case TEST_COMPAT13_LONGJMP_ZERO:
    234  1.3  christos 			ATF_REQUIRE_MSG(x == 1, "setjmp returned wrong value");
    235  1.6  riastrad 			break;
    236  1.6  riastrad 		default:
    237  1.3  christos 			ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value");
    238  1.6  riastrad 		}
    239  1.3  christos 
    240  1.1  pgoyette 		kill(i, SIGABRT);
    241  1.1  pgoyette 		ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed");
    242  1.1  pgoyette 		atf_tc_pass();
    243  1.3  christos 	} else if (did_longjmp) {
    244  1.3  christos 		atf_tc_fail("setjmp returned zero after longjmp");
    245  1.1  pgoyette 	}
    246  1.1  pgoyette 
    247  1.6  riastrad 	RL(sigprocmask(SIG_UNBLOCK, &ss, NULL));
    248  1.1  pgoyette 
    249  1.3  christos 	did_longjmp = true;
    250  1.6  riastrad 	switch (test) {
    251  1.6  riastrad 	case TEST_SETJMP:
    252  1.1  pgoyette 		longjmp(jb, i);
    253  1.6  riastrad 		break;
    254  1.7  riastrad 	case TEST_COMPAT13_SETJMP:
    255  1.7  riastrad 		(*compat13_longjmp)(jb, i);
    256  1.7  riastrad 		break;
    257  1.6  riastrad 	case TEST_LONGJMP_ZERO:
    258  1.3  christos 		longjmp(jb, 0);
    259  1.6  riastrad 		break;
    260  1.7  riastrad 	case TEST_COMPAT13_LONGJMP_ZERO:
    261  1.7  riastrad 		(*compat13_longjmp)(jb, 0);
    262  1.7  riastrad 		break;
    263  1.6  riastrad 	case TEST_U_SETJMP:
    264  1.1  pgoyette 		_longjmp(jb, i);
    265  1.6  riastrad 		break;
    266  1.6  riastrad 	case TEST_U_LONGJMP_ZERO:
    267  1.3  christos 		_longjmp(jb, 0);
    268  1.6  riastrad 		break;
    269  1.6  riastrad 	case TEST_SIGSETJMP_SAVE:
    270  1.6  riastrad 	case TEST_SIGSETJMP_NOSAVE:
    271  1.1  pgoyette 		siglongjmp(sjb, i);
    272  1.6  riastrad 		break;
    273  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_SAVE:
    274  1.7  riastrad 	case TEST_COMPAT13_SIGSETJMP_NOSAVE:
    275  1.7  riastrad 		(*compat13_siglongjmp)(sjb, i);
    276  1.7  riastrad 		break;
    277  1.6  riastrad 	default:
    278  1.6  riastrad 		atf_tc_fail("unknown test");
    279  1.6  riastrad 	}
    280  1.1  pgoyette 
    281  1.1  pgoyette 	atf_tc_fail("jmp failed");
    282  1.1  pgoyette }
    283  1.1  pgoyette 
    284  1.1  pgoyette ATF_TC(setjmp);
    285  1.1  pgoyette ATF_TC_HEAD(setjmp, tc)
    286  1.1  pgoyette {
    287  1.1  pgoyette 	atf_tc_set_md_var(tc, "descr", "Checks setjmp(3)");
    288  1.1  pgoyette }
    289  1.1  pgoyette ATF_TC_BODY(setjmp, tc)
    290  1.1  pgoyette {
    291  1.1  pgoyette 	h_check(TEST_SETJMP);
    292  1.1  pgoyette }
    293  1.1  pgoyette 
    294  1.1  pgoyette ATF_TC(_setjmp);
    295  1.1  pgoyette ATF_TC_HEAD(_setjmp, tc)
    296  1.1  pgoyette {
    297  1.1  pgoyette 	atf_tc_set_md_var(tc, "descr", "Checks _setjmp(3)");
    298  1.1  pgoyette }
    299  1.1  pgoyette ATF_TC_BODY(_setjmp, tc)
    300  1.1  pgoyette {
    301  1.1  pgoyette 	h_check(TEST_U_SETJMP);
    302  1.1  pgoyette }
    303  1.1  pgoyette 
    304  1.1  pgoyette ATF_TC(sigsetjmp_save);
    305  1.1  pgoyette ATF_TC_HEAD(sigsetjmp_save, tc)
    306  1.1  pgoyette {
    307  1.6  riastrad 	atf_tc_set_md_var(tc, "descr",
    308  1.6  riastrad 	    "Checks sigsetjmp(3) with savemask enabled");
    309  1.1  pgoyette }
    310  1.1  pgoyette ATF_TC_BODY(sigsetjmp_save, tc)
    311  1.1  pgoyette {
    312  1.1  pgoyette 	h_check(TEST_SIGSETJMP_SAVE);
    313  1.1  pgoyette }
    314  1.1  pgoyette 
    315  1.1  pgoyette ATF_TC(sigsetjmp_nosave);
    316  1.1  pgoyette ATF_TC_HEAD(sigsetjmp_nosave, tc)
    317  1.1  pgoyette {
    318  1.6  riastrad 	atf_tc_set_md_var(tc, "descr",
    319  1.6  riastrad 	    "Checks sigsetjmp(3) with savemask disabled");
    320  1.1  pgoyette }
    321  1.1  pgoyette ATF_TC_BODY(sigsetjmp_nosave, tc)
    322  1.1  pgoyette {
    323  1.1  pgoyette 	h_check(TEST_SIGSETJMP_NOSAVE);
    324  1.1  pgoyette }
    325  1.1  pgoyette 
    326  1.3  christos ATF_TC(longjmp_zero);
    327  1.3  christos ATF_TC_HEAD(longjmp_zero, tc)
    328  1.3  christos {
    329  1.6  riastrad 	atf_tc_set_md_var(tc, "descr",
    330  1.6  riastrad 	    "Checks longjmp(3) with a zero value");
    331  1.3  christos }
    332  1.3  christos ATF_TC_BODY(longjmp_zero, tc)
    333  1.3  christos {
    334  1.3  christos 	h_check(TEST_LONGJMP_ZERO);
    335  1.3  christos }
    336  1.3  christos 
    337  1.3  christos ATF_TC(_longjmp_zero);
    338  1.3  christos ATF_TC_HEAD(_longjmp_zero, tc)
    339  1.3  christos {
    340  1.6  riastrad 	atf_tc_set_md_var(tc, "descr",
    341  1.6  riastrad 	    "Checks _longjmp(3) with a zero value");
    342  1.3  christos }
    343  1.3  christos ATF_TC_BODY(_longjmp_zero, tc)
    344  1.3  christos {
    345  1.3  christos 	h_check(TEST_U_LONGJMP_ZERO);
    346  1.3  christos }
    347  1.3  christos 
    348  1.7  riastrad ATF_TC(compat13_setjmp);
    349  1.7  riastrad ATF_TC_HEAD(compat13_setjmp, tc)
    350  1.7  riastrad {
    351  1.7  riastrad 	atf_tc_set_md_var(tc, "descr", "Checks compat13 setjmp(3)");
    352  1.7  riastrad }
    353  1.7  riastrad ATF_TC_BODY(compat13_setjmp, tc)
    354  1.7  riastrad {
    355  1.7  riastrad #ifdef __mips__
    356  1.7  riastrad 	atf_tc_expect_fail("PR port-mips/59342:"
    357  1.7  riastrad 	    " compat_setjmp.S is confused about delay slots");
    358  1.7  riastrad #endif
    359  1.7  riastrad 	h_check(TEST_COMPAT13_SETJMP);
    360  1.7  riastrad }
    361  1.7  riastrad 
    362  1.7  riastrad ATF_TC(compat13_sigsetjmp_save);
    363  1.7  riastrad ATF_TC_HEAD(compat13_sigsetjmp_save, tc)
    364  1.7  riastrad {
    365  1.7  riastrad 	atf_tc_set_md_var(tc, "descr",
    366  1.7  riastrad 	    "Checks compat13 sigsetjmp(3) with savemask enabled");
    367  1.7  riastrad }
    368  1.7  riastrad ATF_TC_BODY(compat13_sigsetjmp_save, tc)
    369  1.7  riastrad {
    370  1.7  riastrad #ifdef __mips__
    371  1.7  riastrad 	atf_tc_expect_signal(-1, "PR port-mips/59342:"
    372  1.7  riastrad 	    " compat_setjmp.S is confused about delay slots"
    373  1.7  riastrad 	    "; and "
    374  1.7  riastrad 	    "PR port-mips/59343:"
    375  1.7  riastrad 	    " compat_sigsetjmp.S: missing RESTORE_GP64");
    376  1.7  riastrad #endif
    377  1.7  riastrad 	h_check(TEST_COMPAT13_SIGSETJMP_SAVE);
    378  1.7  riastrad }
    379  1.7  riastrad 
    380  1.7  riastrad ATF_TC(compat13_sigsetjmp_nosave);
    381  1.7  riastrad ATF_TC_HEAD(compat13_sigsetjmp_nosave, tc)
    382  1.7  riastrad {
    383  1.7  riastrad 	atf_tc_set_md_var(tc, "descr",
    384  1.7  riastrad 	    "Checks compat13 sigsetjmp(3) with savemask disabled");
    385  1.7  riastrad }
    386  1.7  riastrad ATF_TC_BODY(compat13_sigsetjmp_nosave, tc)
    387  1.7  riastrad {
    388  1.7  riastrad #ifdef __mips__
    389  1.7  riastrad 	atf_tc_expect_signal(-1, "PR port-mips/59343:"
    390  1.7  riastrad 	    " compat_sigsetjmp.S: missing RESTORE_GP64");
    391  1.7  riastrad #endif
    392  1.7  riastrad 	h_check(TEST_COMPAT13_SIGSETJMP_NOSAVE);
    393  1.7  riastrad }
    394  1.7  riastrad 
    395  1.7  riastrad ATF_TC(compat13_longjmp_zero);
    396  1.7  riastrad ATF_TC_HEAD(compat13_longjmp_zero, tc)
    397  1.7  riastrad {
    398  1.7  riastrad 	atf_tc_set_md_var(tc, "descr",
    399  1.7  riastrad 	    "Checks compat13 longjmp(3) with a zero value");
    400  1.7  riastrad }
    401  1.7  riastrad ATF_TC_BODY(compat13_longjmp_zero, tc)
    402  1.7  riastrad {
    403  1.7  riastrad #if defined __mips_o32		/* no compat13 setjmp on n32 or n64 */
    404  1.7  riastrad 	atf_tc_expect_fail("PR port-mips/59285:"
    405  1.7  riastrad 	    " _longjmp(..., 0) makes setjmp return 0, not 1");
    406  1.7  riastrad #elif defined __mips__		/* spectacularly broken before compatsigsys */
    407  1.7  riastrad 	/*
    408  1.7  riastrad 	 * PR port-mips/59342 (compat_setjmp.S is confused about delay
    409  1.7  riastrad 	 * slots) kicks in before compatsigsys has a chance to
    410  1.7  riastrad 	 * atf_tc_skip, so just do it early.
    411  1.7  riastrad 	 */
    412  1.7  riastrad 	atf_tc_skip("no compat syscalls to test");
    413  1.7  riastrad #endif
    414  1.7  riastrad 	h_check(TEST_COMPAT13_LONGJMP_ZERO);
    415  1.7  riastrad }
    416  1.7  riastrad 
    417  1.1  pgoyette ATF_TP_ADD_TCS(tp)
    418  1.1  pgoyette {
    419  1.7  riastrad 
    420  1.1  pgoyette 	ATF_TP_ADD_TC(tp, setjmp);
    421  1.1  pgoyette 	ATF_TP_ADD_TC(tp, _setjmp);
    422  1.1  pgoyette 	ATF_TP_ADD_TC(tp, sigsetjmp_save);
    423  1.1  pgoyette 	ATF_TP_ADD_TC(tp, sigsetjmp_nosave);
    424  1.3  christos 	ATF_TP_ADD_TC(tp, longjmp_zero);
    425  1.3  christos 	ATF_TP_ADD_TC(tp, _longjmp_zero);
    426  1.1  pgoyette 
    427  1.7  riastrad 	ATF_TP_ADD_TC(tp, compat13_setjmp);
    428  1.7  riastrad 	ATF_TP_ADD_TC(tp, compat13_sigsetjmp_save);
    429  1.7  riastrad 	ATF_TP_ADD_TC(tp, compat13_sigsetjmp_nosave);
    430  1.7  riastrad 	ATF_TP_ADD_TC(tp, compat13_longjmp_zero);
    431  1.7  riastrad 
    432  1.1  pgoyette 	return atf_no_error();
    433  1.1  pgoyette }
    434