From 18c1ebf3f6616119b72ec6c52900be92f4af93c4 Mon Sep 17 00:00:00 2001 From: mvs Date: Mon, 29 Nov 2021 21:25:09 +0000 Subject: [PATCH] Use nanosleep(3) instead of select(2) for test run time delay. Use ~10 years interval as operational infinity. --- regress/sys/kern/unconacc/unconacc.c | 12 ++++++------ regress/sys/kern/undgram_conclose/undgram_conclose.c | 12 ++++++------ regress/sys/kern/unsendrecvthr/unsendrecvthr.c | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/regress/sys/kern/unconacc/unconacc.c b/regress/sys/kern/unconacc/unconacc.c index 6b875fd0986..c687091260f 100644 --- a/regress/sys/kern/unconacc/unconacc.c +++ b/regress/sys/kern/unconacc/unconacc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unconacc.c,v 1.2 2021/11/29 21:21:26 mvs Exp $ */ +/* $OpenBSD: unconacc.c,v 1.3 2021/11/29 21:25:09 mvs Exp $ */ /* * Copyright (c) 2021 Vitaliy Makkoveev @@ -33,6 +33,7 @@ #include #include #include +#include #include static pthread_mutex_t therr_mtx = PTHREAD_MUTEX_INITIALIZER; @@ -121,11 +122,10 @@ thr_conn(void *arg) int main(int argc, char *argv[]) { - struct timeval testtime = { + struct timespec testtime = { .tv_sec = 60, - .tv_usec = 0, + .tv_nsec = 0, }; - struct timeval *tv = &testtime; struct sockaddr_un sun; int s; @@ -138,7 +138,7 @@ main(int argc, char *argv[]) umask(0077); if (argc == 2 && !strcmp(argv[1], "--infinite")) - tv = NULL; + testtime.tv_sec = (10 * 365 * 86400); mib[0] = CTL_HW; mib[1] = HW_NCPUONLINE; @@ -180,7 +180,7 @@ main(int argc, char *argv[]) therrc(1, error, "pthread_create"); } - select(0, NULL, NULL, NULL, tv); + nanosleep(&testtime, NULL); return 0; } diff --git a/regress/sys/kern/undgram_conclose/undgram_conclose.c b/regress/sys/kern/undgram_conclose/undgram_conclose.c index 85258a51375..678021d5714 100644 --- a/regress/sys/kern/undgram_conclose/undgram_conclose.c +++ b/regress/sys/kern/undgram_conclose/undgram_conclose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undgram_conclose.c,v 1.2 2021/11/29 21:21:26 mvs Exp $ */ +/* $OpenBSD: undgram_conclose.c,v 1.3 2021/11/29 21:25:09 mvs Exp $ */ /* * Copyright (c) 2021 Vitaliy Makkoveev @@ -33,6 +33,7 @@ #include #include #include +#include #include static pthread_mutex_t therr_mtx = PTHREAD_MUTEX_INITIALIZER; @@ -99,11 +100,10 @@ thr_conn(void *arg) int main(int argc, char *argv[]) { - struct timeval testtime = { + struct timespec testtime = { .tv_sec = 60, - .tv_usec = 0, + .tv_nsec = 0, }; - struct timeval *tv = &testtime; int mib[2], ncpu; size_t len; @@ -116,7 +116,7 @@ main(int argc, char *argv[]) umask(0077); if (argc == 2 && !strcmp(argv[1], "--infinite")) - tv = NULL; + testtime.tv_sec = (10 * 365 * 86400); mib[0] = CTL_HW; mib[1] = HW_NCPUONLINE; @@ -141,7 +141,7 @@ main(int argc, char *argv[]) therrc(1, error, "pthread_create"); } - select(0, NULL, NULL, NULL, tv); + nanosleep(&testtime, NULL); return 0; } diff --git a/regress/sys/kern/unsendrecvthr/unsendrecvthr.c b/regress/sys/kern/unsendrecvthr/unsendrecvthr.c index 45e81c051c6..a56848f5139 100644 --- a/regress/sys/kern/unsendrecvthr/unsendrecvthr.c +++ b/regress/sys/kern/unsendrecvthr/unsendrecvthr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unsendrecvthr.c,v 1.1 2021/11/19 17:07:10 mvs Exp $ */ +/* $OpenBSD: unsendrecvthr.c,v 1.2 2021/11/29 21:25:09 mvs Exp $ */ /* * Copyright (c) 2021 Vitaliy Makkoveev @@ -34,6 +34,7 @@ #include #include #include +#include #include static pthread_mutex_t therr_mtx = PTHREAD_MUTEX_INITIALIZER; @@ -149,11 +150,10 @@ thr_rx(void *arg) int main(int argc, char *argv[]) { - struct timeval testtime = { + struct timespec testtime = { .tv_sec = 60, - .tv_usec = 0, + .tv_nsec = 0, }; - struct timeval *tv = &testtime; int mib[2], ncpu; size_t len; @@ -165,7 +165,7 @@ main(int argc, char *argv[]) int s[2], i, j; if (argc == 2 && !strcmp(argv[1], "--infinite")) - tv = NULL; + testtime.tv_sec = (10 * 365 * 86400); mib[0] = CTL_HW; mib[1] = HW_NCPUONLINE; @@ -224,7 +224,7 @@ main(int argc, char *argv[]) } } - select(0, NULL, NULL, NULL, tv); + nanosleep(&testtime, NULL); return 0; } -- 2.20.1