diff options
Diffstat (limited to 'src/regress/lib')
| -rw-r--r-- | src/regress/lib/libc/sys/Makefile | 4 | ||||
| -rw-r--r-- | src/regress/lib/libc/sys/t_syscall.c | 123 |
2 files changed, 2 insertions, 125 deletions
diff --git a/src/regress/lib/libc/sys/Makefile b/src/regress/lib/libc/sys/Makefile index 86a8af55fa..93b977707a 100644 --- a/src/regress/lib/libc/sys/Makefile +++ b/src/regress/lib/libc/sys/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.14 2021/09/19 08:20:04 claudio Exp $ | 1 | # $OpenBSD: Makefile,v 1.15 2022/01/06 03:30:15 guenther Exp $ |
| 2 | 2 | ||
| 3 | # Copyright (c) 2019 Moritz Buhl <openbsd@moritzbuhl.de> | 3 | # Copyright (c) 2019 Moritz Buhl <openbsd@moritzbuhl.de> |
| 4 | # Copyright (c) 2019 Alexander Bluhm <bluhm@openbsd.org> | 4 | # Copyright (c) 2019 Alexander Bluhm <bluhm@openbsd.org> |
| @@ -63,7 +63,7 @@ PROGS += t_sigaction | |||
| 63 | PROGS += t_sigaltstack | 63 | PROGS += t_sigaltstack |
| 64 | PROGS += t_socketpair | 64 | PROGS += t_socketpair |
| 65 | PROGS += t_stat | 65 | PROGS += t_stat |
| 66 | PROGS += t_syscall | 66 | #PROGS += t_syscall Deleted: test of gcc1.x syscall pad |
| 67 | PROGS += t_truncate | 67 | PROGS += t_truncate |
| 68 | PROGS += t_umask t_unlink | 68 | PROGS += t_umask t_unlink |
| 69 | PROGS += t_vfork | 69 | PROGS += t_vfork |
diff --git a/src/regress/lib/libc/sys/t_syscall.c b/src/regress/lib/libc/sys/t_syscall.c deleted file mode 100644 index a8e3cd1288..0000000000 --- a/src/regress/lib/libc/sys/t_syscall.c +++ /dev/null | |||
| @@ -1,123 +0,0 @@ | |||
| 1 | /* $OpenBSD: t_syscall.c,v 1.4 2021/12/13 16:56:48 deraadt Exp $ */ | ||
| 2 | /* $NetBSD: t_syscall.c,v 1.4 2021/01/18 05:44:20 simonb Exp $ */ | ||
| 3 | |||
| 4 | /*- | ||
| 5 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | ||
| 6 | * All rights reserved. | ||
| 7 | * | ||
| 8 | * This code is derived from software contributed to The NetBSD Foundation | ||
| 9 | * by Martin Husemann. | ||
| 10 | * | ||
| 11 | * Redistribution and use in source and binary forms, with or without | ||
| 12 | * modification, are permitted provided that the following conditions | ||
| 13 | * are met: | ||
| 14 | * 1. Redistributions of source code must retain the above copyright | ||
| 15 | * notice, this list of conditions and the following disclaimer. | ||
| 16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 17 | * notice, this list of conditions and the following disclaimer in the | ||
| 18 | * documentation and/or other materials provided with the distribution. | ||
| 19 | * | ||
| 20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | ||
| 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
| 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | ||
| 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 30 | * POSSIBILITY OF SUCH DAMAGE. | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include "macros.h" | ||
| 34 | |||
| 35 | #include "atf-c.h" | ||
| 36 | #include <stdio.h> | ||
| 37 | #include <unistd.h> | ||
| 38 | #include <fcntl.h> | ||
| 39 | #include <err.h> | ||
| 40 | #include <string.h> | ||
| 41 | #include <stdlib.h> | ||
| 42 | #include <sys/mman.h> | ||
| 43 | #include <sys/endian.h> | ||
| 44 | #include <sys/syscall.h> | ||
| 45 | |||
| 46 | #ifdef __OpenBSD__ | ||
| 47 | /* Declare prototype of __syscall locally specifying the return type. */ | ||
| 48 | quad_t __syscall(quad_t number, ...); | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #if !defined(_LP64) && BYTE_ORDER == _BIG_ENDIAN | ||
| 52 | #define __SYSCALL_TO_UINTPTR_T(V) ((uintptr_t)((V)>>32)) | ||
| 53 | #else | ||
| 54 | #define __SYSCALL_TO_UINTPTR_T(V) ((uintptr_t)(V)) | ||
| 55 | #endif | ||
| 56 | |||
| 57 | static const char secrect_data[1024] = { | ||
| 58 | "my secret key\n" | ||
| 59 | }; | ||
| 60 | |||
| 61 | #define FILE_NAME "dummy" | ||
| 62 | |||
| 63 | #ifndef _LP64 | ||
| 64 | ATF_TC(mmap_syscall); | ||
| 65 | |||
| 66 | ATF_TC_HEAD(mmap_syscall, tc) | ||
| 67 | { | ||
| 68 | atf_tc_set_md_var(tc, "descr", "Tests mmap(2) via syscall(2)"); | ||
| 69 | } | ||
| 70 | |||
| 71 | ATF_TC_BODY(mmap_syscall, tc) | ||
| 72 | { | ||
| 73 | int fd; | ||
| 74 | const char *p; | ||
| 75 | |||
| 76 | fd = open(FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); | ||
| 77 | ATF_REQUIRE(fd != -1); | ||
| 78 | |||
| 79 | write(fd, secrect_data, sizeof(secrect_data)); | ||
| 80 | |||
| 81 | p = (const char *)syscall(SYS_mmap, | ||
| 82 | 0, sizeof(secrect_data), PROT_READ, MAP_PRIVATE, fd, 0, 0, 0); | ||
| 83 | ATF_REQUIRE(p != MAP_FAILED); | ||
| 84 | |||
| 85 | ATF_REQUIRE(strcmp(p, secrect_data) == 0); | ||
| 86 | } | ||
| 87 | #endif | ||
| 88 | |||
| 89 | ATF_TC(mmap___syscall); | ||
| 90 | |||
| 91 | ATF_TC_HEAD(mmap___syscall, tc) | ||
| 92 | { | ||
| 93 | atf_tc_set_md_var(tc, "descr", "Tests mmap(2) via __syscall(2)"); | ||
| 94 | } | ||
| 95 | |||
| 96 | ATF_TC_BODY(mmap___syscall, tc) | ||
| 97 | { | ||
| 98 | int fd; | ||
| 99 | const char *p; | ||
| 100 | |||
| 101 | fd = open(FILE_NAME, O_RDWR|O_CREAT|O_TRUNC, 0666); | ||
| 102 | ATF_REQUIRE(fd != -1); | ||
| 103 | |||
| 104 | write(fd, secrect_data, sizeof(secrect_data)); | ||
| 105 | |||
| 106 | p = (const char *)__SYSCALL_TO_UINTPTR_T(__syscall(SYS_mmap, | ||
| 107 | 0, sizeof(secrect_data), PROT_READ, MAP_PRIVATE, fd, | ||
| 108 | /* pad*/ 0, (off_t)0)); | ||
| 109 | ATF_REQUIRE(p != MAP_FAILED); | ||
| 110 | |||
| 111 | ATF_REQUIRE(strcmp(p, secrect_data) == 0); | ||
| 112 | } | ||
| 113 | |||
| 114 | ATF_TP_ADD_TCS(tp) | ||
| 115 | { | ||
| 116 | |||
| 117 | #ifndef _LP64 | ||
| 118 | ATF_TP_ADD_TC(tp, mmap_syscall); | ||
| 119 | #endif | ||
| 120 | ATF_TP_ADD_TC(tp, mmap___syscall); | ||
| 121 | |||
| 122 | return atf_no_error(); | ||
| 123 | } | ||
