1# $OpenBSD: Makefile,v 1.18 2023/10/31 08:00:33 claudio Exp $ 2 3# Copyright (c) 2019 Moritz Buhl <openbsd@moritzbuhl.de> 4# Copyright (c) 2019 Alexander Bluhm <bluhm@openbsd.org> 5# 6# Permission to use, copy, modify, and distribute this software for any 7# purpose with or without fee is hereby granted, provided that the above 8# copyright notice and this permission notice appear in all copies. 9# 10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 18# Each test program in PROGS may define several numbered subtests. 19# In a first step compile all programs and extract their parameters. 20# For each PROG define new regression subtests based on the test number. 21 22.if defined(NUMBERS) 23REGRESS_TARGETS = ${NUMBERS:C/(.*)/run-${PROG}-\1 cleanup-${PROG}-\1/} 24.else 25REGRESS_TARGETS = ${PROGS:S/^/run-/} 26.endif 27 28PROGS = 29PROGS += t_access 30PROGS += t_bind 31PROGS += t_chroot t_clock_gettime 32PROGS += t_connect 33PROGS += t_dup 34PROGS += t_fork 35PROGS += t_fsync 36PROGS += t_getgroups t_getitimer t_getlogin t_getpid t_getrusage 37PROGS += t_getsid t_getsockname t_gettimeofday 38PROGS += t_kevent 39PROGS += t_kill 40PROGS += t_link t_listen 41PROGS += t_minherit 42PROGS += t_mkdir 43PROGS += t_mkfifo 44PROGS += t_mknod 45PROGS += t_mlock 46PROGS += t_mmap 47PROGS += t_msgctl 48PROGS += t_msgget 49PROGS += t_msgrcv 50PROGS += t_msgsnd 51PROGS += t_msync 52PROGS += t_pipe 53PROGS += t_pipe2 54PROGS += t_poll 55PROGS += t_ppoll 56PROGS += t_ptrace 57PROGS += t_recvmmsg 58PROGS += t_revoke 59PROGS += t_select 60PROGS += t_sendmmsg 61PROGS += t_sendrecv 62PROGS += t_setrlimit 63PROGS += t_setuid 64PROGS += t_sigaction 65PROGS += t_sigaltstack 66PROGS += t_socketpair 67PROGS += t_stat 68#PROGS += t_syscall Deleted: test of gcc1.x syscall pad 69PROGS += t_truncate 70PROGS += t_umask t_unlink 71PROGS += t_vfork 72PROGS += t_waitid 73PROGS += t_wait_noproc 74PROGS += t_wait_noproc_wnohang 75PROGS += t_write 76 77# failing tests 78REGRESS_EXPECTED_FAILURES = 79REGRESS_EXPECTED_FAILURES += run-t_mlock-4 80REGRESS_EXPECTED_FAILURES += run-t_msgrcv-3 81 82. for t in run-t_fork-{3,4,5} 83${t}: 84 # Only works with a controlling tty 85 @echo DISABLED 86. endfor 87 88run-t_vfork-2: 89 # SIGSTOP with vfork is masked before exec(3)/exit(3) 90 # see NetBSD: kern_sig.c,v 1.345 91 @echo DISABLED 92 93. for p in ${PROGS} 94SRCS_$p = $p.c atf-c.c 95. endfor 96 97CFLAGS += -std=gnu99 98 99LDADD_t_getpid = -lpthread 100 101run-t_truncate: setup-t_truncate 102setup-t_truncate: 103 ${SUDO} touch truncate_test.root_owned 104 ${SUDO} chown root:wheel truncate_test.root_owned 105 106run-t_chroot: clean-dir 107run-t_ptrace: clean-dir 108clean-dir: 109 ${SUDO} rm -rf dir 110 111CLEANFILES = access dummy mmap truncate_test.root_owned 112 113.for p in ${PROGS} 114run-$p: $p 115 ulimit -c unlimited && \ 116 ntests="`./$p -n`" && \ 117 echo "1..$$ntests" && \ 118 tnumbers="`jot -ns' ' - 1 $$ntests`" && \ 119 ${.MAKE} -C ${.CURDIR} PROG=$p NUMBERS="$$tnumbers" regress 120.endfor 121 122.if defined(NUMBERS) 123CUR_USER != id -g 124 125. for n in ${NUMBERS} 126DESCR_$n != eval `./${PROG} -i $n` && echo $$DESCR 127REQ_USER_$n != eval `./${PROG} -i $n` && echo $$REQ_USER 128 129. if ${REQ_USER_$n} == "root" 130REGRESS_ROOT_TARGETS += run-${PROG}-$n 131. endif 132 133run-${PROG}-$n: 134 @echo "$n ${DESCR_$n}" 135. if ${REQ_USER_$n} == "root" 136 ${SUDO} ./${PROG} -r $n 137. elif ${REQ_USER_$n} == "unprivileged" && ${CUR_USER} == 0 138 ${SUDO} su ${BUILDUSER} -c exec ./${PROG} -r $n 139. elif ${REQ_USER_$n} == "unprivileged" || ${REQ_USER_$n} == "" 140 ./${PROG} -r $n 141. else 142 # bad REQ_USER: ${REQ_USER_$n} 143 false 144. endif 145 146cleanup-${PROG}-$n: 147 -./${PROG} -c $n 148 149. endfor 150.endif 151 152.include <bsd.regress.mk> 153