From b2bdbc04fb540e09593ae35ff3336dc3b378f73a Mon Sep 17 00:00:00 2001 From: bluhm <> Date: Fri, 22 Nov 2019 15:59:53 +0000 Subject: Sync tests with current NetBSD. Enable t_mkfifo test. from Moritz Buhl --- src/regress/lib/libc/sys/README | 11 +++++------ src/regress/lib/libc/sys/atf-c.c | 17 ++++++++++++++++- src/regress/lib/libc/sys/t_access.c | 8 ++++---- src/regress/lib/libc/sys/t_getitimer.c | 15 +++++++++------ src/regress/lib/libc/sys/t_stat.c | 12 ++++++------ src/regress/lib/libc/sys/t_write.c | 8 ++++---- 6 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/regress/lib/libc/sys/README b/src/regress/lib/libc/sys/README index 979f3bde4a..84a442eb5d 100644 --- a/src/regress/lib/libc/sys/README +++ b/src/regress/lib/libc/sys/README @@ -3,11 +3,11 @@ Regression tests for system calls ported from NetBSD. Reimplement ATF with many hacks to adjust the tests as little as possible. Tests passing without source file adjustments: -t_access t_getpid t_kill t_msgsnd t_sigaction -t_bind t_link t_msync t_socketpair t_getgroups -t_getsid t_listen t_pipe t_truncate t_getitimer -t_getsockname t_mkdir t_sendrecv t_umask t_getlogin -t_gettimeofday t_msgctl t_setuid t_write +t_access t_getpid t_link t_msgsnd t_sigaction +t_bind t_getsid t_listen t_msync t_socketpair +t_getgroups t_getsockname t_mkdir t_pipe t_truncate +t_getitimer t_gettimeofday t_mkfifo t_sendrecv t_umask +t_getlogin t_kill t_msgctl t_setuid t_write Tests passing after adjustments: t_chroot - fchroot is not implemented @@ -22,7 +22,6 @@ t_revoke - remove basic tests, revoke only on ttys supported t_select - remove sigset_t struct as it is int on OpenBSD Failing tests: -t_mkfifo - every test case fails now t_mlock - wrong errno, succeeds where not expected, POSIX imprecise t_mmap - ENOTBLK on test NetBSD is skipping, remove mmap_va0 test t_msgrcv - msgrcv(id, &r, 3 - 1, 0x41, 004000) != -1 diff --git a/src/regress/lib/libc/sys/atf-c.c b/src/regress/lib/libc/sys/atf-c.c index 45181c7353..e550a9b753 100644 --- a/src/regress/lib/libc/sys/atf-c.c +++ b/src/regress/lib/libc/sys/atf-c.c @@ -1,4 +1,19 @@ -/* $OpenBSD: atf-c.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */ +/* $OpenBSD: atf-c.c,v 1.2 2019/11/22 15:59:53 bluhm Exp $ */ +/* + * Copyright (c) 2019 Moritz Buhl + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ #include diff --git a/src/regress/lib/libc/sys/t_access.c b/src/regress/lib/libc/sys/t_access.c index 33888c7039..ed6410423b 100644 --- a/src/regress/lib/libc/sys/t_access.c +++ b/src/regress/lib/libc/sys/t_access.c @@ -1,5 +1,5 @@ -/* $OpenBSD: t_access.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */ -/* $NetBSD: t_access.c,v 1.2 2017/01/10 22:36:29 christos Exp $ */ +/* $OpenBSD: t_access.c,v 1.2 2019/11/22 15:59:53 bluhm Exp $ */ +/* $NetBSD: t_access.c,v 1.3 2019/07/16 17:29:18 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include "macros.h" #include -__RCSID("$NetBSD: t_access.c,v 1.2 2017/01/10 22:36:29 christos Exp $"); +__RCSID("$NetBSD: t_access.c,v 1.3 2019/07/16 17:29:18 martin Exp $"); #include "atf-c.h" @@ -62,7 +62,7 @@ ATF_TC_BODY(access_access, tc) size_t i; int fd; - fd = open(path, O_RDONLY | O_CREAT); + fd = open(path, O_RDONLY | O_CREAT, 0600); if (fd < 0) return; diff --git a/src/regress/lib/libc/sys/t_getitimer.c b/src/regress/lib/libc/sys/t_getitimer.c index b6cc4102bb..fbf9c28ccc 100644 --- a/src/regress/lib/libc/sys/t_getitimer.c +++ b/src/regress/lib/libc/sys/t_getitimer.c @@ -1,5 +1,5 @@ -/* $OpenBSD: t_getitimer.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */ -/* $NetBSD: t_getitimer.c,v 1.2 2012/03/22 18:20:46 christos Exp $ */ +/* $OpenBSD: t_getitimer.c,v 1.2 2019/11/22 15:59:53 bluhm Exp $ */ +/* $NetBSD: t_getitimer.c,v 1.3 2019/07/13 12:44:02 gson Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -179,11 +179,13 @@ ATF_TC_BODY(setitimer_old, tc) struct itimerval it, ot; /* - * Make two calls; the second one - * should store the old values. + * Make two calls; the second one should store the old + * timer value which should be the same as that set in + * the first call, or slightly less due to time passing + * between the two calls. */ it.it_value.tv_sec = 4; - it.it_value.tv_usec = 3; + it.it_value.tv_usec = 999999; it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; @@ -198,7 +200,8 @@ ATF_TC_BODY(setitimer_old, tc) ATF_REQUIRE(setitimer(ITIMER_REAL, &it, &ot) == 0); - if (ot.it_value.tv_sec != 4 || ot.it_value.tv_usec != 3) + /* Check seconds only as microseconds may have decremented */ + if (ot.it_value.tv_sec != 4) atf_tc_fail("setitimer(2) did not store old values"); } diff --git a/src/regress/lib/libc/sys/t_stat.c b/src/regress/lib/libc/sys/t_stat.c index ea7f4b24a2..73350c0e6a 100644 --- a/src/regress/lib/libc/sys/t_stat.c +++ b/src/regress/lib/libc/sys/t_stat.c @@ -1,5 +1,5 @@ -/* $OpenBSD: t_stat.c,v 1.1.1.1 2019/11/19 19:57:04 bluhm Exp $ */ -/* $NetBSD: t_stat.c,v 1.5 2017/01/13 20:06:50 christos Exp $ */ +/* $OpenBSD: t_stat.c,v 1.2 2019/11/22 15:59:53 bluhm Exp $ */ +/* $NetBSD: t_stat.c,v 1.6 2019/07/16 17:29:18 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include "macros.h" #include -__RCSID("$NetBSD: t_stat.c,v 1.5 2017/01/13 20:06:50 christos Exp $"); +__RCSID("$NetBSD: t_stat.c,v 1.6 2019/07/16 17:29:18 martin Exp $"); #include #include @@ -214,7 +214,7 @@ ATF_TC_BODY(stat_mtime, tc) (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); - fd[i] = open(path, O_WRONLY | O_CREAT); + fd[i] = open(path, O_WRONLY | O_CREAT, 0600); ATF_REQUIRE(fd[i] != -1); ATF_REQUIRE(write(fd[i], "X", 1) == 1); @@ -292,7 +292,7 @@ ATF_TC_BODY(stat_size, tc) size_t i; int fd; - fd = open(path, O_WRONLY | O_CREAT); + fd = open(path, O_WRONLY | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); for (i = 0; i < n; i++) { @@ -381,7 +381,7 @@ ATF_TC_BODY(stat_symlink, tc) (void)memset(&sa, 0, sizeof(struct stat)); (void)memset(&sb, 0, sizeof(struct stat)); - fd = open(path, O_WRONLY | O_CREAT); + fd = open(path, O_WRONLY | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE(symlink(path, pathlink) == 0); diff --git a/src/regress/lib/libc/sys/t_write.c b/src/regress/lib/libc/sys/t_write.c index d22f32383a..f05edb5bed 100644 --- a/src/regress/lib/libc/sys/t_write.c +++ b/src/regress/lib/libc/sys/t_write.c @@ -1,5 +1,5 @@ -/* $OpenBSD: t_write.c,v 1.1.1.1 2019/11/19 19:57:04 bluhm Exp $ */ -/* $NetBSD: t_write.c,v 1.6 2017/07/09 22:18:43 christos Exp $ */ +/* $OpenBSD: t_write.c,v 1.2 2019/11/22 15:59:53 bluhm Exp $ */ +/* $NetBSD: t_write.c,v 1.7 2019/07/16 17:29:18 martin Exp $ */ /*- * Copyright (c) 2001, 2008 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_write.c,v 1.6 2017/07/09 22:18:43 christos Exp $"); +__RCSID("$NetBSD: t_write.c,v 1.7 2019/07/16 17:29:18 martin Exp $"); #include #include @@ -176,7 +176,7 @@ ATF_TC_BODY(write_ret, tc) size_t i, j; int fd; - fd = open(path, O_WRONLY | O_CREAT); + fd = open(path, O_WRONLY | O_CREAT, 0600); ATF_REQUIRE(fd >= 0); (void)memset(buf, 'x', sizeof(buf)); -- cgit v1.2.3-55-g6feb