CVS commit: src/tests/lib/libossaudio
Module Name:src Committed By: andvar Date: Mon Aug 2 17:43:56 UTC 2021 Modified Files: src/tests/lib/libossaudio: t_ossaudio.c Log Message: s/suported/supported in comments To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libossaudio/t_ossaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libossaudio/t_ossaudio.c diff -u src/tests/lib/libossaudio/t_ossaudio.c:1.3 src/tests/lib/libossaudio/t_ossaudio.c:1.4 --- src/tests/lib/libossaudio/t_ossaudio.c:1.3 Sat Dec 26 15:28:52 2020 +++ src/tests/lib/libossaudio/t_ossaudio.c Mon Aug 2 17:43:55 2021 @@ -250,7 +250,7 @@ ATF_TC_BODY(oss_dsp_init, tc) * and some unsupported sample rates... "best effort" */ - /* closest suported rate is 1000 */ + /* closest supported rate is 1000 */ rate = 900; if (ioctl(fd, SNDCTL_DSP_SPEED, ) < 0) atf_tc_fail("ioctl SNDCTL_DSP_SPEED (900) failed"); @@ -259,7 +259,7 @@ ATF_TC_BODY(oss_dsp_init, tc) ATF_REQUIRE((fabs(900.0 - info.play.sample_rate) / 900.0) < 0.2); ATF_REQUIRE_EQ(rate, (int)info.play.sample_rate); - /* closest suported rate is 192000 */ + /* closest supported rate is 192000 */ rate = 197000; if (ioctl(fd, SNDCTL_DSP_SPEED, ) < 0) atf_tc_fail("ioctl SNDCTL_DSP_SPEED (197000) failed");
CVS commit: src/tests/lib/libc
Module Name:src Committed By: andvar Date: Mon Aug 2 17:41:07 UTC 2021 Modified Files: src/tests/lib/libc/locale: t_sprintf.c t_strfmon.c t_toupper.c src/tests/lib/libc/string: t_strcoll.c Log Message: s/diferent/different/ To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/locale/t_sprintf.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_strfmon.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_toupper.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strcoll.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/locale/t_sprintf.c diff -u src/tests/lib/libc/locale/t_sprintf.c:1.7 src/tests/lib/libc/locale/t_sprintf.c:1.8 --- src/tests/lib/libc/locale/t_sprintf.c:1.7 Fri Dec 1 01:08:35 2017 +++ src/tests/lib/libc/locale/t_sprintf.c Mon Aug 2 17:41:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sprintf.c,v 1.7 2017/12/01 01:08:35 kre Exp $ */ +/* $NetBSD: t_sprintf.c,v 1.8 2021/08/02 17:41:07 andvar Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2017\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_sprintf.c,v 1.7 2017/12/01 01:08:35 kre Exp $"); +__RCSID("$NetBSD: t_sprintf.c,v 1.8 2021/08/02 17:41:07 andvar Exp $"); #include #include @@ -193,7 +193,7 @@ ATF_TC(sprintf); ATF_TC_HEAD(sprintf, tc) { atf_tc_set_md_var(tc, "descr", - "Checks sprintf %%'d and %%'f under diferent locales"); + "Checks sprintf %%'d and %%'f under different locales"); } ATF_TC_BODY(sprintf, tc) { @@ -207,7 +207,7 @@ ATF_TC(strto); ATF_TC_HEAD(strto, tc) { atf_tc_set_md_var(tc, "descr", - "Checks strtol and strtod under diferent locales"); + "Checks strtol and strtod under different locales"); } ATF_TC_BODY(strto, tc) { @@ -221,7 +221,7 @@ ATF_TC(sscanf); ATF_TC_HEAD(sscanf, tc) { atf_tc_set_md_var(tc, "descr", - "Checks sscanf under diferent locales"); + "Checks sscanf under different locales"); } ATF_TC_BODY(sscanf, tc) { Index: src/tests/lib/libc/locale/t_strfmon.c diff -u src/tests/lib/libc/locale/t_strfmon.c:1.2 src/tests/lib/libc/locale/t_strfmon.c:1.3 --- src/tests/lib/libc/locale/t_strfmon.c:1.2 Thu Dec 7 22:23:14 2017 +++ src/tests/lib/libc/locale/t_strfmon.c Mon Aug 2 17:41:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strfmon.c,v 1.2 2017/12/07 22:23:14 kre Exp $ */ +/* $NetBSD: t_strfmon.c,v 1.3 2021/08/02 17:41:07 andvar Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: t_strfmon.c,v 1.2 2017/12/07 22:23:14 kre Exp $"); +__RCSID("$NetBSD: t_strfmon.c,v 1.3 2021/08/02 17:41:07 andvar Exp $"); #include #include @@ -41,7 +41,7 @@ ATF_TC(strfmon); ATF_TC_HEAD(strfmon, tc) { atf_tc_set_md_var(tc, "descr", - "Checks strfmon_l under diferent locales"); + "Checks strfmon_l under different locales"); } ATF_TC_BODY(strfmon, tc) Index: src/tests/lib/libc/locale/t_toupper.c diff -u src/tests/lib/libc/locale/t_toupper.c:1.1 src/tests/lib/libc/locale/t_toupper.c:1.2 --- src/tests/lib/libc/locale/t_toupper.c:1.1 Tue May 30 02:11:03 2017 +++ src/tests/lib/libc/locale/t_toupper.c Mon Aug 2 17:41:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $ */ +/* $NetBSD: t_toupper.c,v 1.2 2021/08/02 17:41:07 andvar Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2017\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $"); +__RCSID("$NetBSD: t_toupper.c,v 1.2 2021/08/02 17:41:07 andvar Exp $"); #include #include @@ -92,7 +92,7 @@ ATF_TC(toupper); ATF_TC_HEAD(toupper, tc) { atf_tc_set_md_var(tc, "descr", - "Checks toupper under diferent locales"); + "Checks toupper under different locales"); } ATF_TC_BODY(toupper, tc) @@ -108,7 +108,7 @@ ATF_TC(tolower); ATF_TC_HEAD(tolower, tc) { atf_tc_set_md_var(tc, "descr", - "Checks tolower under diferent locales"); + "Checks tolower under different locales"); } ATF_TC_BODY(tolower, tc) Index: src/tests/lib/libc/string/t_strcoll.c diff -u src/tests/lib/libc/string/t_strcoll.c:1.1 src/tests/lib/libc/string/t_strcoll.c:1.2 --- src/tests/lib/libc/string/t_strcoll.c:1.1 Fri May 26 01:24:19 2017 +++ src/tests/lib/libc/string/t_strcoll.c Mon Aug 2 17:41:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strcoll.c,v 1.1 2017/05/26 01:24:19 perseant Exp $ */ +/* $NetBSD: t_strcoll.c,v 1.2 2021/08/02 17:41:07 andvar Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2017\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_strcoll.c,v 1.1 2017/05/26 01:24:19 perseant Exp $"); +__RCSID("$NetBSD: t_strcoll.c,v 1.2
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: rin Date: Sat Jul 24 08:39:54 UTC 2021 Modified Files: src/tests/lib/libc/sys: t_ptrace_core_wait.h Log Message: For sh3, increment PC when PT_CONTINUE from trigger_trap(), as already done for aarch64, arm, and powerpc. Otherwise, child is trapped to the PTRACE_BREAKPOINT_ASM (== trapa) instruction indefinitely. Fix tests/lib/libc/sys/t_ptrace_wait*:core_dump_procinfo. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_ptrace_core_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_ptrace_core_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.3 src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.4 --- src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.3 Thu Oct 15 22:59:50 2020 +++ src/tests/lib/libc/sys/t_ptrace_core_wait.h Sat Jul 24 08:39:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_core_wait.h,v 1.3 2020/10/15 22:59:50 rin Exp $ */ +/* $NetBSD: t_ptrace_core_wait.h,v 1.4 2021/07/24 08:39:54 rin Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -208,7 +208,8 @@ ATF_TC_BODY(core_dump_procinfo, tc) DPRINTF("Before resuming the child process where it left off and " "without signal to be sent\n"); -#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__) +#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__) || \ +defined(__sh3__) /* * For these archs, program counter is not automatically incremented * by a trap instruction. We cannot increment PC in the trap handler, @@ -220,12 +221,7 @@ ATF_TC_BODY(core_dump_procinfo, tc) SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, , 0) != -1); SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, -# if defined(__aarch64__) || defined(__arm__) - (void *)(r.r_pc + PTRACE_BREAKPOINT_SIZE), -# elif defined(__powerpc__) - (void *)(r.pc + PTRACE_BREAKPOINT_SIZE), -# endif - 0) != -1); + (void *)(PTRACE_REG_PC() + PTRACE_BREAKPOINT_SIZE), 0) != -1); #else SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1); #endif
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: martin Date: Sat Jul 17 14:03:36 UTC 2021 Modified Files: src/tests/lib/libc/sys: t_wait.c Log Message: PR 56313: fix eroneous = that was meant to be == To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/sys/t_wait.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_wait.c diff -u src/tests/lib/libc/sys/t_wait.c:1.9 src/tests/lib/libc/sys/t_wait.c:1.10 --- src/tests/lib/libc/sys/t_wait.c:1.9 Mon Feb 4 09:35:11 2019 +++ src/tests/lib/libc/sys/t_wait.c Sat Jul 17 14:03:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_wait.c,v 1.9 2019/02/04 09:35:11 mrg Exp $ */ +/* $NetBSD: t_wait.c,v 1.10 2021/07/17 14:03:35 martin Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_wait.c,v 1.9 2019/02/04 09:35:11 mrg Exp $"); +__RCSID("$NetBSD: t_wait.c,v 1.10 2021/07/17 14:03:35 martin Exp $"); #include #include @@ -85,7 +85,7 @@ ATF_TC_BODY(wait6_exited, tc) default: ATF_REQUIRE(wait6(P_PID, pid, , WEXITED, , ) == pid); ATF_REQUIRE(WIFEXITED(st) && WEXITSTATUS(st) == 0x5a); - ATF_REQUIRE(si.si_status = 0x5a5a5a5a); + ATF_REQUIRE(si.si_status == 0x5a5a5a5a); ATF_REQUIRE(si.si_pid == pid); ATF_REQUIRE(si.si_uid == getuid()); ATF_REQUIRE(si.si_code == CLD_EXITED);
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: martin Date: Sat Jul 10 13:22:01 UTC 2021 Modified Files: src/tests/lib/libc/stdio: t_fmemopen.c Log Message: Use intmax_t to printf an off_t To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/stdio/t_fmemopen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/t_fmemopen.c diff -u src/tests/lib/libc/stdio/t_fmemopen.c:1.5 src/tests/lib/libc/stdio/t_fmemopen.c:1.6 --- src/tests/lib/libc/stdio/t_fmemopen.c:1.5 Sat Jul 10 07:50:33 2021 +++ src/tests/lib/libc/stdio/t_fmemopen.c Sat Jul 10 13:22:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fmemopen.c,v 1.5 2021/07/10 07:50:33 christos Exp $ */ +/* $NetBSD: t_fmemopen.c,v 1.6 2021/07/10 13:22:01 martin Exp $ */ /*- * Copyright (c)2010 Takehiko NOZAKI, @@ -965,7 +965,8 @@ ATF_TC_BODY(test19, tc) /* don't accept non nul character at end of buffer */ ATF_CHECK(fputc(0x1, fp) == EOF); ATF_CHECK_MSG(ftello(fp) == (off_t)t->n, -"%td != %td", ftello(fp), (off_t)t->n); +"%jd != %jd", (intmax_t)ftello(fp), +(intmax_t)t->n); ATF_CHECK(feof(fp) == 0); /* accept nul character at end of buffer */
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: christos Date: Sat Jul 10 07:50:33 UTC 2021 Modified Files: src/tests/lib/libc/stdio: t_fmemopen.c Log Message: add more info to ease future debugging. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdio/t_fmemopen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/t_fmemopen.c diff -u src/tests/lib/libc/stdio/t_fmemopen.c:1.4 src/tests/lib/libc/stdio/t_fmemopen.c:1.5 --- src/tests/lib/libc/stdio/t_fmemopen.c:1.4 Sat Oct 19 13:45:00 2013 +++ src/tests/lib/libc/stdio/t_fmemopen.c Sat Jul 10 03:50:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fmemopen.c,v 1.4 2013/10/19 17:45:00 christos Exp $ */ +/* $NetBSD: t_fmemopen.c,v 1.5 2021/07/10 07:50:33 christos Exp $ */ /*- * Copyright (c)2010 Takehiko NOZAKI, @@ -964,7 +964,8 @@ ATF_TC_BODY(test19, tc) /* don't accept non nul character at end of buffer */ ATF_CHECK(fputc(0x1, fp) == EOF); - ATF_CHECK(ftello(fp) == (off_t)t->n); + ATF_CHECK_MSG(ftello(fp) == (off_t)t->n, +"%td != %td", ftello(fp), (off_t)t->n); ATF_CHECK(feof(fp) == 0); /* accept nul character at end of buffer */
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: christos Date: Sat Jul 10 07:50:20 UTC 2021 Modified Files: src/tests/lib/libc/stdio: h_intr.c Log Message: space before star To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdio/h_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/h_intr.c diff -u src/tests/lib/libc/stdio/h_intr.c:1.4 src/tests/lib/libc/stdio/h_intr.c:1.5 --- src/tests/lib/libc/stdio/h_intr.c:1.4 Fri Jul 9 16:00:26 2021 +++ src/tests/lib/libc/stdio/h_intr.c Sat Jul 10 03:50:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $ */ +/* $NetBSD: h_intr.c,v 1.5 2021/07/10 07:50:20 christos Exp $ */ /** * Test of interrupted I/O to popen()ed commands. @@ -25,7 +25,7 @@ */ #include -__RCSID("$NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $"); +__RCSID("$NetBSD: h_intr.c,v 1.5 2021/07/10 07:50:20 christos Exp $"); #include #include @@ -48,12 +48,12 @@ static int rndmode(void); static sig_t xsignal(int signo, sig_t handler); static void alarmtimer(int wait); static void pr_star(int signo); -static int do_opts(int argc, char* argv[]); +static int do_opts(int argc, char *argv[]); static void usage(FILE *fp); /* Globals */ static struct options { - const char* cmd; /* cmd to run (which must read from stdin) */ + const char *cmd; /* cmd to run (which must read from stdin) */ size_t bsize; /* block size to use */ size_t asize; /* alt. stdio buffer size */ int btype; /* buffering type: _IONBF, ... */ @@ -74,8 +74,8 @@ static const struct { static void (*alarm_fn)(int);/* real/dummy alarm fn. */ static int (*sintr_fn)(int, int); /* " siginterrupt fn. */ -static ssize_t (*rd_fn)(FILE*, void*, size_t); /* read fn. */ -static ssize_t (*wr_fn)(FILE*, const void*, size_t); /* write fn. */ +static ssize_t (*rd_fn)(FILE *, void *, size_t); /* read fn. */ +static ssize_t (*wr_fn)(FILE *, const void *, size_t); /* write fn. */ enum { MB = 1024 * 1024, /* a megabyte */ @@ -91,7 +91,7 @@ enum { * M A I N */ int -main(int argc, char* argv[]) +main(int argc, char *argv[]) { int i, rc = EXIT_SUCCESS; @@ -205,9 +205,9 @@ fail: * maxread - syscall version */ ssize_t -smaxread(FILE* fp, void* buf, size_t size) +smaxread(FILE* fp, void *buf, size_t size) { - char* p = buf; + char *p = buf; ssize_t nrd = 0; ssize_t n; @@ -231,9 +231,9 @@ smaxread(FILE* fp, void* buf, size_t siz * maxread - stdio version */ ssize_t -maxread(FILE* fp, void* buf, size_t size) +maxread(FILE* fp, void *buf, size_t size) { - char* p = buf; + char *p = buf; ssize_t nrd = 0; size_t n; @@ -262,9 +262,9 @@ maxread(FILE* fp, void* buf, size_t size * maxwrite - syscall version */ ssize_t -smaxwrite(FILE* fp, const void* buf, size_t size) +smaxwrite(FILE* fp, const void *buf, size_t size) { - const char* p = buf; + const char *p = buf; ssize_t nwr = 0; ssize_t n; @@ -287,9 +287,9 @@ smaxwrite(FILE* fp, const void* buf, siz * maxwrite - stdio version (warning: substrate may be buggy) */ ssize_t -maxwrite(FILE* fp, const void* buf, size_t size) +maxwrite(FILE* fp, const void *buf, size_t size) { - const char* p = buf; + const char *p = buf; ssize_t nwr = 0; size_t n; @@ -412,7 +412,7 @@ btype2str(int val) } static int -str2btype(const char* s) +str2btype(const char *s) { for (size_t i = 0; i < __arraycount(btypes); i++) if (strcmp(btypes[i].name, s) == 0)
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: kre Date: Fri Jul 9 20:00:26 UTC 2021 Modified Files: src/tests/lib/libc/stdio: h_intr.c Log Message: Make opts.cmd const char * rather than char * -- nothing ever modifies the string it points to, it is never passed to a function not taking a const char * arg, and this allows "" (or other literal strings if ever needed) to be assigned to it - which should fix the build. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/stdio/h_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/h_intr.c diff -u src/tests/lib/libc/stdio/h_intr.c:1.3 src/tests/lib/libc/stdio/h_intr.c:1.4 --- src/tests/lib/libc/stdio/h_intr.c:1.3 Fri Jul 9 15:26:59 2021 +++ src/tests/lib/libc/stdio/h_intr.c Fri Jul 9 20:00:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $ */ +/* $NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $ */ /** * Test of interrupted I/O to popen()ed commands. @@ -25,7 +25,7 @@ */ #include -__RCSID("$NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $"); +__RCSID("$NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $"); #include #include @@ -53,7 +53,7 @@ static void usage(FILE *fp); /* Globals */ static struct options { - char* cmd; /* cmd to run (which must read from stdin) */ + const char* cmd; /* cmd to run (which must read from stdin) */ size_t bsize; /* block size to use */ size_t asize; /* alt. stdio buffer size */ int btype; /* buffering type: _IONBF, ... */
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: christos Date: Fri Jul 9 15:26:59 UTC 2021 Modified Files: src/tests/lib/libc/stdio: h_intr.c t_intr.sh Log Message: fixes from RVP To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/stdio/h_intr.c cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdio/t_intr.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/h_intr.c diff -u src/tests/lib/libc/stdio/h_intr.c:1.2 src/tests/lib/libc/stdio/h_intr.c:1.3 --- src/tests/lib/libc/stdio/h_intr.c:1.2 Thu Jul 8 11:21:40 2021 +++ src/tests/lib/libc/stdio/h_intr.c Fri Jul 9 11:26:59 2021 @@ -1,20 +1,20 @@ -/* $NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $ */ +/* $NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $ */ /** - * Test of interrupted writes to popen()'ed commands. + * Test of interrupted I/O to popen()ed commands. * * Example 1: - * ./h_fwrite -c "gzip -t" *.gz + * ./h_intr -c "gzip -t" *.gz * * Example 2: - * while :; do ./h_fwrite -b $((12*1024)) -t 10 -c "bzip2 -t" *.bz2; sleep 2; done + * while :; do ./h_intr -b $((12*1024)) -t 10 -c "bzip2 -t" *.bz2; sleep 2; done * * Example 3: * Create checksum file: * find /mnt -type f -exec sha512 -n {} + >SHA512 * * Check program: - * find /mnt -type f -exec ./h_fwrite -b 512 -c run.sh {} + + * find /mnt -type f -exec ./h_intr -b 512 -c run.sh {} + * * ./run.sh: #!/bin/sh @@ -25,7 +25,7 @@ */ #include -__RCSID("$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $"); +__RCSID("$NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $"); #include #include @@ -38,25 +38,29 @@ __RCSID("$NetBSD: h_intr.c,v 1.2 2021/07 #include #include -static int process(const char *fn); +static bool process(const char *fn); ssize_t maxread(FILE *fp, void *buf, size_t size); ssize_t smaxread(FILE *fp, void *buf, size_t size); ssize_t maxwrite(FILE *fp, const void *buf, size_t size); ssize_t smaxwrite(FILE *fp, const void *buf, size_t size); +static int rndbuf(void); +static int rndmode(void); static sig_t xsignal(int signo, sig_t handler); static void alarmtimer(int wait); static void pr_star(int signo); -static bool isvalid(const char *s); static int do_opts(int argc, char* argv[]); -static void usage(FILE* fp); +static void usage(FILE *fp); /* Globals */ static struct options { - size_t bsize; - size_t ssize; - int btype; - int tmout; - const char *cmd; + char* cmd; /* cmd to run (which must read from stdin) */ + size_t bsize; /* block size to use */ + size_t asize; /* alt. stdio buffer size */ + int btype; /* buffering type: _IONBF, ... */ + int tmout; /* alarm timeout */ + int flush; /* call fflush() after write if 1 */ + int rndbuf; /* switch buffer randomly if 1 */ + int rndmod; /* switch buffering modes randomly if 1 */ } opts; static const struct { @@ -68,15 +72,24 @@ static const struct { { "IOFBF", _IOFBF }, }; +static void (*alarm_fn)(int);/* real/dummy alarm fn. */ +static int (*sintr_fn)(int, int); /* " siginterrupt fn. */ +static ssize_t (*rd_fn)(FILE*, void*, size_t); /* read fn. */ +static ssize_t (*wr_fn)(FILE*, const void*, size_t); /* write fn. */ + enum { - MB = 1024 * 1024, - BSIZE = 16 * 1024, - DEF_MS = 100, - MS = 1000, + MB = 1024 * 1024, /* a megabyte */ + BSIZE = 16 * 1024, /* default RW buffer size */ + DEF_MS = 100, /* interrupt 10x a second */ + MS = 1000, /* msecs. in a second */ }; + +/** + * M A I N + */ int main(int argc, char* argv[]) { @@ -100,8 +113,8 @@ main(int argc, char* argv[]) sig_t osig = xsignal(SIGALRM, pr_star); - if (process(argv[i]) == 0) - printf("ok\n"); + if (process(argv[i]) == true) + printf(" OK\n"); else rc = EXIT_FAILURE; @@ -111,46 +124,79 @@ main(int argc, char* argv[]) return rc; } -static int +static bool process(const char *fn) { FILE *ifp, *ofp; - char *buf; + char *buf, *abuf; + int rc = false; size_t nw = 0; - int rc = EXIT_FAILURE; ssize_t n; - if ((buf = malloc(opts.bsize)) == NULL) - err(rc, "buffer alloc failed"); + abuf = NULL; + + if ((buf = malloc(opts.bsize)) == NULL) { + warn("buffer alloc failed"); + return rc; + } + + if ((abuf = malloc(opts.asize)) == NULL) { + warn("alt. buffer alloc failed"); + goto fail; + } if ((ifp = fopen(fn, "r")) == NULL) { warn("fopen failed: %s", fn); - return rc; + goto fail; + } + + if ((ofp = popen(opts.cmd, "w")) == NULL) { + warn("popen failed `%s'", opts.cmd); + goto fail; } - if ((ofp = popen(opts.cmd, "w")) == NULL) - err(rc, "popen failed `%s'", opts.cmd); + setvbuf(ofp, NULL, opts.btype, opts.asize); + setvbuf(ifp, NULL, opts.btype, opts.asize); - setvbuf(ofp, NULL, opts.btype, opts.ssize); - setvbuf(ifp, NULL, opts.btype, opts.ssize); + alarm_fn(opts.tmout); - alarmtimer(opts.tmout); - while ((n = maxread(ifp, buf, opts.bsize)) > 0) { + while
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: christos Date: Thu Jul 8 15:21:40 UTC 2021 Modified Files: src/tests/lib/libc/stdio: h_intr.c Log Message: fix printf format strings To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdio/h_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/h_intr.c diff -u src/tests/lib/libc/stdio/h_intr.c:1.1 src/tests/lib/libc/stdio/h_intr.c:1.2 --- src/tests/lib/libc/stdio/h_intr.c:1.1 Thu Jul 8 05:07:46 2021 +++ src/tests/lib/libc/stdio/h_intr.c Thu Jul 8 11:21:40 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $ */ +/* $NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $ */ /** * Test of interrupted writes to popen()'ed commands. @@ -25,7 +25,7 @@ */ #include -__RCSID("$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $"); +__RCSID("$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $"); #include #include @@ -144,7 +144,7 @@ process(const char *fn) nw += i; } alarmtimer(0); - // printf("%lu\n", nw); + // printf("%zu\n", nw); fclose(ifp); if (pclose(ofp) != 0) @@ -341,11 +341,11 @@ usage(FILE* fp) fprintf(fp, "%s: Test interrupted writes to popen()ed CMD.\n", getprogname()); fprintf(fp, "\n"); - fprintf(fp, " -b SIZE Buffer size (%lu)\n", opts.bsize); + fprintf(fp, " -b SIZE Buffer size (%zu)\n", opts.bsize); fprintf(fp, " -c CMDCommand to run on each FILE.\n"); fprintf(fp, " -hThis message.\n"); fprintf(fp, " -pBuffering type %s.\n", getbtype(opts.btype)); - fprintf(fp, " -s SIZE stdio buffer size (%lu)\n", opts.ssize); + fprintf(fp, " -s SIZE stdio buffer size (%zu)\n", opts.ssize); fprintf(fp, " -t TMOUT Interrupt writing to CMD every (%d) ms\n", opts.tmout); }
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: christos Date: Thu Jul 8 12:30:20 UTC 2021 Modified Files: src/tests/lib/libc/stdio: Makefile Log Message: need to set BINDIR To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libc/stdio/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/Makefile diff -u src/tests/lib/libc/stdio/Makefile:1.15 src/tests/lib/libc/stdio/Makefile:1.16 --- src/tests/lib/libc/stdio/Makefile:1.15 Thu Jul 8 05:07:46 2021 +++ src/tests/lib/libc/stdio/Makefile Thu Jul 8 08:30:20 2021 @@ -1,10 +1,12 @@ -# $NetBSD: Makefile,v 1.15 2021/07/08 09:07:46 christos Exp $ +# $NetBSD: Makefile,v 1.16 2021/07/08 12:30:20 christos Exp $ NOMAN= .include TESTSDIR= ${TESTSBASE}/lib/libc/stdio +BINDIR= ${TESTSDIR} + TESTS_C+= t_clearerr TESTS_C+= t_fflush TESTS_C+= t_fmemopen
CVS commit: src/tests/lib/libc/stdio
Module Name:src Committed By: christos Date: Thu Jul 8 09:07:46 UTC 2021 Modified Files: src/tests/lib/libc/stdio: Makefile Added Files: src/tests/lib/libc/stdio: h_intr.c h_makenumbers.c h_testnumbers.c t_intr.sh Log Message: Add interrupted I/O tests (from RVP) To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/stdio/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/stdio/h_intr.c \ src/tests/lib/libc/stdio/h_makenumbers.c \ src/tests/lib/libc/stdio/h_testnumbers.c \ src/tests/lib/libc/stdio/t_intr.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdio/Makefile diff -u src/tests/lib/libc/stdio/Makefile:1.14 src/tests/lib/libc/stdio/Makefile:1.15 --- src/tests/lib/libc/stdio/Makefile:1.14 Mon Jun 29 10:22:11 2020 +++ src/tests/lib/libc/stdio/Makefile Thu Jul 8 05:07:46 2021 @@ -1,5 +1,6 @@ -# $NetBSD: Makefile,v 1.14 2020/06/29 14:22:11 jruoho Exp $ +# $NetBSD: Makefile,v 1.15 2021/07/08 09:07:46 christos Exp $ +NOMAN= .include TESTSDIR= ${TESTSBASE}/lib/libc/stdio @@ -13,6 +14,11 @@ TESTS_C+= t_fputc TESTS_C+= t_popen TESTS_C+= t_printf TESTS_C+= t_scanf + +TESTS_SH+= t_intr + COPTS.t_printf.c += -Wno-format-nonliteral +PROGS+= h_intr h_makenumbers h_testnumbers + .include Added files: Index: src/tests/lib/libc/stdio/h_intr.c diff -u /dev/null src/tests/lib/libc/stdio/h_intr.c:1.1 --- /dev/null Thu Jul 8 05:07:46 2021 +++ src/tests/lib/libc/stdio/h_intr.c Thu Jul 8 05:07:46 2021 @@ -0,0 +1,421 @@ +/* $NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $ */ + +/** + * Test of interrupted writes to popen()'ed commands. + * + * Example 1: + * ./h_fwrite -c "gzip -t" *.gz + * + * Example 2: + * while :; do ./h_fwrite -b $((12*1024)) -t 10 -c "bzip2 -t" *.bz2; sleep 2; done + * + * Example 3: + * Create checksum file: + * find /mnt -type f -exec sha512 -n {} + >SHA512 + * + * Check program: + * find /mnt -type f -exec ./h_fwrite -b 512 -c run.sh {} + + * + * ./run.sh: + #!/bin/sh + set -eu + grep -q "^$(sha512 -q)" SHA512 + * + * Author: RVP at sdf.org + */ + +#include +__RCSID("$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int process(const char *fn); +ssize_t maxread(FILE *fp, void *buf, size_t size); +ssize_t smaxread(FILE *fp, void *buf, size_t size); +ssize_t maxwrite(FILE *fp, const void *buf, size_t size); +ssize_t smaxwrite(FILE *fp, const void *buf, size_t size); +static sig_t xsignal(int signo, sig_t handler); +static void alarmtimer(int wait); +static void pr_star(int signo); +static bool isvalid(const char *s); +static int do_opts(int argc, char* argv[]); +static void usage(FILE* fp); + +/* Globals */ +static struct options { + size_t bsize; + size_t ssize; + int btype; + int tmout; + const char *cmd; +} opts; + +static const struct { + const char *name; + int value; +} btypes[] = { + { "IONBF", _IONBF }, + { "IOLBF", _IOLBF }, + { "IOFBF", _IOFBF }, +}; + +enum { + MB = 1024 * 1024, + BSIZE = 16 * 1024, + DEF_MS = 100, + MS = 1000, +}; + + + +int +main(int argc, char* argv[]) +{ + int i, rc = EXIT_SUCCESS; + + i = do_opts(argc, argv); + argc -= i; + argv += i; + + if (argc == 0) { + usage(stderr); + return rc; + } + + xsignal(SIGPIPE, SIG_IGN); + for (i = 0; i < argc; i++) { + char *s = strdup(argv[i]); + printf("%s...", basename(s)); + fflush(stdout); + free(s); + + sig_t osig = xsignal(SIGALRM, pr_star); + + if (process(argv[i]) == 0) + printf("ok\n"); + else + rc = EXIT_FAILURE; + + xsignal(SIGALRM, osig); + } + + return rc; +} + +static int +process(const char *fn) +{ + FILE *ifp, *ofp; + char *buf; + size_t nw = 0; + int rc = EXIT_FAILURE; + ssize_t n; + + if ((buf = malloc(opts.bsize)) == NULL) + err(rc, "buffer alloc failed"); + + if ((ifp = fopen(fn, "r")) == NULL) { + warn("fopen failed: %s", fn); + return rc; + } + + if ((ofp = popen(opts.cmd, "w")) == NULL) + err(rc, "popen failed `%s'", opts.cmd); + + setvbuf(ofp, NULL, opts.btype, opts.ssize); + setvbuf(ifp, NULL, opts.btype, opts.ssize); + + alarmtimer(opts.tmout); + while ((n = maxread(ifp, buf, opts.bsize)) > 0) { + ssize_t i; + if ((i = maxwrite(ofp, buf, n)) == -1) { + warn("write failed"); + break; + } + nw += i; + } + alarmtimer(0); + // printf("%lu\n", nw); + + fclose(ifp); + if (pclose(ofp) != 0) + warn("command failed `%s'", opts.cmd); + else + rc = EXIT_SUCCESS; + + return rc; +} + +/** + * maxread - syscall version + */ +ssize_t +smaxread(FILE* fp, void* buf, size_t size) +{ + char* p = buf; + ssize_t nrd = 0; + ssize_t n; + + while (size > 0) { + n = read(fileno(fp), p, size); + if (n < 0) { + if (errno == EINTR) +continue; + else +return -1; + } else if (n == 0) + break; + p += n; + nrd += n; + size -= n; + } +
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:49:59 UTC 2021 Modified Files: src/tests/lib/libcurses/check_files: addstr2.chk addstr3.chk copywin6.chk copywin7.chk dupwin1.chk dupwin2.chk src/tests/lib/libcurses/tests: addstr Log Message: Update the check files to account for fixes to addstr.c To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/check_files/addstr2.chk \ src/tests/lib/libcurses/check_files/addstr3.chk cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/check_files/copywin6.chk \ src/tests/lib/libcurses/check_files/copywin7.chk cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/check_files/dupwin1.chk \ src/tests/lib/libcurses/check_files/dupwin2.chk cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/addstr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/check_files/addstr2.chk diff -u src/tests/lib/libcurses/check_files/addstr2.chk:1.1 src/tests/lib/libcurses/check_files/addstr2.chk:1.2 --- src/tests/lib/libcurses/check_files/addstr2.chk:1.1 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/addstr2.chk Tue Jun 22 07:49:58 2021 @@ -1 +1 @@ -cup24;1X0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890123456clearcup24;76Xa \ No newline at end of file +cup24;1X0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890123456cup24;1Xclearcup24;76Xa rmamhsmamcup24;1X \ No newline at end of file Index: src/tests/lib/libcurses/check_files/addstr3.chk diff -u src/tests/lib/libcurses/check_files/addstr3.chk:1.1 src/tests/lib/libcurses/check_files/addstr3.chk:1.2 --- src/tests/lib/libcurses/check_files/addstr3.chk:1.1 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/addstr3.chk Tue Jun 22 07:49:58 2021 @@ -1,2 +1,4 @@ -cup22;76Xa 0cup23;1X123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(cup24;1X)cup24;76Xel)clearcup23;76Xa -hello \ No newline at end of file +csr2;24Xhomehome +rin1Xcsr1;24Xhomehomecup24;1Xhome +()cup23;1X0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*cup2;3Xclear +hellocup23;76Xacup2;6X \ No newline at end of file Index: src/tests/lib/libcurses/check_files/copywin6.chk diff -u src/tests/lib/libcurses/check_files/copywin6.chk:1.3 src/tests/lib/libcurses/check_files/copywin6.chk:1.4 --- src/tests/lib/libcurses/check_files/copywin6.chk:1.3 Sun May 26 07:28:15 2019 +++ src/tests/lib/libcurses/check_files/copywin6.chk Tue Jun 22 07:49:58 2021 @@ -1,4 +1,4 @@ cup3;6Xstingt ingtes gtesti - estingcup8;6X \ No newline at end of file + estingcup4;6X \ No newline at end of file Index: src/tests/lib/libcurses/check_files/copywin7.chk diff -u src/tests/lib/libcurses/check_files/copywin7.chk:1.3 src/tests/lib/libcurses/check_files/copywin7.chk:1.4 --- src/tests/lib/libcurses/check_files/copywin7.chk:1.3 Sun May 26 07:28:15 2019 +++ src/tests/lib/libcurses/check_files/copywin7.chk Tue Jun 22 07:49:58 2021 @@ -1,4 +1,4 @@ -el +el el el elcup11;15Xelcup12;15Xelcup13;15Xelcup14;15Xelcup15;15Xelcup17;15Xel \ No newline at end of file Index: src/tests/lib/libcurses/check_files/dupwin1.chk diff -u src/tests/lib/libcurses/check_files/dupwin1.chk:1.2 src/tests/lib/libcurses/check_files/dupwin1.chk:1.3 --- src/tests/lib/libcurses/check_files/dupwin1.chk:1.2 Tue Jun 11 08:09:36 2019 +++ src/tests/lib/libcurses/check_files/dupwin1.chk Tue Jun 22 07:49:58 2021 @@ -3,4 +3,4 @@ 33 44 55 - 66 cup9;13X11cup10;13X22cup11;13X33cup12;13X44cup13;13X55cup14;13X66cup14;13X \ No newline at end of file + 66 cup9;13X11cup10;13X22cup11;13X33cup12;13X44cup13;13X55cup14;13X66 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/dupwin2.chk diff -u src/tests/lib/libcurses/check_files/dupwin2.chk:1.2 src/tests/lib/libcurses/check_files/dupwin2.chk:1.3 --- src/tests/lib/libcurses/check_files/dupwin2.chk:1.2 Tue Jun 11 08:09:36 2019 +++ src/tests/lib/libcurses/check_files/dupwin2.chk Tue Jun 22 07:49:58 2021 @@ -1 +1 @@ -cup8;6Xcup9;13Xaacup10;13Xbbcup11;13Xcccup12;13Xddcup13;13Xeecup14;13Xffcup14;13X \ No newline at end of file +cup9;13Xaacup10;13Xbbcup11;13Xcccup12;13Xddcup13;13Xeecup14;13Xffcup14;13X \ No newline at end of file Index: src/tests/lib/libcurses/tests/addstr diff -u src/tests/lib/libcurses/tests/addstr:1.3 src/tests/lib/libcurses/tests/addstr:1.4 --- src/tests/lib/libcurses/tests/addstr:1.3 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/tests/addstr Tue Jun 22 07:49:58 2021 @@ -9,12 +9,12 @@ compare addstr.chk # Checks for PR#56224 # call OK move 23 0 -# the addstr should be truncated since no scrolling -call OK addstr
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: blymn Date: Tue Jun 22 07:29:16 UTC 2021 Modified Files: src/tests/lib/libcurses/check_files: slk1.chk slk3.chk slk5.chk slk6.chk slk_init.chk src/tests/lib/libcurses/tests: slk Log Message: Fix slk test and check files due to libcurses slk changes. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/check_files/slk1.chk \ src/tests/lib/libcurses/check_files/slk3.chk \ src/tests/lib/libcurses/check_files/slk5.chk \ src/tests/lib/libcurses/check_files/slk6.chk \ src/tests/lib/libcurses/check_files/slk_init.chk cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/slk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/check_files/slk1.chk diff -u src/tests/lib/libcurses/check_files/slk1.chk:1.2 src/tests/lib/libcurses/check_files/slk1.chk:1.3 --- src/tests/lib/libcurses/check_files/slk1.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk1.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -cup24;1Xrevone sgr0smsosmulrev one rmsormulsgr0smsorev onermsosgr0cup24;42Xsmulrev five cup24;73Xeight!!cup24;50Xrmulsgr0 \ No newline at end of file +cup24;1Xrevone sgr0smsosmulrev one rmsormulsgr0smsorev onermsosgr0cup24;42Xsmulrev five cup24;73Xeight!!rmam!smamcup24;50Xrmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk3.chk diff -u src/tests/lib/libcurses/check_files/slk3.chk:1.2 src/tests/lib/libcurses/check_files/slk3.chk:1.3 --- src/tests/lib/libcurses/check_files/slk3.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk3.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -smulrev one five eight!!rmulsgr0 \ No newline at end of file +smulrev one five eight!!rmam!smamrmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk5.chk diff -u src/tests/lib/libcurses/check_files/slk5.chk:1.2 src/tests/lib/libcurses/check_files/slk5.chk:1.3 --- src/tests/lib/libcurses/check_files/slk5.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk5.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -cup24;1Xsmulrev onesgr0 smulrev two sgr0 smulrevsgr0 smulrevsgr0 smulrev five sgr0 smulrevsgr0 smulrevsgr0 smulreveight!!rmulsgr0elcup24;18X \ No newline at end of file +cup24;1Xsmulrev onesgr0 smulrev two sgr0 smulrevsgr0 smulrevsgr0 smulrev five sgr0 smulrevsgr0 smulrevsgr0 smulreveight!!rmam!smamcup24;18Xrmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk6.chk diff -u src/tests/lib/libcurses/check_files/slk6.chk:1.2 src/tests/lib/libcurses/check_files/slk6.chk:1.3 --- src/tests/lib/libcurses/check_files/slk6.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk6.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -opsetaf7Xsetab0Xsmulrev onesgr0setaf7Xsetab0X smulrev two sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X setaf1Xsetab2Xsmulrevfoursgr0setaf7Xsetab0X smulrev five sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulreveight!!rmulsgr0opsetaf7Xsetab0Xelcup24;40Xop \ No newline at end of file +opsetaf7Xsetab0Xsmulrev onesgr0setaf7Xsetab0X smulrev two sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X setaf1Xsetab2Xsmulrevfoursgr0setaf7Xsetab0X smulrev five sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulreveight!!rmam!smamcup24;40Xrmulsgr0op \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk_init.chk diff -u src/tests/lib/libcurses/check_files/slk_init.chk:1.2 src/tests/lib/libcurses/check_files/slk_init.chk:1.3 --- src/tests/lib/libcurses/check_files/slk_init.chk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/check_files/slk_init.chk Tue Jun 22 07:29:16 2021 @@ -1 +1 @@ -enacsenacssmcupcnormclearcup24;1Xrevsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 rev sgr0elcup1;1X \ No newline at end of file +enacsenacssmcupcnormclearcup24;1Xrevsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 revsgr0 rev rmam smamcup1;1Xsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/tests/slk diff -u src/tests/lib/libcurses/tests/slk:1.3 src/tests/lib/libcurses/tests/slk:1.4 --- src/tests/lib/libcurses/tests/slk:1.3 Tue Jun 15 22:21:09 2021 +++ src/tests/lib/libcurses/tests/slk Tue Jun 22 07:29:16 2021 @@ -54,8 +54,7 @@ call OK slk_refresh compare slk6.chk # test slk_wset -# returning ERR now - blymn 20210606
CVS commit: src/tests/lib/libcurses/tests
Module Name:src Committed By: blymn Date: Tue Jun 15 22:21:09 UTC 2021 Modified Files: src/tests/lib/libcurses/tests: slk Log Message: Restore the slk_wset test after fixing a but in libcurses. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/tests/slk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/tests/slk diff -u src/tests/lib/libcurses/tests/slk:1.2 src/tests/lib/libcurses/tests/slk:1.3 --- src/tests/lib/libcurses/tests/slk:1.2 Sun Jun 6 04:57:58 2021 +++ src/tests/lib/libcurses/tests/slk Tue Jun 15 22:21:09 2021 @@ -56,6 +56,6 @@ compare slk6.chk # test slk_wset # returning ERR now - blymn 20210606 # [buggy??] 'b' should be printed as (wcswidth(wstr) == 6) <= 8 -#wchar WSTR [0x3401, "a", 0x3401, "b"] -#call OK slk_wset 3 $WSTR 1 -#call OK slk_refresh +wchar WSTR [0x3401, "a", 0x3401, "b"] +call OK slk_wset 3 $WSTR 1 +call OK slk_refresh
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 21:54:52 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: fix argument handling for mvwget_wch There's currently no test for that function, therefore no functional change. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.28 src/tests/lib/libcurses/slave/curses_commands.c:1.29 --- src/tests/lib/libcurses/slave/curses_commands.c:1.28 Sun Jun 13 19:17:53 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Sun Jun 13 21:54:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.28 2021/06/13 19:17:53 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.29 2021/06/13 21:54:51 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -4084,7 +4084,7 @@ cmd_mvwget_wch(int nargs, char **args) { wchar_t ch; - ARGC(1); /* FIXME: 3 */ + ARGC(3); ARG_WINDOW(win); ARG_INT(y); ARG_INT(x);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 19:50:18 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: lint.lua Log Message: tests/libcurses: make error handling in the linter simpler To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/lint.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/lint.lua diff -u src/tests/lib/libcurses/slave/lint.lua:1.5 src/tests/lib/libcurses/slave/lint.lua:1.6 --- src/tests/lib/libcurses/slave/lint.lua:1.5 Sun Jun 13 19:41:12 2021 +++ src/tests/lib/libcurses/slave/lint.lua Sun Jun 13 19:50:18 2021 @@ -1,5 +1,5 @@ #! /usr/bin/lua --- $NetBSD: lint.lua,v 1.5 2021/06/13 19:41:12 rillig Exp $ +-- $NetBSD: lint.lua,v 1.6 2021/06/13 19:50:18 rillig Exp $ --[[ @@ -24,18 +24,10 @@ local function load_lines(fname) return lines end - -local function new_errors() - local errors = {} - errors.add = function(self, fmt, ...) -table.insert(self, string.format(fmt, ...)) - end - errors.print = function(self) -for _, msg in ipairs(self) do - print(msg) -end - end - return errors +local had_errors = false +local function print_error(fmt, ...) + print(fmt:format(...)) + had_errors = true end @@ -46,7 +38,7 @@ end -- After each macro ARGC, there must be the corresponding macros for ARG. -local function check_args(errors) +local function check_args() local fname = "curses_commands.c" local lines = load_lines(fname) local curr_argc, curr_arg ---@type number|nil, number|nil @@ -66,9 +58,9 @@ local function check_args(errors) curr_argc, curr_arg = nil, nil end elseif line_arg then - errors:add("%s:%d: ARG without preceding ARGC", fname, lineno) + print_error("%s:%d: ARG without preceding ARGC", fname, lineno) elseif curr_arg then - errors:add("%s:%d: expecting ARG %d, got %s", + print_error("%s:%d: expecting ARG %d, got %s", fname, lineno, curr_arg, line) curr_argc, curr_arg = nil, nil end @@ -77,13 +69,5 @@ local function check_args(errors) end end - -local function main(arg) - local errors = new_errors() - check_args(errors) - errors:print() - return #errors == 0 -end - - -os.exit(main(arg)) +check_args() +os.exit(not had_errors)
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 19:41:12 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: lint.lua Log Message: tests/libcurses: improve code locality in linter No functional change. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libcurses/slave/lint.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/lint.lua diff -u src/tests/lib/libcurses/slave/lint.lua:1.4 src/tests/lib/libcurses/slave/lint.lua:1.5 --- src/tests/lib/libcurses/slave/lint.lua:1.4 Sun Jun 13 19:25:08 2021 +++ src/tests/lib/libcurses/slave/lint.lua Sun Jun 13 19:41:12 2021 @@ -1,5 +1,5 @@ #! /usr/bin/lua --- $NetBSD: lint.lua,v 1.4 2021/06/13 19:25:08 rillig Exp $ +-- $NetBSD: lint.lua,v 1.5 2021/06/13 19:41:12 rillig Exp $ --[[ @@ -53,29 +53,27 @@ local function check_args(errors) for lineno, line in ipairs(lines) do -local line_argc = num(line:match("^\tARGC%((%d)")) -local line_arg = line:match("^\tARG_[%w_]+%(") - +local line_argc = num(line:match("^\tARGC%((%d+)")) if line_argc and line_argc > 0 then curr_argc, curr_arg = line_argc, 0 + goto next end -if line_arg and not curr_arg then - errors:add("%s:%d: ARG without preceding ARGC", fname, lineno) -end - -if not line_arg and curr_arg and not line_argc then - errors:add("%s:%d: expecting ARG %d, got %s", -fname, lineno, curr_arg, line) - curr_argc, curr_arg = nil, nil -end - +local line_arg = line:match("^\tARG_[%w_]+%(") if line_arg and curr_arg then curr_arg = curr_arg + 1 if curr_arg == curr_argc then curr_argc, curr_arg = nil, nil end +elseif line_arg then + errors:add("%s:%d: ARG without preceding ARGC", fname, lineno) +elseif curr_arg then + errors:add("%s:%d: expecting ARG %d, got %s", +fname, lineno, curr_arg, line) + curr_argc, curr_arg = nil, nil end + +::next:: end end
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 19:25:08 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: lint.lua Log Message: tests/libcurses: improve local variable names in linter To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/slave/lint.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/lint.lua diff -u src/tests/lib/libcurses/slave/lint.lua:1.3 src/tests/lib/libcurses/slave/lint.lua:1.4 --- src/tests/lib/libcurses/slave/lint.lua:1.3 Sun Jun 13 18:11:44 2021 +++ src/tests/lib/libcurses/slave/lint.lua Sun Jun 13 19:25:08 2021 @@ -1,11 +1,11 @@ #! /usr/bin/lua --- $NetBSD: lint.lua,v 1.3 2021/06/13 18:11:44 rillig Exp $ +-- $NetBSD: lint.lua,v 1.4 2021/06/13 19:25:08 rillig Exp $ --[[ usage: lua ./lint.lua -Check that the boilerplate code does not contain unintended +Check that the argument handling code does not contain unintended inconsistencies. ]] @@ -49,29 +49,31 @@ end local function check_args(errors) local fname = "curses_commands.c" local lines = load_lines(fname) - local argi, argc + local curr_argc, curr_arg ---@type number|nil, number|nil for lineno, line in ipairs(lines) do -local c = num(line:match("^\tARGC%((%d)")) -if c and c > 0 then - argc, argi = c, 0 +local line_argc = num(line:match("^\tARGC%((%d)")) +local line_arg = line:match("^\tARG_[%w_]+%(") + +if line_argc and line_argc > 0 then + curr_argc, curr_arg = line_argc, 0 end -local arg = line:match("^\tARG_[%w_]+%(") -if arg and not argi then +if line_arg and not curr_arg then errors:add("%s:%d: ARG without preceding ARGC", fname, lineno) end -if not arg and argi and not c then - errors:add("%s:%d: expecting ARG %d, got %s", fname, lineno, argi, line) - argc, argi = nil, nil +if not line_arg and curr_arg and not line_argc then + errors:add("%s:%d: expecting ARG %d, got %s", +fname, lineno, curr_arg, line) + curr_argc, curr_arg = nil, nil end -if arg and argi then - argi = argi + 1 - if argi == argc then -argc, argi = nil, nil +if line_arg and curr_arg then + curr_arg = curr_arg + 1 + if curr_arg == curr_argc then +curr_argc, curr_arg = nil, nil end end end
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 19:17:53 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c curses_commands.h Log Message: tests/libcurses: unexport argument handling functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libcurses/slave/curses_commands.c cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/curses_commands.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.27 src/tests/lib/libcurses/slave/curses_commands.c:1.28 --- src/tests/lib/libcurses/slave/curses_commands.c:1.27 Sun Jun 13 19:13:20 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Sun Jun 13 19:17:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.27 2021/06/13 19:13:20 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.28 2021/06/13 19:17:53 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -38,8 +38,8 @@ #include "slave.h" #include "curses_commands.h" -int -set_int(char *arg, int *x) +static int +set_int(const char *arg, int *x) { if (sscanf(arg, "%d", x) == 0) { report_count(1); @@ -50,8 +50,8 @@ set_int(char *arg, int *x) return 0; } -int -set_uint(char *arg, unsigned int *x) +static int +set_uint(const char *arg, unsigned int *x) { if (sscanf(arg, "%u", x) == 0) { report_count(1); @@ -62,8 +62,8 @@ set_uint(char *arg, unsigned int *x) return 0; } -int -set_short(char *arg, short *x) +static int +set_short(const char *arg, short *x) { if (sscanf(arg, "%hd", x) == 0) { report_count(1); @@ -74,8 +74,8 @@ set_short(char *arg, short *x) return 0; } -int -set_win(char *arg, WINDOW **x) +static int +set_win(const char *arg, WINDOW **x) { if (sscanf(arg, "%p", x) == 0) { report_count(1); @@ -86,8 +86,8 @@ set_win(char *arg, WINDOW **x) return 0; } -int -set_scrn(char *arg, SCREEN **x) +static int +set_scrn(const char *arg, SCREEN **x) { if (sscanf(arg, "%p", x) == 0) { report_count(1); Index: src/tests/lib/libcurses/slave/curses_commands.h diff -u src/tests/lib/libcurses/slave/curses_commands.h:1.7 src/tests/lib/libcurses/slave/curses_commands.h:1.8 --- src/tests/lib/libcurses/slave/curses_commands.h:1.7 Sat Feb 13 08:14:46 2021 +++ src/tests/lib/libcurses/slave/curses_commands.h Sun Jun 13 19:17:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.h,v 1.7 2021/02/13 08:14:46 rillig Exp $ */ +/* $NetBSD: curses_commands.h,v 1.8 2021/06/13 19:17:53 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -36,12 +36,6 @@ struct command_def { void (*func)(int, char **); }; -int set_int(char *, int *); -int set_uint(char *, unsigned int *); -int set_short(char *, short *); -int set_win(char *, WINDOW **); -int set_scrn(char *, SCREEN **); - /* * prototypes for test commands */
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 19:13:20 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: KNF for while loop To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.26 src/tests/lib/libcurses/slave/curses_commands.c:1.27 --- src/tests/lib/libcurses/slave/curses_commands.c:1.26 Sun Jun 13 18:11:44 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Sun Jun 13 19:13:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.26 2021/06/13 18:11:44 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.27 2021/06/13 19:13:20 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -165,7 +165,9 @@ cmd_DRAIN(int nargs, char **args) ARGC(1); ARG_WINDOW(win); - while (wgetch(win) != ERR); + while (wgetch(win) != ERR) + continue; + report_count(1); report_return(OK); }
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 18:11:44 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c lint.lua Log Message: tests/libcurses: remove redundant argument numbers Since all arguments are processed in increasing order, there is no need to add the redundant argument numbers. Most of the curses functions have less than 5 arguments, which makes it easy enough to count the ARG macros. Changes to curses_commands.c: * replace ^(\tARG_\w+\()\d(?:, |) with $1 * replace (define ARG_\w+\()i,\s with $1 * replace args\[i\] with *args++ * replace \(i\) with () * replace \(void\)0 with args++ The wrong argument count in cmd_mvwget_wch is still detected by lint.lua, as it was before. There is no test yet that covers this function. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libcurses/slave/curses_commands.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/slave/lint.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.25 src/tests/lib/libcurses/slave/curses_commands.c:1.26 --- src/tests/lib/libcurses/slave/curses_commands.c:1.25 Sun Apr 4 09:49:13 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Sun Jun 13 18:11:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.25 2021/04/04 09:49:13 rin Exp $ */ +/* $NetBSD: curses_commands.c,v 1.26 2021/06/13 18:11:44 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -102,68 +102,68 @@ set_scrn(char *arg, SCREEN **x) if (check_arg_count(nargs, n) == 1)\ return -#define ARG_SHORT(i, arg) \ +#define ARG_SHORT(arg) \ short arg; \ - if (set_short(args[i], ) != 0)\ + if (set_short(*args++, ) != 0)\ return -#define ARG_INT(i, arg) \ +#define ARG_INT(arg) \ int arg; \ - if (set_int(args[i], ) != 0)\ + if (set_int(*args++, ) != 0)\ return -#define ARG_UINT(i, arg) \ +#define ARG_UINT(arg) \ unsigned int arg; \ - if (set_uint(args[i], ) != 0)\ + if (set_uint(*args++, ) != 0)\ return -#define ARG_CHTYPE(i, arg) \ - chtype arg = ((const chtype *)args[i])[0] +#define ARG_CHTYPE(arg) \ + chtype arg = ((const chtype *)*args++)[0] -#define ARG_WCHAR(i, arg) \ - wchar_t arg = ((const wchar_t *)args[i])[0] +#define ARG_WCHAR(arg) \ + wchar_t arg = ((const wchar_t *)*args++)[0] -#define ARG_STRING(i, arg) \ - const char *arg = args[i] +#define ARG_STRING(arg) \ + const char *arg = *args++ /* Only used for legacy interfaces that are missing the 'const'. */ -#define ARG_MODIFIABLE_STRING(i, arg) \ - char *arg = args[i] +#define ARG_MODIFIABLE_STRING(arg) \ + char *arg = *args++ -#define ARG_CHTYPE_STRING(i, arg) \ - const chtype *arg = (const chtype *)args[i] +#define ARG_CHTYPE_STRING(arg) \ + const chtype *arg = (const chtype *)*args++ -#define ARG_CCHAR_STRING(i, arg) \ - const cchar_t *arg = (const cchar_t *)args[i] +#define ARG_CCHAR_STRING(arg) \ + const cchar_t *arg = (const cchar_t *)*args++ -#define ARG_WCHAR_STRING(i, arg) \ - wchar_t *arg = (wchar_t *)args[i] +#define ARG_WCHAR_STRING(arg) \ + wchar_t *arg = (wchar_t *)*args++ -#define ARG_WINDOW(i, arg) \ +#define ARG_WINDOW(arg) \ WINDOW *arg; \ - if (set_win(args[i], ) != 0)\ + if (set_win(*args++, ) != 0)\ return -#define ARG_SCREEN(i, arg) \ +#define ARG_SCREEN(arg) \ SCREEN *arg; \ - if (set_scrn(args[i], ) != 0)\ + if (set_scrn(*args++, ) != 0)\ return /* * Required by the API, intended for future extensions, but this * implementation does not support the extension. */ -#define ARG_NULL(i) \ - (void)0 +#define ARG_NULL() \ + args++ -#define ARG_IGNORE(i) \ - (void)0 +#define ARG_IGNORE() \ + args++ void cmd_DRAIN(int nargs, char **args) { ARGC(1); - ARG_WINDOW(0, win); + ARG_WINDOW(win); while (wgetch(win) != ERR); report_count(1); @@ -174,8 +174,8 @@ void cmd_addbytes(int nargs, char **args) { ARGC(2); - ARG_STRING(0, str); - ARG_INT(1, count); + ARG_STRING(str); + ARG_INT(count); report_count(1); report_return(addbytes(str, count)); @@ -186,7 +186,7 @@ void cmd_addch(int nargs, char **args) { ARGC(1); - ARG_CHTYPE(0, ch); + ARG_CHTYPE(ch); report_count(1); report_return(addch(ch)); @@ -197,8 +197,8 @@ void cmd_addchnstr(int nargs, char **args) { ARGC(2); - ARG_CHTYPE_STRING(0, chstr); - ARG_INT(1, count); + ARG_CHTYPE_STRING(chstr); + ARG_INT(count); report_count(1); report_return(addchnstr(chstr, count)); @@ -209,7 +209,7 @@ void cmd_addchstr(int nargs, char **args) { ARGC(1); - ARG_CHTYPE_STRING(0, chstr); + ARG_CHTYPE_STRING(chstr); report_count(1); report_return(addchstr(chstr)); @@ -220,8 +220,8 @@ void cmd_addnstr(int nargs, char **args) { ARGC(2); - ARG_STRING(0, str); - ARG_INT(1, count); + ARG_STRING(str); +
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Jun 13 12:46:02 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: commands.c slave.c Log Message: tests/libcurses: add parentheses around argument to sizeof To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/commands.c cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/slave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/commands.c diff -u src/tests/lib/libcurses/slave/commands.c:1.14 src/tests/lib/libcurses/slave/commands.c:1.15 --- src/tests/lib/libcurses/slave/commands.c:1.14 Mon Feb 15 07:06:27 2021 +++ src/tests/lib/libcurses/slave/commands.c Sun Jun 13 12:46:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.14 2021/02/15 07:06:27 rillig Exp $ */ +/* $NetBSD: commands.c,v 1.15 2021/06/13 12:46:01 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -98,7 +98,7 @@ write_to_director(const void *mem, size_ static void write_to_director_int(int i) { - write_to_director(, sizeof i); + write_to_director(, sizeof(i)); } static void @@ -218,7 +218,7 @@ report_nstr(chtype *string) for (p = string; (*p & __CHARTEXT) != 0; p++) continue; - size = (size_t)(p + 1 - string) * sizeof *p; + size = (size_t)(p + 1 - string) * sizeof(*p); write_to_director_type(data_byte); write_to_director_int(size); @@ -233,8 +233,8 @@ report_cchar(cchar_t c) { write_to_director_type(data_cchar); - write_to_director_int(sizeof c); - write_to_director(, sizeof c); + write_to_director_int(sizeof(c)); + write_to_director(, sizeof(c)); } /* @@ -262,7 +262,7 @@ report_wstr(wchar_t *wstr) for (p = wstr; *p != L'\0'; p++) continue; - size = (size_t)(p + 1 - wstr) * sizeof *p; + size = (size_t)(p + 1 - wstr) * sizeof(*p); write_to_director_type(data_wchar); Index: src/tests/lib/libcurses/slave/slave.c diff -u src/tests/lib/libcurses/slave/slave.c:1.16 src/tests/lib/libcurses/slave/slave.c:1.17 --- src/tests/lib/libcurses/slave/slave.c:1.16 Sat Feb 13 10:03:49 2021 +++ src/tests/lib/libcurses/slave/slave.c Sun Jun 13 12:46:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slave.c,v 1.16 2021/02/13 10:03:49 rillig Exp $ */ +/* $NetBSD: slave.c,v 1.17 2021/06/13 12:46:01 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -82,12 +82,12 @@ read_command_argument(char ***pargs, int int type, len; char **args = *pargs; - read_from_director(, sizeof type); - read_from_director(, sizeof len); + read_from_director(, sizeof(type)); + read_from_director(, sizeof(len)); if (len < 0) return false; - args = realloc(args, (argslen + 1) * sizeof args[0]); + args = realloc(args, (argslen + 1) * sizeof(args[0])); if (args == NULL) err(1, "slave realloc of args array failed"); *pargs = args; @@ -134,11 +134,11 @@ process_commands(void) if ((cmdbuf = malloc(maxlen)) == NULL) err(1, "slave cmdbuf malloc failed"); - while (try_read_from_director(, sizeof type)) { + while (try_read_from_director(, sizeof(type))) { if (type != data_string) errx(1, "Unexpected type for command, got %d", type); - read_from_director(, sizeof len); + read_from_director(, sizeof(len)); if ((len + 1) > maxlen) { maxlen = len + 1;
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sun Jun 13 11:06:20 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: tests/libcurses: sprinkle 'const', normalize sizeof No functional change. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.52 src/tests/lib/libcurses/director/testlang_parse.y:1.53 --- src/tests/lib/libcurses/director/testlang_parse.y:1.52 Tue Apr 6 01:29:37 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Sun Jun 13 11:06:20 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.52 2021/04/06 01:29:37 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.53 2021/06/13 11:06:20 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -82,7 +82,7 @@ static bool no_input; /* don't need more static wchar_t *vals = NULL; /* wchars to attach to a cchar type */ static unsigned nvals; /* number of wchars */ -const char *enum_names[] = { /* for data_enum_t */ +const char *const enum_names[] = { /* for data_enum_t */ "unused", "numeric", "static", "string", "byte", "cchar", "wchar", "ERR", "OK", "NULL", "not NULL", "variable", "reference", "return count", "slave error" @@ -116,7 +116,7 @@ typedef struct { static size_t nvars; /* Number of declared variables */ static var_t *vars; /* Variables defined during the test. */ -static int check_function_table(char *, const char *[], int); +static int check_function_table(char *, const char *const[], int); static int find_var_index(const char *); static void assign_arg(data_enum_t, void *); static int assign_var(const char *); @@ -149,7 +149,7 @@ static void set_wchar(char *); static wchar_t *add_to_vals(data_enum_t, void *); #define variants(fn) "" fn, "mv" fn, "w" fn, "mvw" fn -static const char *input_functions[] = { +static const char *const input_functions[] = { variants("getch"), variants("getnstr"), variants("getstr"), @@ -161,7 +161,7 @@ static const char *input_functions[] = { #undef variants static const unsigned ninput_functions = - sizeof(input_functions) / sizeof(char *); + sizeof(input_functions) / sizeof(input_functions[0]); extern saved_data_t saved_output; @@ -875,7 +875,7 @@ find_var_index(const char *var_name) * there is a match. */ static int -check_function_table(char *function, const char *table[], int nfunctions) +check_function_table(char *function, const char *const table[], int nfunctions) { int i;
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: mcf Date: Thu Jun 10 07:21:07 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c Log Message: Unset ESCDELAY in libcurses test director to ensure consistent results Non-default values of ESCDELAY may result in unexpected test failures. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/tests/lib/libcurses/director/director.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.28 src/tests/lib/libcurses/director/director.c:1.29 --- src/tests/lib/libcurses/director/director.c:1.28 Sat Feb 13 09:18:12 2021 +++ src/tests/lib/libcurses/director/director.c Thu Jun 10 07:21:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.28 2021/02/13 09:18:12 rillig Exp $ */ +/* $NetBSD: director.c,v 1.29 2021/06/10 07:21:07 mcf Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -195,6 +195,9 @@ main(int argc, char *argv[]) if (setenv("TERM", term, 1) != 0) err(2, "Failed to set TERM variable"); + if (unsetenv("ESCDELAY") != 0) + err(2, "Failed to unset ESCDELAY variable"); + if (stat(termpath, ) == -1) err(1, "Cannot stat %s", termpath);
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Jun 9 21:09:20 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: remove the kill in the trace code. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.13 src/tests/lib/libc/regex/t_exhaust.c:1.14 --- src/tests/lib/libc/regex/t_exhaust.c:1.13 Wed Jun 9 17:08:56 2021 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Jun 9 17:09:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.14 2021/06/09 21:09:20 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.14 2021/06/09 21:09:20 christos Exp $"); #include #include @@ -74,8 +74,6 @@ malloc(size_t l) return p; q = 1; printf("%p m %zu\n", p, l); - if (p == (void *)0x7f7ff7e21ac0) - kill(0, SIGSTOP); q = 0; return p; }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Jun 9 21:08:56 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: remove not required include files To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.12 src/tests/lib/libc/regex/t_exhaust.c:1.13 --- src/tests/lib/libc/regex/t_exhaust.c:1.12 Wed Jun 9 16:48:37 2021 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Jun 9 17:08:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $"); #include #include @@ -52,17 +52,17 @@ __RCSID("$NetBSD: t_exhaust.c,v 1.12 202 #endif #include -#include #include #include #include -#include #ifndef REGEX_MAXSIZE #define REGEX_MAXSIZE #endif #ifdef TRACE + +#include void * malloc(size_t l) {
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Jun 9 20:48:37 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: 1. Preallocate the patterns so that out of memory conditions don't happen during their allocation, which the test cannot handle properly. 2. Enable building the test without atf so that we can easily debug with atf memory allocations interfering 3. Add memory tracing (disabled) To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.11 src/tests/lib/libc/regex/t_exhaust.c:1.12 --- src/tests/lib/libc/regex/t_exhaust.c:1.11 Mon Jun 7 07:45:35 2021 +++ src/tests/lib/libc/regex/t_exhaust.c Wed Jun 9 16:48:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,20 +37,59 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $"); #include -#include #include + +#ifdef TEST +# include +# define ATF_REQUIRE(a) assert(a) +# define ATF_REQUIRE_MSG(a, fmt, ...) \ +if (!(a)) err(EXIT_FAILURE, fmt, __VA_ARGS__) +#else +# include +#endif + #include +#include #include #include #include +#include #ifndef REGEX_MAXSIZE #define REGEX_MAXSIZE #endif +#ifdef TRACE +void * +malloc(size_t l) +{ + static void *(*m)(size_t); + static int q; + if (m == NULL) m = dlsym(RTLD_NEXT, "malloc"); + void *p = (*m)(l); + if (q) + return p; + q = 1; + printf("%p m %zu\n", p, l); + if (p == (void *)0x7f7ff7e21ac0) + kill(0, SIGSTOP); + q = 0; + return p; +} + +void +free(void *p) +{ + static void (*f)(void *); + if (f == NULL) f = dlsym(RTLD_NEXT, "malloc"); + printf("%p f\n", p); + (*f)(p); +} +#endif + static char * mkstr(const char *str, size_t len) { @@ -168,43 +207,56 @@ static const struct { { p6, REG_BASIC }, }; -ATF_TC(regcomp_too_big); - -ATF_TC_HEAD(regcomp_too_big, tc) -{ - - atf_tc_set_md_var(tc, "descr", "Check that large patterns don't" - " crash, but return a proper error code"); - // libtre needs it. - atf_tc_set_md_var(tc, "timeout", "600"); - atf_tc_set_md_var(tc, "require.memory", "256M"); -} - -ATF_TC_BODY(regcomp_too_big, tc) +static void +run(void) { regex_t re; int e; struct rlimit limit; + char *patterns[__arraycount(tests)]; + + for (size_t i = 0; i < __arraycount(patterns); i++) { + patterns[i] = (*tests[i].pattern)(REGEX_MAXSIZE); + } limit.rlim_cur = limit.rlim_max = 256 * 1024 * 1024; ATF_REQUIRE(setrlimit(RLIMIT_VMEM, ) != -1); for (size_t i = 0; i < __arraycount(tests); i++) { - char *d = (*tests[i].pattern)(REGEX_MAXSIZE); - e = regcomp(, d, tests[i].type); + e = regcomp(, patterns[i], tests[i].type); if (e) { char ebuf[1024]; (void)regerror(e, , ebuf, sizeof(ebuf)); ATF_REQUIRE_MSG(e == REG_ESPACE, - "regcomp returned %d (%s) for pattern %zu [%s]", e, ebuf, - i, d); - free(d); + "regcomp returned %d (%s) for pattern %zu [%s]", e, + ebuf, i, patterns[i]); continue; } - free(d); (void)regexec(, "aaa", 0, NULL, 0); regfree(); } + for (size_t i = 0; i < __arraycount(patterns); i++) { + free(patterns[i]); + } +} + +#ifndef TEST + +ATF_TC(regcomp_too_big); + +ATF_TC_HEAD(regcomp_too_big, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Check that large patterns don't" + " crash, but return a proper error code"); + // libtre needs it. + atf_tc_set_md_var(tc, "timeout", "600"); + atf_tc_set_md_var(tc, "require.memory", "256M"); +} + +ATF_TC_BODY(regcomp_too_big, tc) +{ + run(); } ATF_TP_ADD_TCS(tp) @@ -213,3 +265,11 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, regcomp_too_big); return atf_no_error(); } +#else +int +main(void) +{ + run(); + return 0; +} +#endif
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Mon Jun 7 11:45:35 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_exhaust.c Log Message: Add more information for the malloc failure. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/regex/t_exhaust.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_exhaust.c diff -u src/tests/lib/libc/regex/t_exhaust.c:1.10 src/tests/lib/libc/regex/t_exhaust.c:1.11 --- src/tests/lib/libc/regex/t_exhaust.c:1.10 Tue Jul 9 09:59:25 2019 +++ src/tests/lib/libc/regex/t_exhaust.c Mon Jun 7 07:45:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_exhaust.c,v 1.10 2019/07/09 13:59:25 gson Exp $ */ +/* $NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_exhaust.c,v 1.10 2019/07/09 13:59:25 gson Exp $"); +__RCSID("$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $"); #include #include @@ -69,7 +69,7 @@ concat(const char *d, const char *s) size_t slen = strlen(s); char *p = malloc(dlen + slen + 1); - ATF_REQUIRE(p != NULL); + ATF_REQUIRE_MSG(p != NULL, "slen=%zu, dlen=%zu", slen, dlen); strcpy(p, d); strcpy(p + dlen, s); return p;
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: blymn Date: Sun Jun 6 04:57:58 UTC 2021 Modified Files: src/tests/lib/libcurses/check_files: Makefile slk1.chk slk3.chk slk5.chk slk6.chk slk_init.chk src/tests/lib/libcurses/tests: addstr slk Added Files: src/tests/lib/libcurses/check_files: addstr2.chk addstr3.chk Log Message: New tests and updates for corrected behaviour due to fix for PR56224 * Added extra testing to the addstr test to demonstrate bug described in PR#56224 and validate case when scrolling enabled still works. * Fixed slk test, the slk_init output changed due to corrected wrapping, slk_restore no longer returns ERR probably due to addwchar no longer returning ERR when an implicit scroll was attempted when scrolling disabled. Commented out the slk_wset test, this is now returning ERR instead of misbehaving, needs investigation. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/check_files/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libcurses/check_files/addstr2.chk \ src/tests/lib/libcurses/check_files/addstr3.chk cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/check_files/slk1.chk \ src/tests/lib/libcurses/check_files/slk3.chk \ src/tests/lib/libcurses/check_files/slk5.chk \ src/tests/lib/libcurses/check_files/slk6.chk \ src/tests/lib/libcurses/check_files/slk_init.chk cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/tests/addstr cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/tests/slk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/check_files/Makefile diff -u src/tests/lib/libcurses/check_files/Makefile:1.6 src/tests/lib/libcurses/check_files/Makefile:1.7 --- src/tests/lib/libcurses/check_files/Makefile:1.6 Sat Jun 5 06:11:09 2021 +++ src/tests/lib/libcurses/check_files/Makefile Sun Jun 6 04:57:58 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2021/06/05 06:11:09 blymn Exp $ +# $NetBSD: Makefile,v 1.7 2021/06/06 04:57:58 blymn Exp $ NOMAN= # defined @@ -21,6 +21,8 @@ FILES+= addnstr.chk FILES+= addnwstr1.chk FILES+= addnwstr2.chk FILES+= addstr.chk +FILES+= addstr2.chk +FILES+= addstr3.chk FILES+= addwstr1.chk FILES+= addwstr2.chk FILES+= addwstr3.chk Index: src/tests/lib/libcurses/check_files/slk1.chk diff -u src/tests/lib/libcurses/check_files/slk1.chk:1.1 src/tests/lib/libcurses/check_files/slk1.chk:1.2 --- src/tests/lib/libcurses/check_files/slk1.chk:1.1 Sat Oct 24 04:46:16 2020 +++ src/tests/lib/libcurses/check_files/slk1.chk Sun Jun 6 04:57:58 2021 @@ -1 +1 @@ -cup24;1Xrevone sgr0smsosmulrev one rmsormulsgr0smsorev onermsosgr0cup24;42Xsmulrev five cup24;73Xeight!!rmam!smamcup24;50Xrmulsgr0 \ No newline at end of file +cup24;1Xrevone sgr0smsosmulrev one rmsormulsgr0smsorev onermsosgr0cup24;42Xsmulrev five cup24;73Xeight!!cup24;50Xrmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk3.chk diff -u src/tests/lib/libcurses/check_files/slk3.chk:1.1 src/tests/lib/libcurses/check_files/slk3.chk:1.2 --- src/tests/lib/libcurses/check_files/slk3.chk:1.1 Sat Oct 24 04:46:16 2020 +++ src/tests/lib/libcurses/check_files/slk3.chk Sun Jun 6 04:57:58 2021 @@ -1 +1 @@ -smulrev one five eight!!rmam!smamcup24;1Xrmulsgr0 \ No newline at end of file +smulrev one five eight!!rmulsgr0 \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk5.chk diff -u src/tests/lib/libcurses/check_files/slk5.chk:1.1 src/tests/lib/libcurses/check_files/slk5.chk:1.2 --- src/tests/lib/libcurses/check_files/slk5.chk:1.1 Sat Oct 24 04:46:16 2020 +++ src/tests/lib/libcurses/check_files/slk5.chk Sun Jun 6 04:57:58 2021 @@ -1 +1 @@ -cup24;1Xsmulrev onesgr0 smulrev two sgr0 smulrevsgr0 smulrevsgr0 smulrev five sgr0 smulrevsgr0 smulrevsgr0 smulreveight!!rmam!smamcup24;18Xrmulsgr0 \ No newline at end of file +cup24;1Xsmulrev onesgr0 smulrev two sgr0 smulrevsgr0 smulrevsgr0 smulrev five sgr0 smulrevsgr0 smulrevsgr0 smulreveight!!rmulsgr0elcup24;18X \ No newline at end of file Index: src/tests/lib/libcurses/check_files/slk6.chk diff -u src/tests/lib/libcurses/check_files/slk6.chk:1.1 src/tests/lib/libcurses/check_files/slk6.chk:1.2 --- src/tests/lib/libcurses/check_files/slk6.chk:1.1 Sat Oct 24 04:46:16 2020 +++ src/tests/lib/libcurses/check_files/slk6.chk Sun Jun 6 04:57:58 2021 @@ -1 +1 @@ -opsetaf7Xsetab0Xsmulrev onesgr0setaf7Xsetab0X smulrev two sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X setaf1Xsetab2Xsmulrevfoursgr0setaf7Xsetab0X smulrev five sgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X smulrevsgr0setaf7Xsetab0X
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: blymn Date: Sat Jun 5 06:23:48 UTC 2021 Modified Files: src/tests/lib/libcurses: chk_gen Log Message: Convert % into %% in input string so printf won't barf To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/chk_gen Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/chk_gen diff -u src/tests/lib/libcurses/chk_gen:1.1 src/tests/lib/libcurses/chk_gen:1.2 --- src/tests/lib/libcurses/chk_gen:1.1 Sun Jun 9 07:54:55 2019 +++ src/tests/lib/libcurses/chk_gen Sat Jun 5 06:23:48 2021 @@ -8,7 +8,7 @@ OUT="" while read -r line do - next=`echo $line | sed -e 's/\n//' -e 's/\\015/\\r/g' -e 's/\\012/\\n/g'` + next=`echo $line | sed -e 's/%/%%/g' -e 's/\n//' -e 's/\\015/\\r/g' -e 's/\\012/\\n/g'` OUT="${OUT}${next}" done OUT=`echo "${OUT}" | sed 's/\n//'`
CVS commit: src/tests/lib/libcurses/tests
Module Name:src Committed By: blymn Date: Sat Jun 5 06:13:37 UTC 2021 Modified Files: src/tests/lib/libcurses/tests: clear Log Message: Decouple the clear test from the addstr test, they should not be linked together because they are not really related. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/tests/clear Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/tests/clear diff -u src/tests/lib/libcurses/tests/clear:1.1 src/tests/lib/libcurses/tests/clear:1.2 --- src/tests/lib/libcurses/tests/clear:1.1 Sun Apr 10 09:55:10 2011 +++ src/tests/lib/libcurses/tests/clear Sat Jun 5 06:13:36 2021 @@ -1,4 +1,10 @@ -include addstr +include start +call OK addstr "abcde\n" +call OK addstr "\n" +call OK addstr "\t8\n" +call OK addstr "0123456\t8\n" +call OK refresh +compare clear0.chk call OK clear call OK refresh compare clear1.chk
CVS commit: src/tests/lib/libcurses/check_files
Module Name:src Committed By: blymn Date: Sat Jun 5 06:11:09 UTC 2021 Modified Files: src/tests/lib/libcurses/check_files: Makefile Added Files: src/tests/lib/libcurses/check_files: clear0.chk Log Message: Add new check file for the clear test. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/check_files/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libcurses/check_files/clear0.chk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/check_files/Makefile diff -u src/tests/lib/libcurses/check_files/Makefile:1.5 src/tests/lib/libcurses/check_files/Makefile:1.6 --- src/tests/lib/libcurses/check_files/Makefile:1.5 Sun Feb 7 01:53:54 2021 +++ src/tests/lib/libcurses/check_files/Makefile Sat Jun 5 06:11:09 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2021/02/07 01:53:54 rillig Exp $ +# $NetBSD: Makefile,v 1.6 2021/06/05 06:11:09 blymn Exp $ NOMAN= # defined @@ -41,6 +41,7 @@ FILES+= box_standout.chk FILES+= chgat1.chk FILES+= chgat2.chk FILES+= chgat3.chk +FILES+= clear0.chk FILES+= clear1.chk FILES+= clear10.chk FILES+= clear2.chk Added files: Index: src/tests/lib/libcurses/check_files/clear0.chk diff -u /dev/null src/tests/lib/libcurses/check_files/clear0.chk:1.1 --- /dev/null Sat Jun 5 06:11:09 2021 +++ src/tests/lib/libcurses/check_files/clear0.chk Sat Jun 5 06:11:09 2021 @@ -0,0 +1,2 @@ +abcdecup3;9X8 +0123456 8
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: blymn Date: Fri Jun 4 23:07:39 UTC 2021 Modified Files: src/tests/lib/libcurses: debug_test Log Message: Fix debug_test so it actually works and does not do damage * disable blind clearing of /tmp. The comment says this is needed for getwin/putwin those tests need to be looked at to correct this. * remove invalid -I option from director arguments for now. * fix paths to executables so debug_test will work with installed versions by default the previous version was using the src tree locations but basedir was wrong for that. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libcurses/debug_test Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/debug_test diff -u src/tests/lib/libcurses/debug_test:1.4 src/tests/lib/libcurses/debug_test:1.5 --- src/tests/lib/libcurses/debug_test:1.4 Sat Oct 24 04:46:16 2020 +++ src/tests/lib/libcurses/debug_test Fri Jun 4 23:07:39 2021 @@ -8,7 +8,7 @@ INCLUDE_PATH="${BASEDIR}/tests/" export INCLUDE_PATH # CURSES_TRACE_FILE="/tmp/ctrace" -SLAVE="${BASEDIR}/slave/slave" +SLAVE="${BASEDIR}/slave" usage() { echo "Set up the environment to run the test frame. Option flags:" @@ -31,10 +31,11 @@ usage() { # This is needed for getwin/putwin test case and /tmp can be used for any file # related tests. -rm -rf /tmp/* +#rm -rf /tmp/* # -ARGS="-T ${BASEDIR} -I ${INCLUDE_PATH} -C ${CHECK_PATH}" +#ARGS="-T ${BASEDIR} -I ${INCLUDE_PATH} -C ${CHECK_PATH}" +ARGS="-T ${BASEDIR} -C ${CHECK_PATH}" # while getopts cf:L:s:vg opt do @@ -90,4 +91,4 @@ then exit 1 fi # -exec ${BASEDIR}/director/director ${ARGS} -s ${SLAVE} "${INCLUDE_PATH}/$1" +exec ${BASEDIR}/director ${ARGS} -s ${SLAVE} "${INCLUDE_PATH}/$1"
CVS commit: src/tests/lib/csu
Module Name:src Committed By: christos Date: Thu Jun 3 20:17:37 UTC 2021 Modified Files: src/tests/lib/csu: h_ifunc_static.c Log Message: PR/56230: Jan-Benedict Glaw: arm oabi does not and will not have ifunc support. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/csu/h_ifunc_static.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/csu/h_ifunc_static.c diff -u src/tests/lib/csu/h_ifunc_static.c:1.2 src/tests/lib/csu/h_ifunc_static.c:1.3 --- src/tests/lib/csu/h_ifunc_static.c:1.2 Sun Mar 11 17:20:22 2018 +++ src/tests/lib/csu/h_ifunc_static.c Thu Jun 3 16:17:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: h_ifunc_static.c,v 1.2 2018/03/11 21:20:22 joerg Exp $ */ +/* $NetBSD: h_ifunc_static.c,v 1.3 2021/06/03 20:17:37 christos Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if defined(__arm__) || defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__sparc__) +#if (defined(__arm__) && defined(__ARM_EABI__)) || defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__sparc__) #include #include
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: gson Date: Mon May 24 10:44:06 UTC 2021 Modified Files: src/tests/lib/libc/sys: t_ptrace_wait.h Log Message: On mips, avoid deliberately executing an illegal instruction for now because it causes GXemul to exit rather than generating a trap. A bug report has been sent to the GXemul author. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/tests/lib/libc/sys/t_ptrace_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_ptrace_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.32 src/tests/lib/libc/sys/t_ptrace_wait.h:1.33 --- src/tests/lib/libc/sys/t_ptrace_wait.h:1.32 Mon Jun 22 12:21:02 2020 +++ src/tests/lib/libc/sys/t_ptrace_wait.h Mon May 24 10:44:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_wait.h,v 1.32 2020/06/22 12:21:02 rin Exp $ */ +/* $NetBSD: t_ptrace_wait.h,v 1.33 2021/05/24 10:44:06 gson Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc. @@ -648,7 +648,9 @@ trigger_ill(void) /* Illegal instruction causes CPU trap, translated to SIGILL */ #ifdef PTRACE_ILLEGAL_ASM +#ifndef __mips__ /* To avoid GXemul crash */ PTRACE_ILLEGAL_ASM; +#endif #else /* port me */ #endif
CVS commit: src/tests/lib/libc/gen/posix_spawn
Module Name:src Committed By: martin Date: Sun May 2 11:18:11 UTC 2021 Modified Files: src/tests/lib/libc/gen/posix_spawn: h_spawn.c t_spawnattr.c Log Message: Add test for POSIX_SPAWN_RESETIDS flag To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/posix_spawn/h_spawn.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/gen/posix_spawn/h_spawn.c diff -u src/tests/lib/libc/gen/posix_spawn/h_spawn.c:1.1 src/tests/lib/libc/gen/posix_spawn/h_spawn.c:1.2 --- src/tests/lib/libc/gen/posix_spawn/h_spawn.c:1.1 Mon Feb 13 21:03:08 2012 +++ src/tests/lib/libc/gen/posix_spawn/h_spawn.c Sun May 2 11:18:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: h_spawn.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */ +/* $NetBSD: h_spawn.c,v 1.2 2021/05/02 11:18:11 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -32,6 +32,8 @@ #include #include +#include +#include int main(int argc, char **argv) @@ -39,11 +41,25 @@ main(int argc, char **argv) unsigned long ret; char *endp; - if (argc < 2) { + if (argc == 2 && strcmp(argv[1], "--resetids") == 0) { + if (getuid() != geteuid() || getgid() != getegid()) { + fprintf(stderr, "uid/gid do not match effective ids, " + "uid: %d euid: %d gid: %d egid: %d\n", + getuid(), geteuid(), getgid(), getegid()); + exit(255); + } + return 0; + } else if (argc != 2) { fprintf(stderr, "usage:\n\t%s (retcode)\n", getprogname()); exit(255); } ret = strtoul(argv[1], , 10); + if (*endp != 0) { + fprintf(stderr, + "invalid arg: %s\n" + "usage:\n\t%s (retcode)\n", endp, getprogname()); + exit(255); + } fprintf(stderr, "%s exiting with status %lu\n", getprogname(), ret); return ret; Index: src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c diff -u src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.3 src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.4 --- src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.3 Thu Dec 21 03:31:43 2017 +++ src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c Sun May 2 11:18:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_spawnattr.c,v 1.3 2017/12/21 03:31:43 christos Exp $ */ +/* $NetBSD: t_spawnattr.c,v 1.4 2021/05/02 11:18:11 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -165,9 +165,43 @@ ATF_TC_BODY(t_spawnattr, tc) posix_spawnattr_destroy(); } +ATF_TC(t_spawn_resetids); + +ATF_TC_HEAD(t_spawn_resetids, tc) +{ + atf_tc_set_md_var(tc, "descr", + "posix_spawn a child and with POSIX_SPAWN_RESETIDS flag"); +} + +ATF_TC_BODY(t_spawn_resetids, tc) +{ + char buf[FILENAME_MAX]; + char * const args[] = { + __UNCONST("h_spawn"), __UNCONST("--resetids"), NULL + }; + posix_spawnattr_t attr; + int err, status; + pid_t pid; + + posix_spawnattr_init(); + posix_spawnattr_setflags(, POSIX_SPAWN_RESETIDS); + + snprintf(buf, sizeof buf, "%s/h_spawn", + atf_tc_get_config_var(tc, "srcdir")); + + err = posix_spawn(, buf, NULL, , args, NULL); + ATF_REQUIRE(err == 0); + ATF_REQUIRE(pid > 0); + waitpid(pid, , 0); + ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 0); + + posix_spawnattr_destroy(); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_spawnattr); + ATF_TP_ADD_TC(tp, t_spawn_resetids); return atf_no_error(); }
CVS commit: src/tests/lib/libi386
Module Name:src Committed By: christos Date: Fri Apr 30 13:53:30 UTC 2021 Modified Files: src/tests/lib/libi386: t_user_ldt.c Log Message: remove hacks. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libi386/t_user_ldt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libi386/t_user_ldt.c diff -u src/tests/lib/libi386/t_user_ldt.c:1.5 src/tests/lib/libi386/t_user_ldt.c:1.6 --- src/tests/lib/libi386/t_user_ldt.c:1.5 Sun Jul 19 10:31:31 2020 +++ src/tests/lib/libi386/t_user_ldt.c Fri Apr 30 09:53:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_user_ldt.c,v 1.5 2020/07/19 14:31:31 maxv Exp $ */ +/* $NetBSD: t_user_ldt.c,v 1.6 2021/04/30 13:53:30 christos Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -41,10 +41,7 @@ #include #include #include - -#define _LOCORE /* XXX a bit of a hack, but whatever */ #include -#undef _LOCORE #include
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Tue Apr 6 01:29:37 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: tests/libcurses: fix names of over-the-wire data types The test 'mvscanw' reported that it would send '%s' as 'numeric', which was rather suspicious. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.51 src/tests/lib/libcurses/director/testlang_parse.y:1.52 --- src/tests/lib/libcurses/director/testlang_parse.y:1.51 Tue Apr 6 00:47:00 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Tue Apr 6 01:29:37 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.51 2021/04/06 00:47:00 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.52 2021/04/06 01:29:37 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -82,9 +82,9 @@ static bool no_input; /* don't need more static wchar_t *vals = NULL; /* wchars to attach to a cchar type */ static unsigned nvals; /* number of wchars */ -const char *enum_names[] = { - "unused", "static", "numeric", "string", "byte", "cchar", "wchar", "ERR", - "OK", "NULL", "not NULL", "variable", "reference", "returns count", +const char *enum_names[] = { /* for data_enum_t */ + "unused", "numeric", "static", "string", "byte", "cchar", "wchar", "ERR", + "OK", "NULL", "not NULL", "variable", "reference", "return count", "slave error" };
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Tue Apr 6 00:47:00 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: tests/libcurses: clean up table of input functions The previous "table" was an insult to any reader. It was unsorted, listed the functions shuffled, and was not even formatted consistently. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.50 src/tests/lib/libcurses/director/testlang_parse.y:1.51 --- src/tests/lib/libcurses/director/testlang_parse.y:1.50 Tue Apr 6 00:35:58 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Tue Apr 6 00:47:00 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.50 2021/04/06 00:35:58 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.51 2021/04/06 00:47:00 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -148,13 +148,17 @@ static void set_cchar(char *, void *); static void set_wchar(char *); static wchar_t *add_to_vals(data_enum_t, void *); +#define variants(fn) "" fn, "mv" fn, "w" fn, "mvw" fn static const char *input_functions[] = { - "getch", "mvgetch", "mvwgetch", "wgetch", "getnstr", "getstr", "mvgetnstr", - "mvgetstr", "mvwgetnstr", "mvwgetstr", "wgetnstr", "wgetstr", "mvscanw", - "mvwscanw", "scanw", "wscanw", "get_wch", "mvget_wch", "mvwget_wch", - "wget_wch", "getn_wstr", "get_wstr", "mvgetn_wstr", "mvget_wstr", - "mvwgetn_wstr","mvwget_wstr", "wgetn_wstr", "wget_wstr" + variants("getch"), + variants("getnstr"), + variants("getstr"), + variants("getn_wstr"), + variants("get_wch"), + variants("get_wstr"), + variants("scanw"), }; +#undef variants static const unsigned ninput_functions = sizeof(input_functions) / sizeof(char *);
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Tue Apr 6 00:35:58 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: tests/libcurses: don't waste time calling strlen needlessly To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.49 src/tests/lib/libcurses/director/testlang_parse.y:1.50 --- src/tests/lib/libcurses/director/testlang_parse.y:1.49 Mon Feb 15 15:55:50 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Tue Apr 6 00:35:58 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.49 2021/02/15 15:55:50 joerg Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.50 2021/04/06 00:35:58 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -876,8 +876,7 @@ check_function_table(char *function, con int i; for (i = 0; i < nfunctions; i++) { - if ((strlen(function) == strlen(table[i])) && - (strcmp(function, table[i]) == 0)) + if (strcmp(function, table[i]) == 0) return 1; }
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rin Date: Sun Apr 4 09:49:13 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c src/tests/lib/libcurses/tests: mvscanw Log Message: Reapply fix for big-endian environments, which was lost when GSoC results were merged... http://www.nerv.org/netbsd/?q=id:20200620T075016Z.3584036ccf31f69ee76ea4a02e9be30ff081df21 > Fix false positive for mvscanw tests on big endian machines. > > When conversion specifier is not a derivative form of "%s", retrieve > input as 32bit integer, and then convert to string literal. Then we > can avoid interpretation from ASCII code to integer, which is > apparently byte-order depended. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/lib/libcurses/slave/curses_commands.c cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/tests/mvscanw Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.24 src/tests/lib/libcurses/slave/curses_commands.c:1.25 --- src/tests/lib/libcurses/slave/curses_commands.c:1.24 Sun Apr 4 09:42:08 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Sun Apr 4 09:49:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.24 2021/04/04 09:42:08 rin Exp $ */ +/* $NetBSD: curses_commands.c,v 1.25 2021/04/04 09:49:13 rin Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -1986,10 +1986,19 @@ cmd_mvscanw(int nargs, char **args) ARGC(3); ARG_INT(0, y); ARG_INT(1, x); - ARG_STRING(2, fmt); /* Must have a single "%s" in this test. */ + ARG_STRING(2, fmt); report_count(2); - report_return(ret = mvscanw(y, x, fmt, string)); + if (strchr(fmt, 's') != NULL) { + report_return(ret = mvscanw(y, x, fmt, string)); + } else { + int val; /* XXX assume 32-bit integer */ + report_return(ret = mvscanw(y, x, fmt, )); + if (ret == ERR) + goto out; + snprintf(string, sizeof(string), fmt, val); + } +out: /* * When mvscanw(3) fails, string is not modified. * Let's ignore the 2nd result for this case. Index: src/tests/lib/libcurses/tests/mvscanw diff -u src/tests/lib/libcurses/tests/mvscanw:1.6 src/tests/lib/libcurses/tests/mvscanw:1.7 --- src/tests/lib/libcurses/tests/mvscanw:1.6 Sun Apr 4 09:42:08 2021 +++ src/tests/lib/libcurses/tests/mvscanw Sun Apr 4 09:49:13 2021 @@ -1,11 +1,13 @@ +# XXX +# For this test, only one string or 32-bit integer are supported as +# conversion specifiers at the moment. include start input "testing 1 2 3\n" call2 OK "testing" mvscanw 3 5 "%s" input "testing 1 2 3\n" call2 OK "test" mvscanw 3 5 "%4s" -# 50 will translate into number 2 in ascii input "50 12\n" -call2 OK "2" mvscanw 3 5 "%d" +call2 OK "50" mvscanw 3 5 "%d" input "aa bb 50 12\n" # expect ERR because input has alpha and scanw wants integer call2 ERR "ERR" mvscanw 3 5 "%d"
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rin Date: Sun Apr 4 09:42:08 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c src/tests/lib/libcurses/tests: mvscanw Log Message: When mvscanw(3) fails, string is not modified. Let's ignore the 2nd result for this case. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libcurses/slave/curses_commands.c cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/tests/mvscanw Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.23 src/tests/lib/libcurses/slave/curses_commands.c:1.24 --- src/tests/lib/libcurses/slave/curses_commands.c:1.23 Sun Apr 4 09:34:24 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Sun Apr 4 09:42:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.23 2021/04/04 09:34:24 rin Exp $ */ +/* $NetBSD: curses_commands.c,v 1.24 2021/04/04 09:42:08 rin Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -1980,6 +1980,7 @@ cmd_mvprintw(int nargs, char **args) void cmd_mvscanw(int nargs, char **args) { + int ret; char string[256]; ARGC(3); @@ -1988,8 +1989,12 @@ cmd_mvscanw(int nargs, char **args) ARG_STRING(2, fmt); /* Must have a single "%s" in this test. */ report_count(2); - report_return(mvscanw(y, x, fmt, string)); - report_status(string); + report_return(ret = mvscanw(y, x, fmt, string)); + /* + * When mvscanw(3) fails, string is not modified. + * Let's ignore the 2nd result for this case. + */ + report_status(ret == ERR ? "ERR" : string); } Index: src/tests/lib/libcurses/tests/mvscanw diff -u src/tests/lib/libcurses/tests/mvscanw:1.5 src/tests/lib/libcurses/tests/mvscanw:1.6 --- src/tests/lib/libcurses/tests/mvscanw:1.5 Sat Oct 24 04:46:17 2020 +++ src/tests/lib/libcurses/tests/mvscanw Sun Apr 4 09:42:08 2021 @@ -8,4 +8,4 @@ input "50 12\n" call2 OK "2" mvscanw 3 5 "%d" input "aa bb 50 12\n" # expect ERR because input has alpha and scanw wants integer -call2 ERR "2" mvscanw 3 5 "%d" +call2 ERR "ERR" mvscanw 3 5 "%d"
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rin Date: Sun Apr 4 09:34:24 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: s//string/ for mvscanw(3); string is already pointer to buffer. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.22 src/tests/lib/libcurses/slave/curses_commands.c:1.23 --- src/tests/lib/libcurses/slave/curses_commands.c:1.22 Sat Feb 13 08:14:46 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Sun Apr 4 09:34:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.22 2021/02/13 08:14:46 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.23 2021/04/04 09:34:24 rin Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -1988,7 +1988,7 @@ cmd_mvscanw(int nargs, char **args) ARG_STRING(2, fmt); /* Must have a single "%s" in this test. */ report_count(2); - report_return(mvscanw(y, x, fmt, )); + report_return(mvscanw(y, x, fmt, string)); report_status(string); }
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: christos Date: Sun Mar 28 17:30:01 UTC 2021 Modified Files: src/tests/lib/libc/sys: t_sendrecv.c Log Message: yield so we can lose packets To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/sys/t_sendrecv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_sendrecv.c diff -u src/tests/lib/libc/sys/t_sendrecv.c:1.7 src/tests/lib/libc/sys/t_sendrecv.c:1.8 --- src/tests/lib/libc/sys/t_sendrecv.c:1.7 Sun Mar 21 12:58:07 2021 +++ src/tests/lib/libc/sys/t_sendrecv.c Sun Mar 28 13:30:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $ */ +/* $NetBSD: t_sendrecv.c,v 1.8 2021/03/28 17:30:01 christos Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $"); +__RCSID("$NetBSD: t_sendrecv.c,v 1.8 2021/03/28 17:30:01 christos Exp $"); #include #include @@ -40,6 +40,7 @@ __RCSID("$NetBSD: t_sendrecv.c,v 1.7 202 #include #include #include +#include #include #include @@ -94,6 +95,8 @@ receiver(int sd) return; if (p.seq != seq) printf("%ju != %ju\n", p.seq, seq); + if (seq % 10 == 0) +sched_yield(); seq = p.seq + 1; } // printf("<<%zd %d %ju\n", n, errno, seq);
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: christos Date: Sun Mar 21 16:58:07 UTC 2021 Modified Files: src/tests/lib/libc/sys: t_sendrecv.c Log Message: use a pipe instead of sched_yield() To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/t_sendrecv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_sendrecv.c diff -u src/tests/lib/libc/sys/t_sendrecv.c:1.6 src/tests/lib/libc/sys/t_sendrecv.c:1.7 --- src/tests/lib/libc/sys/t_sendrecv.c:1.6 Sat Feb 2 22:19:28 2019 +++ src/tests/lib/libc/sys/t_sendrecv.c Sun Mar 21 12:58:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_sendrecv.c,v 1.6 2019/02/03 03:19:28 mrg Exp $ */ +/* $NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_sendrecv.c,v 1.6 2019/02/03 03:19:28 mrg Exp $"); +__RCSID("$NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $"); #include #include @@ -41,7 +41,6 @@ __RCSID("$NetBSD: t_sendrecv.c,v 1.6 201 #include #include #include -#include #include @@ -62,33 +61,33 @@ handle_sigchld(__unused int pid) } static void -sender(int fd) +sender(int sd) { union packet p; ssize_t n; p.seq = 0; for (size_t i = 0; i < COUNT; i++) { - for (; (n = send(fd, , sizeof(p), 0)) == sizeof(p); + for (; (n = send(sd, , sizeof(p), 0)) == sizeof(p); p.seq++) continue; - printf(">>%zd %d %ju\n", n, errno, p.seq); +// printf(">>%zd %d %ju\n", n, errno, p.seq); ATF_REQUIRE_MSG(errno == ENOBUFS, "send %s", strerror(errno)); -// sched_yield(); } - printf("sender done\n"); + close(sd); +// printf("sender done\n"); } static void -receiver(int fd) +receiver(int sd) { union packet p; ssize_t n; uintmax_t seq = 0; - do { + for (size_t i = 0; i < COUNT; i++) { if (rdied) return; - while ((n = recv(fd, , sizeof(p), 0), sizeof(p)) + while ((n = recv(sd, , sizeof(p), 0), sizeof(p)) == sizeof(p)) { if (rdied) @@ -97,26 +96,29 @@ receiver(int fd) printf("%ju != %ju\n", p.seq, seq); seq = p.seq + 1; } - printf("<<%zd %d %ju\n", n, errno, seq); +// printf("<<%zd %d %ju\n", n, errno, seq); if (n == 0) return; ATF_REQUIRE_EQ(n, -1); ATF_REQUIRE_MSG(errno == ENOBUFS, "recv %s", strerror(errno)); - } while (p.seq < COUNT); + } + close(sd); } static void sendrecv(int rerror) { - int fd[2], error; + int fd[2], sd[2], error; + char c = 0; struct sigaction sa; - error = socketpair(AF_UNIX, SOCK_DGRAM, 0, fd); -// error = pipe(fd); + error = socketpair(AF_UNIX, SOCK_DGRAM, 0, sd); ATF_REQUIRE_MSG(error != -1, "socketpair failed (%s)", strerror(errno)); + error = pipe(fd); + ATF_REQUIRE_MSG(error != -1, "pipe failed (%s)", strerror(errno)); - for (size_t i = 0; i < __arraycount(fd); i++) { - error = setsockopt(fd[i], SOL_SOCKET, SO_RERROR, , + for (size_t i = 0; i < __arraycount(sd); i++) { + error = setsockopt(sd[i], SOL_SOCKET, SO_RERROR, , sizeof(rerror)); ATF_REQUIRE_MSG(error != -1, "setsockopt(SO_RERROR) failed (%s)", strerror(errno)); @@ -133,17 +135,18 @@ sendrecv(int rerror) switch (fork()) { case -1: ATF_REQUIRE_MSG(errno == 0, - "socketpair failed (%s)", strerror(errno)); + "fork failed (%s)", strerror(errno)); __unreachable(); /*NOTREACHED*/ case 0: - sched_yield(); - sender(fd[0]); - close(fd[0]); + read(fd[1], , sizeof(c)); + sender(sd[0]); + close(sd[0]); exit(EXIT_SUCCESS); /*NOTREACHED*/ default: - receiver(fd[1]); + write(fd[0], , sizeof(c)); + receiver(sd[1]); return; } }
CVS commit: src/tests/lib/libc/setjmp
Module Name:src Committed By: christos Date: Sun Mar 21 16:36:32 UTC 2021 Modified Files: src/tests/lib/libc/setjmp: t_setjmp.c Log Message: PR/56066: Jessica Clarke: Add tests for calling {_,}longjmp with a zero value. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/setjmp/t_setjmp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/setjmp/t_setjmp.c diff -u src/tests/lib/libc/setjmp/t_setjmp.c:1.2 src/tests/lib/libc/setjmp/t_setjmp.c:1.3 --- src/tests/lib/libc/setjmp/t_setjmp.c:1.2 Sat Jan 14 16:08:17 2017 +++ src/tests/lib/libc/setjmp/t_setjmp.c Sun Mar 21 12:36:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $ */ +/* $NetBSD: t_setjmp.c,v 1.3 2021/03/21 16:36:32 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -63,13 +63,14 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $"); +__RCSID("$NetBSD: t_setjmp.c,v 1.3 2021/03/21 16:36:32 christos Exp $"); #include #include #include #include +#include #include #include #include @@ -83,6 +84,8 @@ __RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/ #define TEST_U_SETJMP 1 #define TEST_SIGSETJMP_SAVE 2 #define TEST_SIGSETJMP_NOSAVE 3 +#define TEST_LONGJMP_ZERO 4 +#define TEST_U_LONGJMP_ZERO 5 static int expectsignal; @@ -101,12 +104,16 @@ h_check(int test) sigjmp_buf sjb; sigset_t ss; int i, x; + volatile bool did_longjmp; i = getpid(); + did_longjmp = false; - if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE) + if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE || + test == TEST_LONGJMP_ZERO) expectsignal = 0; - else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE) + else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE || + test == TEST_U_LONGJMP_ZERO) expectsignal = 1; else atf_tc_fail("unknown test"); @@ -119,26 +126,37 @@ h_check(int test) REQUIRE_ERRNO(sigaddset(, SIGABRT) != -1); REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, , NULL) != -1); - if (test == TEST_SETJMP) + if (test == TEST_SETJMP || test == TEST_LONGJMP_ZERO) x = setjmp(jb); - else if (test == TEST_U_SETJMP) + else if (test == TEST_U_SETJMP || test == TEST_U_LONGJMP_ZERO) x = _setjmp(jb); else x = sigsetjmp(sjb, !expectsignal); if (x != 0) { - ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); + if (test == TEST_LONGJMP_ZERO || test == TEST_U_LONGJMP_ZERO) + ATF_REQUIRE_MSG(x == 1, "setjmp returned wrong value"); + else + ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value"); + kill(i, SIGABRT); ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed"); atf_tc_pass(); + } else if (did_longjmp) { + atf_tc_fail("setjmp returned zero after longjmp"); } REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, , NULL) != -1); + did_longjmp = true; if (test == TEST_SETJMP) longjmp(jb, i); + else if (test == TEST_LONGJMP_ZERO) + longjmp(jb, 0); else if (test == TEST_U_SETJMP) _longjmp(jb, i); + else if (test == TEST_U_LONGJMP_ZERO) + _longjmp(jb, 0); else siglongjmp(sjb, i); @@ -185,12 +203,34 @@ ATF_TC_BODY(sigsetjmp_nosave, tc) h_check(TEST_SIGSETJMP_NOSAVE); } +ATF_TC(longjmp_zero); +ATF_TC_HEAD(longjmp_zero, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks longjmp(3) with a zero value"); +} +ATF_TC_BODY(longjmp_zero, tc) +{ + h_check(TEST_LONGJMP_ZERO); +} + +ATF_TC(_longjmp_zero); +ATF_TC_HEAD(_longjmp_zero, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks _longjmp(3) with a zero value"); +} +ATF_TC_BODY(_longjmp_zero, tc) +{ + h_check(TEST_U_LONGJMP_ZERO); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, setjmp); ATF_TP_ADD_TC(tp, _setjmp); ATF_TP_ADD_TC(tp, sigsetjmp_save); ATF_TP_ADD_TC(tp, sigsetjmp_nosave); + ATF_TP_ADD_TC(tp, longjmp_zero); + ATF_TP_ADD_TC(tp, _longjmp_zero); return atf_no_error(); }
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: simonb Date: Fri Mar 19 00:44:09 UTC 2021 Modified Files: src/tests/lib/libc/sys: t_ptrace_signal_wait.h Log Message: Sprinkle a few more \n's and the end of some debug printfs. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_ptrace_signal_wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_ptrace_signal_wait.h diff -u src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.4 src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.5 --- src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.4 Mon Jun 22 12:21:02 2020 +++ src/tests/lib/libc/sys/t_ptrace_signal_wait.h Fri Mar 19 00:44:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace_signal_wait.h,v 1.4 2020/06/22 12:21:02 rin Exp $ */ +/* $NetBSD: t_ptrace_signal_wait.h,v 1.5 2021/03/19 00:44:09 simonb Exp $ */ /*- * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ traceme_raise(int sigval) ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval); ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP); - DPRINTF("Assert that PT_GET_PROCESS_STATE returns non-error"); + DPRINTF("Assert that PT_GET_PROCESS_STATE returns non-error\n"); SYSCALL_REQUIRE( ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1); ATF_REQUIRE(memcmp(, _state, slen) == 0); @@ -401,7 +401,7 @@ traceme_crash(int sig) validate_status_stopped(status, sig); - DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child"); + DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); SYSCALL_REQUIRE( ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1); @@ -567,7 +567,7 @@ traceme_signalmasked_crash(int sig) validate_status_stopped(status, sig); - DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child"); + DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); SYSCALL_REQUIRE( ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1); @@ -750,7 +750,7 @@ traceme_signalignored_crash(int sig) validate_status_stopped(status, sig); - DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child"); + DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n"); SYSCALL_REQUIRE( ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Thu Feb 25 22:37:37 UTC 2021 Modified Files: src/tests/lib/libc/regex: Makefile debug.c Log Message: Adjust for conditional NLS To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/regex/Makefile cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/Makefile diff -u src/tests/lib/libc/regex/Makefile:1.10 src/tests/lib/libc/regex/Makefile:1.11 --- src/tests/lib/libc/regex/Makefile:1.10 Thu Aug 25 21:31:43 2016 +++ src/tests/lib/libc/regex/Makefile Thu Feb 25 17:37:36 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 2016/08/26 01:31:43 darcy Exp $ +# $NetBSD: Makefile,v 1.11 2021/02/25 22:37:36 christos Exp $ NOMAN= @@ -10,7 +10,7 @@ IMPLEMENTATION?= -DREGEX_SPENCER -DSKIP_ BINDIR= ${TESTSDIR} PROGS?= h_regex SRCS.h_regex= main.c split.c debug.c -CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION} +CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION} -DNLS TESTS_SH?= t_regex TESTS_C= t_regex_att Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.6 src/tests/lib/libc/regex/debug.c:1.7 --- src/tests/lib/libc/regex/debug.c:1.6 Wed Feb 24 13:18:53 2021 +++ src/tests/lib/libc/regex/debug.c Thu Feb 25 17:37:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.6 2021/02/24 18:18:53 christos Exp $ */ +/* $NetBSD: debug.c,v 1.7 2021/02/25 22:37:36 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -33,8 +33,6 @@ #include #include #include -#include -#include #ifndef __linux__ /* Don't sort these! */
CVS commit: src/tests/lib/libcurses/tests
Module Name:src Committed By: rillig Date: Thu Feb 25 01:07:43 UTC 2021 Modified Files: src/tests/lib/libcurses/tests: addbytes addch Log Message: tests/libcurses: add test for '\b' in addch Just to ensure that addch and addstr behave the same, after the recent fix for handling '\t'. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/addbytes cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/tests/addch Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/tests/addbytes diff -u src/tests/lib/libcurses/tests/addbytes:1.3 src/tests/lib/libcurses/tests/addbytes:1.4 --- src/tests/lib/libcurses/tests/addbytes:1.3 Thu Feb 25 00:26:57 2021 +++ src/tests/lib/libcurses/tests/addbytes Thu Feb 25 01:07:43 2021 @@ -1,4 +1,4 @@ -# $NetBSD: addbytes,v 1.3 2021/02/25 00:26:57 rillig Exp $ +# $NetBSD: addbytes,v 1.4 2021/02/25 01:07:43 rillig Exp $ # # Tests adding bytes to stdscr. # @@ -19,13 +19,15 @@ call2 0 16 getyx STDSCR call OK addbytes "\n" 1 call2 1 0 getyx STDSCR +# Ensure that backspace works as intended. +# See tests/addch. call OK addbytes "12345\010" 6 call2 1 4 getyx STDSCR call OK addbytes "\010\010\010\010" 4 call2 1 0 getyx STDSCR -# When curx is already 0, backspace is a no-op. +# If curx is already 0, backspace is a no-op. call OK addbytes "\010" 1 call2 1 0 getyx STDSCR Index: src/tests/lib/libcurses/tests/addch diff -u src/tests/lib/libcurses/tests/addch:1.7 src/tests/lib/libcurses/tests/addch:1.8 --- src/tests/lib/libcurses/tests/addch:1.7 Sun Feb 14 11:21:37 2021 +++ src/tests/lib/libcurses/tests/addch Thu Feb 25 01:07:43 2021 @@ -1,4 +1,4 @@ -# $NetBSD: addch,v 1.7 2021/02/14 11:21:37 rillig Exp $ +# $NetBSD: addch,v 1.8 2021/02/25 01:07:43 rillig Exp $ # # Between at least 2012 and 2016, addstr did not advance win->curx for a '\t', # but addch did. This was inconsistent. @@ -33,3 +33,29 @@ call OK addch `\000\n` call OK refresh compare addch.chk + +# Ensure that backspace works as intended. +# See tests/addbytes. +call OK move 1 0 +call OK addstr "12345" +call OK addch `\000\010` +call2 1 4 getyx STDSCR + +call OK addch `\000\010` +call OK addch `\000\010` +call OK addch `\000\010` +call OK addch `\000\010` +call2 1 0 getyx STDSCR + +# If curx is already 0, backspace is a no-op. +call OK addch `\000\010` +call2 1 0 getyx STDSCR + +call OK addstr "123" +call OK addch `\000\t` +call2 1 8 getyx STDSCR + +# Backspace affects the cursor position, no matter whether the previously +# output char was a tab or a space. +call OK addch `\000\010` +call2 1 7 getyx STDSCR
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Thu Feb 25 00:50:10 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_conf.l Log Message: tests/libcurses: use common style for parse error messages To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/lib/libcurses/director/testlang_conf.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.24 src/tests/lib/libcurses/director/testlang_conf.l:1.25 --- src/tests/lib/libcurses/director/testlang_conf.l:1.24 Thu Feb 25 00:42:00 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Thu Feb 25 00:50:10 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.24 2021/02/25 00:42:00 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.25 2021/02/25 00:50:10 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -125,7 +125,8 @@ dequote(const char *s, size_t *len) default: if (isalpha(*p)) errx(2, - "%s:%zu: invalid escape sequence '\\%c' in string literal", + "%s:%zu: Invalid escape sequence " + "'\\%c' in string literal", cur_file, line, *p); *q++ = *p++; } @@ -182,10 +183,9 @@ include BEGIN(incl); char *inc_file; if (include_ptr > MAX_INCLUDES) { - fprintf(stderr, -"Maximum number of nested includes exceeded " -"at line %zu of file %s\n", line, cur_file); -exit(2); + errx(2, + "%s:%zu: Maximum number of nested includes " + "exceeded", cur_file, line); } const char *dir_begin;
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Thu Feb 25 00:42:00 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_conf.l Log Message: tests/libcurses: use common syntax for accessing array elements Writing *(p+1) is needlessly confusing, even though it adds a little symmetry between *p and *(p+1). Still, one of these expressions has parentheses, the other doesn't, which breaks the symmetry. Wrap overly long code line. It's confusing to refer to the digits after the backslash once with index 0 to 2, and the other time with index 1 to 3. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libcurses/director/testlang_conf.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.23 src/tests/lib/libcurses/director/testlang_conf.l:1.24 --- src/tests/lib/libcurses/director/testlang_conf.l:1.23 Thu Feb 25 00:32:44 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Thu Feb 25 00:42:00 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.23 2021/02/25 00:32:44 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.24 2021/02/25 00:42:00 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -59,9 +59,8 @@ dequote(const char *s, size_t *len) *len = 0; p = (const unsigned char *)s; while (*p) { - if (*p == '\\' && *(p+1)) { - if (isdigit(*(p+1)) && *(p+2) && isdigit(*(p+2)) && - *(p+3) && isdigit(*(p+3))) + if (*p == '\\' && p[1]) { + if (isdigit(p[1]) && isdigit(p[2]) && isdigit(p[3])) p += 3; else ++p; @@ -77,13 +76,14 @@ dequote(const char *s, size_t *len) p = (const unsigned char *)s; q = buf; while (*p) { - if (*p == '\\' && *(p+1)) { + if (*p == '\\' && p[1]) { ++p; - if (isdigit(*p)) { -if (*(p+1) && isdigit(*(p+1)) && *(p+2) && -isdigit(*(p+2))) { - *q++ = ((*p - '0') * 8 + (*(p+1) - '0')) * 8 + (*(p+2) - '0'); + if (isdigit(p[0])) { +if (isdigit(p[1]) && isdigit(p[2])) { + *q++ = (p[0] - '0') * 64 + + (p[1] - '0') * 8 + + (p[2] - '0'); p += 3; } else { *q++ = *p++;
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Thu Feb 25 00:32:44 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_conf.l Log Message: tests/libcurses: reduce indentation No functional change. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/director/testlang_conf.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.22 src/tests/lib/libcurses/director/testlang_conf.l:1.23 --- src/tests/lib/libcurses/director/testlang_conf.l:1.22 Thu Feb 25 00:25:31 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Thu Feb 25 00:32:44 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.22 2021/02/25 00:25:31 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.23 2021/02/25 00:32:44 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -79,6 +79,7 @@ dequote(const char *s, size_t *len) while (*p) { if (*p == '\\' && *(p+1)) { ++p; + if (isdigit(*p)) { if (*(p+1) && isdigit(*(p+1)) && *(p+2) && isdigit(*(p+2))) { @@ -87,45 +88,46 @@ dequote(const char *s, size_t *len) } else { *q++ = *p++; } - } else { -switch (*p) { -case 'e': - /* escape */ - *q++ = '\e'; - p++; - break; - -case 'n': - /* newline */ - *q++ = '\n'; - p++; - break; - -case 'r': - /* carriage return */ - *q++ = '\r'; - p++; - break; - -case 't': - /* tab */ - *q++ = '\t'; - p++; - break; - -case '\\': - /* backslash */ - *q++ = '\\'; - p++; - break; - -default: - if (isalpha((unsigned char)*p)) - errx(2, - "%s:%zu: invalid escape sequence '\\%c' in string literal", - cur_file, line, *p); - *q++ = *p++; -} +continue; + } + + switch (*p) { + case 'e': +/* escape */ +*q++ = '\e'; +p++; +break; + + case 'n': +/* newline */ +*q++ = '\n'; +p++; +break; + + case 'r': +/* carriage return */ +*q++ = '\r'; +p++; +break; + + case 't': +/* tab */ +*q++ = '\t'; +p++; +break; + + case '\\': +/* backslash */ +*q++ = '\\'; +p++; +break; + + default: +if (isalpha(*p)) + errx(2, + "%s:%zu: invalid escape sequence '\\%c' in string literal", + cur_file, line, *p); +*q++ = *p++; } } else *q++ = *p++;
CVS commit: src/tests/lib/libcurses/tests
Module Name:src Committed By: rillig Date: Thu Feb 25 00:26:57 UTC 2021 Modified Files: src/tests/lib/libcurses/tests: addbytes Log Message: libcurses: ensure that '\b' in handled correctly in addstr Just to ensure that the recent fix for '\t' handling in addstr/addch didn't introduce another bug. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/tests/addbytes Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/tests/addbytes diff -u src/tests/lib/libcurses/tests/addbytes:1.2 src/tests/lib/libcurses/tests/addbytes:1.3 --- src/tests/lib/libcurses/tests/addbytes:1.2 Sat Feb 13 22:19:47 2021 +++ src/tests/lib/libcurses/tests/addbytes Thu Feb 25 00:26:57 2021 @@ -1,4 +1,4 @@ -# $NetBSD: addbytes,v 1.2 2021/02/13 22:19:47 rillig Exp $ +# $NetBSD: addbytes,v 1.3 2021/02/25 00:26:57 rillig Exp $ # # Tests adding bytes to stdscr. # @@ -18,3 +18,21 @@ call2 0 16 getyx STDSCR call OK addbytes "\n" 1 call2 1 0 getyx STDSCR + +call OK addbytes "12345\010" 6 +call2 1 4 getyx STDSCR + +call OK addbytes "\010\010\010\010" 4 +call2 1 0 getyx STDSCR + +# When curx is already 0, backspace is a no-op. +call OK addbytes "\010" 1 +call2 1 0 getyx STDSCR + +call OK addbytes "123\t" 4 +call2 1 8 getyx STDSCR + +# Backspace affects the cursor position, no matter whether the previously +# output char was a tab or a space. +call OK addbytes "\010" 1 +call2 1 7 getyx STDSCR
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Thu Feb 25 00:25:31 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_conf.l src/tests/lib/libcurses/tests: addchstr Log Message: libcurses: prevent unknown escpae sequences in tests Before, '\b' was interpreted as a simple 'b', which is confusing for C programmers. Same for '\a'. There is absolutely no reason to escape letters, so fail early in these cases. The '\h' in the test addchstr was obviously a typo that was easy to detect, if only the compiler had been strict enough from the very beginning. The code is wider than 80 characters, same as the code that parses octal escape sequences a few lines above it. This code will be refactored to use less indentation in a follow-up commit. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libcurses/director/testlang_conf.l cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/tests/addchstr Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.21 src/tests/lib/libcurses/director/testlang_conf.l:1.22 --- src/tests/lib/libcurses/director/testlang_conf.l:1.21 Mon Feb 15 07:06:27 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Thu Feb 25 00:25:31 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.21 2021/02/15 07:06:27 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.22 2021/02/25 00:25:31 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -120,6 +120,10 @@ dequote(const char *s, size_t *len) break; default: + if (isalpha((unsigned char)*p)) + errx(2, + "%s:%zu: invalid escape sequence '\\%c' in string literal", + cur_file, line, *p); *q++ = *p++; } } Index: src/tests/lib/libcurses/tests/addchstr diff -u src/tests/lib/libcurses/tests/addchstr:1.3 src/tests/lib/libcurses/tests/addchstr:1.4 --- src/tests/lib/libcurses/tests/addchstr:1.3 Sat Oct 24 04:46:17 2020 +++ src/tests/lib/libcurses/tests/addchstr Thu Feb 25 00:25:31 2021 @@ -4,7 +4,7 @@ call OK refresh compare addchstr.chk call OK move 0 5 call OK bkgdset `\002\000` -call OK addchstr `\004f\004g\004\h` +call OK addchstr `\004f\004g\004h` call OK refresh compare addchstr2.chk # check wrapping (should not wrap)
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Feb 24 18:18:53 UTC 2021 Modified Files: src/tests/lib/libc/regex: debug.c Log Message: remove casts To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.5 src/tests/lib/libc/regex/debug.c:1.6 --- src/tests/lib/libc/regex/debug.c:1.5 Tue Feb 23 21:33:56 2021 +++ src/tests/lib/libc/regex/debug.c Wed Feb 24 13:18:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.5 2021/02/24 02:33:56 christos Exp $ */ +/* $NetBSD: debug.c,v 1.6 2021/02/24 18:18:53 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -64,9 +64,7 @@ regprint(regex_t *r, FILE *d) #ifndef REGEX_NODEBUG struct re_guts *g = r->re_g; - fprintf(d, "%ld states, %zu ncsets", (long)g->nstates, g->ncsets); - fprintf(d, ", first %ld last %ld", (long)g->firststate, - (long)g->laststate); + fprintf(d, ", first %u last %u", g->firststate, g->laststate); if (g->iflags) fprintf(d, ", USEBOL"); if (g->iflags) @@ -74,14 +72,13 @@ regprint(regex_t *r, FILE *d) if (g->iflags) fprintf(d, ", BAD"); if (g->nsub > 0) - fprintf(d, ", nsub=%ld", (long)g->nsub); + fprintf(d, ", nsub=%zu", g->nsub); if (g->must != NULL) - fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen, -g->must); + fprintf(d, ", must(%zu) `%*s'", g->mlen, (int)g->mlen, g->must); if (g->backrefs) fprintf(d, ", backrefs"); if (g->nplus > 0) - fprintf(d, ", nplus %ld", (long)g->nplus); + fprintf(d, ", nplus %u", g->nplus); fprintf(d, "\n"); s_print(g, d); fprintf(d, "\n"); @@ -144,63 +141,63 @@ s_print(struct re_guts *g, FILE *d) fprintf(d, "."); break; case OANYOF: - fprintf(d, "[(%ld)", (long)opnd); + fprintf(d, "[(%u)", opnd); fprintf(d, "]"); break; case OBACK_: - fprintf(d, "(\\<%ld>", (long)opnd); + fprintf(d, "(\\<%u>", opnd); break; case O_BACK: - fprintf(d, "<%ld>\\)", (long)opnd); + fprintf(d, "<%u>\\)", opnd); break; case OPLUS_: fprintf(d, "(+"); if (OP(*(s+opnd)) != O_PLUS) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); break; case O_PLUS: if (OP(*(s-opnd)) != OPLUS_) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); fprintf(d, "+)"); break; case OQUEST_: fprintf(d, "(?"); if (OP(*(s+opnd)) != O_QUEST) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); break; case O_QUEST: if (OP(*(s-opnd)) != OQUEST_) -fprintf(d, "<%ld>", (long)opnd); +fprintf(d, "<%u>", opnd); fprintf(d, "?)"); break; case OLPAREN: - fprintf(d, "((<%ld>", (long)opnd); + fprintf(d, "((<%u>", opnd); break; case ORPAREN: - fprintf(d, "<%ld>))", (long)opnd); + fprintf(d, "<%u>))", opnd); break; case OCH_: fprintf(d, "<"); - if (OP(*(s+opnd)) != (sop)OOR2) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s+opnd)) != OOR2) +fprintf(d, "<%u>", opnd); break; case OOR1: - if (OP(*(s-opnd)) != (sop)OOR1 && OP(*(s-opnd)) != (sop)OCH_) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_) +fprintf(d, "<%u>", opnd); fprintf(d, "|"); break; case OOR2: fprintf(d, "|"); - if (OP(*(s+opnd)) != (sop)OOR2 && OP(*(s+opnd)) != (sop)O_CH) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH) +fprintf(d, "<%u>", opnd); break; case O_CH: - if (OP(*(s-opnd)) != (sop)OOR1) -fprintf(d, "<%ld>", (long)opnd); + if (OP(*(s-opnd)) != OOR1) +fprintf(d, "<%u>", opnd); fprintf(d, ">"); break; default: - fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd); + fprintf(d, "!%u(%u)!", OP(*s), opnd); break; } if (!done)
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Wed Feb 24 02:33:56 UTC 2021 Modified Files: src/tests/lib/libc/regex: debug.c Log Message: minimal fix to match the library code (really make the constants unsigned instead) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.4 src/tests/lib/libc/regex/debug.c:1.5 --- src/tests/lib/libc/regex/debug.c:1.4 Tue Feb 23 09:59:09 2021 +++ src/tests/lib/libc/regex/debug.c Tue Feb 23 21:33:56 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.4 2021/02/23 14:59:09 christos Exp $ */ +/* $NetBSD: debug.c,v 1.5 2021/02/24 02:33:56 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -181,21 +181,21 @@ s_print(struct re_guts *g, FILE *d) break; case OCH_: fprintf(d, "<"); - if (OP(*(s+opnd)) != OOR2) + if (OP(*(s+opnd)) != (sop)OOR2) fprintf(d, "<%ld>", (long)opnd); break; case OOR1: - if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_) + if (OP(*(s-opnd)) != (sop)OOR1 && OP(*(s-opnd)) != (sop)OCH_) fprintf(d, "<%ld>", (long)opnd); fprintf(d, "|"); break; case OOR2: fprintf(d, "|"); - if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH) + if (OP(*(s+opnd)) != (sop)OOR2 && OP(*(s+opnd)) != (sop)O_CH) fprintf(d, "<%ld>", (long)opnd); break; case O_CH: - if (OP(*(s-opnd)) != OOR1) + if (OP(*(s-opnd)) != (sop)OOR1) fprintf(d, "<%ld>", (long)opnd); fprintf(d, ">"); break;
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 17:13:44 UTC 2021 Modified Files: src/tests/lib/libc/regex: main.c Log Message: Add REG_GNU To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/main.c diff -u src/tests/lib/libc/regex/main.c:1.3 src/tests/lib/libc/regex/main.c:1.4 --- src/tests/lib/libc/regex/main.c:1.3 Tue Feb 23 10:00:01 2021 +++ src/tests/lib/libc/regex/main.c Tue Feb 23 12:13:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 2021/02/23 15:00:01 christos Exp $ */ +/* $NetBSD: main.c,v 1.4 2021/02/23 17:13:44 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -352,7 +352,7 @@ options(int type, char *s) { char *p; int o = (type == 'c') ? copts : eopts; - const char *legal = (type == 'c') ? "bisnmpP" : "^$#tl"; + const char *legal = (type == 'c') ? "bisnmpg" : "^$#tl"; for (p = s; *p != '\0'; p++) if (strchr(legal, *p) != NULL) @@ -376,8 +376,8 @@ options(int type, char *s) case 'p': o |= REG_PEND; break; - case 'P': -o |= REG_POSIX; + case 'g': +o |= REG_GNU; break; case '^': o |= REG_NOTBOL;
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 16:00:37 UTC 2021 Modified Files: src/tests/lib/libc/regex: t_regex_att.c Log Message: Add support for ENOSYS (was never set) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/t_regex_att.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/t_regex_att.c diff -u src/tests/lib/libc/regex/t_regex_att.c:1.3 src/tests/lib/libc/regex/t_regex_att.c:1.4 --- src/tests/lib/libc/regex/t_regex_att.c:1.3 Sat Jan 14 15:59:23 2017 +++ src/tests/lib/libc/regex/t_regex_att.c Tue Feb 23 11:00:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $ */ +/* $NetBSD: t_regex_att.c,v 1.4 2021/02/23 16:00:37 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__RCSID("$NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $"); +__RCSID("$NetBSD: t_regex_att.c,v 1.4 2021/02/23 16:00:37 christos Exp $"); #include @@ -284,7 +284,12 @@ geterror(const char *s, int *comp, int * _DO(EMPTY, COMP) _DO(ASSERT, COMP) _DO(INVARG, COMP) +#ifdef REG_ENOSYS _DO(ENOSYS, COMP) +#endif +#ifdef REG_ILLSEQ + _DO(ILLSEQ, COMP) +#endif #undef _DO }; *comp = 0;
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 15:00:01 UTC 2021 Modified Files: src/tests/lib/libc/regex: main.c Log Message: Add REG_POSIX, and make compile on linux where we don't have a lot of the internal flags. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/main.c diff -u src/tests/lib/libc/regex/main.c:1.2 src/tests/lib/libc/regex/main.c:1.3 --- src/tests/lib/libc/regex/main.c:1.2 Fri Sep 16 12:13:18 2011 +++ src/tests/lib/libc/regex/main.c Tue Feb 23 10:00:01 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.2 2011/09/16 16:13:18 plunky Exp $ */ +/* $NetBSD: main.c,v 1.3 2021/02/23 15:00:01 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -52,6 +52,16 @@ static char empty = '\0'; static char *eprint(int); static int efind(char *); +#ifndef REG_ATOI +#define REG_ATOI 0 +#define REG_ITOA 0 +#define REG_PEND 0 +#define REG_TRACE 0 +#define REG_BACKR 0 +#define REG_NOSPEC 0 +#define REG_LARGE 0 +#endif + /* * main - do the simple case, hand off to regress() for regression */ @@ -72,7 +82,7 @@ main(int argc, char *argv[]) progname = argv[0]; - while ((c = getopt(argc, argv, "c:e:S:E:x")) != -1) + while ((c = getopt(argc, argv, "c:E:e:S:x")) != -1) switch (c) { case 'c': /* compile options */ copts = options('c', optarg); @@ -80,12 +90,12 @@ main(int argc, char *argv[]) case 'e': /* execute options */ eopts = options('e', optarg); break; - case 'S': /* start offset */ - startoff = (regoff_t)atoi(optarg); - break; case 'E': /* end offset */ endoff = (regoff_t)atoi(optarg); break; + case 'S': /* start offset */ + startoff = (regoff_t)atoi(optarg); + break; case 'x': /* Debugging. */ debug++; break; @@ -211,7 +221,9 @@ regress(FILE *in) erbuf, bpname); status = 1; } +#if REG_ATOI re.re_endp = bpname; +#endif ne = regerror(REG_ATOI, , erbuf, sizeof(erbuf)); if (atoi(erbuf) != (int)REG_BADPAT) { fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n", @@ -247,7 +259,9 @@ try(char *f0, char *f1, char *f2, char * char f2copy[1000]; strcpy(f0copy, f0); +#if REG_ATOI re.re_endp = (opts_PEND) ? f0copy + strlen(f0copy) : NULL; +#endif fixstr(f0copy); err = regcomp(, f0copy, opts); if (err != 0 && (!opt('C', f1) || err != efind(f2))) { @@ -338,7 +352,7 @@ options(int type, char *s) { char *p; int o = (type == 'c') ? copts : eopts; - const char *legal = (type == 'c') ? "bisnmp" : "^$#tl"; + const char *legal = (type == 'c') ? "bisnmpP" : "^$#tl"; for (p = s; *p != '\0'; p++) if (strchr(legal, *p) != NULL) @@ -362,6 +376,9 @@ options(int type, char *s) case 'p': o |= REG_PEND; break; + case 'P': +o |= REG_POSIX; +break; case '^': o |= REG_NOTBOL; break; @@ -517,7 +534,9 @@ efind(char *name) sprintf(efbuf, "REG_%s", name); assert(strlen(efbuf) < sizeof(efbuf)); +#if REG_ATOI re.re_endp = efbuf; +#endif (void) regerror(REG_ATOI, , efbuf, sizeof(efbuf)); return(atoi(efbuf)); }
CVS commit: src/tests/lib/libc/regex
Module Name:src Committed By: christos Date: Tue Feb 23 14:59:09 UTC 2021 Modified Files: src/tests/lib/libc/regex: debug.c Log Message: Delete category stuff that has changed with the new regex; make compile on linux and with TRE To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/debug.c diff -u src/tests/lib/libc/regex/debug.c:1.3 src/tests/lib/libc/regex/debug.c:1.4 --- src/tests/lib/libc/regex/debug.c:1.3 Fri Jan 13 19:50:56 2017 +++ src/tests/lib/libc/regex/debug.c Tue Feb 23 09:59:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.3 2017/01/14 00:50:56 christos Exp $ */ +/* $NetBSD: debug.c,v 1.4 2021/02/23 14:59:09 christos Exp $ */ /*- * Copyright (c) 1993 The NetBSD Foundation, Inc. @@ -36,14 +36,24 @@ #include #include +#ifndef __linux__ /* Don't sort these! */ #include "utils.h" #include "regex2.h" +#else +#define REGEX_NODEBUG +#endif + +#ifdef REGEX_TRE +#define REGEX_NODEBUG +#endif #include "test_regex.h" +#ifndef REGEX_NODEBUG static void s_print(struct re_guts *, FILE *); static char *regchar(int); +#endif /* * regprint - print a regexp for debugging @@ -51,13 +61,10 @@ static char *regchar(int); void regprint(regex_t *r, FILE *d) { +#ifndef REGEX_NODEBUG struct re_guts *g = r->re_g; - int c; - int last; - int nincat[NC]; - fprintf(d, "%ld states, %zu categories", (long)g->nstates, - g->ncategories); + fprintf(d, "%ld states, %zu ncsets", (long)g->nstates, g->ncsets); fprintf(d, ", first %ld last %ld", (long)g->firststate, (long)g->laststate); if (g->iflags) @@ -77,43 +84,11 @@ regprint(regex_t *r, FILE *d) fprintf(d, ", nplus %ld", (long)g->nplus); fprintf(d, "\n"); s_print(g, d); - for (size_t i = 0; i < g->ncategories; i++) { - nincat[i] = 0; - for (c = CHAR_MIN; c <= CHAR_MAX; c++) - if (g->categories[c] == i) -nincat[i]++; - } - fprintf(d, "cc0#%d", nincat[0]); - for (size_t i = 1; i < g->ncategories; i++) - if (nincat[i] == 1) { - for (c = CHAR_MIN; c <= CHAR_MAX; c++) -if (g->categories[c] == i) - break; - fprintf(d, ", %zu=%s", i, regchar(c)); - } fprintf(d, "\n"); - for (size_t i = 1; i < g->ncategories; i++) - if (nincat[i] != 1) { - fprintf(d, "cc%zu\t", i); - last = -1; - for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */ -if (c <= CHAR_MAX && g->categories[c] == i) { - if (last < 0) { - fprintf(d, "%s", regchar(c)); - last = c; - } -} else { - if (last >= 0) { - if (last != c-1) - fprintf(d, "-%s", -regchar(c-1)); - last = -1; - } -} - fprintf(d, "\n"); - } +#endif } +#ifndef REGEX_NODEBUG /* * s_print - print the strip for debugging */ @@ -121,11 +96,9 @@ static void s_print(struct re_guts *g, FILE *d) { sop *s; - cset *cs; int done = 0; sop opnd; int col = 0; - ssize_t last; sopno offset = 2; # define GAP() { if (offset % 5 == 0) { \ if (col > 40) { \ @@ -172,22 +145,6 @@ s_print(struct re_guts *g, FILE *d) break; case OANYOF: fprintf(d, "[(%ld)", (long)opnd); - cs = >sets[opnd]; - last = -1; - for (size_t i = 0; i < g->csetsize+1; i++) /* +1 flushes */ -if (CHIN(cs, i) && i < g->csetsize) { - if (last < 0) { - fprintf(d, "%s", regchar(i)); - last = i; - } -} else { - if (last >= 0) { - if (last != (ssize_t)i - 1) - fprintf(d, "-%s", - regchar(i - 1)); - last = -1; - } -} fprintf(d, "]"); break; case OBACK_: @@ -243,7 +200,7 @@ s_print(struct re_guts *g, FILE *d) fprintf(d, ">"); break; default: - fprintf(d, "!%d(%d)!", OP(*s), opnd); + fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd); break; } if (!done) @@ -265,3 +222,4 @@ regchar(int ch) sprintf(buf, "\\%o", ch); return(buf); } +#endif
CVS commit: src/tests/lib/libc/regex/data
Module Name:src Committed By: christos Date: Tue Feb 23 14:57:16 UTC 2021 Modified Files: src/tests/lib/libc/regex/data: meta.in repet_bounded.in repet_multi.in Log Message: Comment out tests that the new stricter regex does not like To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/data/meta.in \ src/tests/lib/libc/regex/data/repet_bounded.in \ src/tests/lib/libc/regex/data/repet_multi.in Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/regex/data/meta.in diff -u src/tests/lib/libc/regex/data/meta.in:1.1 src/tests/lib/libc/regex/data/meta.in:1.2 --- src/tests/lib/libc/regex/data/meta.in:1.1 Sat Jan 8 13:10:32 2011 +++ src/tests/lib/libc/regex/data/meta.in Tue Feb 23 09:57:16 2021 @@ -4,7 +4,8 @@ a[bc]d & abd abd a\*c & a*c a*c a\\b & a\b a\b a\\\*b & a\*b a\*b -a\bc & abc abc +# legacy escape +#a\bc & abc abc a\ EESCAPE a\\bc & a\bc a\bc \{ bC BADRPT Index: src/tests/lib/libc/regex/data/repet_bounded.in diff -u src/tests/lib/libc/regex/data/repet_bounded.in:1.1 src/tests/lib/libc/regex/data/repet_bounded.in:1.2 --- src/tests/lib/libc/regex/data/repet_bounded.in:1.1 Sat Jan 8 13:10:32 2011 +++ src/tests/lib/libc/regex/data/repet_bounded.in Tue Feb 23 09:57:16 2021 @@ -1,9 +1,10 @@ # the dreaded bounded repetitions -{ & { { -{abc & {abc {abc +# unclosed and with missing values are now errors +#{ & { { +#{abc & {abc {abc {1 C BADRPT {1} C BADRPT -a{b & a{b a{b +#a{b & a{b a{b a{1}b - ab ab a\{1\}b b ab ab a{1,}b - ab ab @@ -16,9 +17,9 @@ a{1a C EBRACE a\{1a bC EBRACE a{1a} C BADBR a\{1a\} bC BADBR -a{,2} - a{,2} a{,2} +#a{,2} - a{,2} a{,2} a\{,2\} bC BADBR -a{,} - a{,} a{,} +#a{,} - a{,} a{,} a\{,\} bC BADBR a{1,x} C BADBR a\{1,x\} bC BADBR Index: src/tests/lib/libc/regex/data/repet_multi.in diff -u src/tests/lib/libc/regex/data/repet_multi.in:1.1 src/tests/lib/libc/regex/data/repet_multi.in:1.2 --- src/tests/lib/libc/regex/data/repet_multi.in:1.1 Sat Jan 8 13:10:32 2011 +++ src/tests/lib/libc/regex/data/repet_multi.in Tue Feb 23 09:57:16 2021 @@ -15,7 +15,8 @@ a?{1} C BADRPT a{1}* C BADRPT a{1}+ C BADRPT a{1}? C BADRPT -a*{b} - a{b} a{b} +# repetition needs to be a number +#a*{b} - a{b} a{b} a\{1\}\{1\} bC BADRPT a*\{1\} bC BADRPT a\{1\}* bC BADRPT
CVS commit: src/tests/lib/libarchive
Module Name:src Committed By: martin Date: Fri Feb 19 18:36:50 UTC 2021 Modified Files: src/tests/lib/libarchive: t_libarchive.sh Log Message: PR kern/55272: do not skip this test on single cpu machines - it is not the only test causing the watchdog starvation and we better find and fix the real issue. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libarchive/t_libarchive.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libarchive/t_libarchive.sh diff -u src/tests/lib/libarchive/t_libarchive.sh:1.7 src/tests/lib/libarchive/t_libarchive.sh:1.8 --- src/tests/lib/libarchive/t_libarchive.sh:1.7 Fri Aug 28 18:46:05 2020 +++ src/tests/lib/libarchive/t_libarchive.sh Fri Feb 19 18:36:50 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_libarchive.sh,v 1.7 2020/08/28 18:46:05 christos Exp $ +# $NetBSD: t_libarchive.sh,v 1.8 2021/02/19 18:36:50 martin Exp $ # # Copyright (c) 2020 The NetBSD Foundation, Inc. # All rights reserved. @@ -41,10 +41,6 @@ libarchive_body() if [ $m -lt 400 ]; then atf_skip "Not enough RAM" fi - local ncpu=$( sysctl -n hw.ncpuonline ) - if [ $ncpu -lt 2 ]; then - atf_skip "PR kern/55272: too dangerous to run this test" - fi local d=$(atf_get_srcdir) atf_check -s exit:0 -o 'not-match:^Details for failing tests:.*' \ "$d/h_libarchive" -r "$d"
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: joerg Date: Mon Feb 15 15:55:51 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: Simplify to avoid copy based on the size of the source. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.48 src/tests/lib/libcurses/director/testlang_parse.y:1.49 --- src/tests/lib/libcurses/director/testlang_parse.y:1.48 Mon Feb 15 07:06:27 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Mon Feb 15 15:55:50 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.48 2021/02/15 07:06:27 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.49 2021/02/15 15:55:50 joerg Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -1388,10 +1388,8 @@ do_input(const char *s) free(input_str); } - if ((input_str = malloc(strlen(s) + 1)) == NULL) + if ((input_str = strdup(s)) == NULL) err(2, "Cannot allocate memory for input string"); - - strlcpy(input_str, s, strlen(s) + 1); } static void
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Mon Feb 15 07:06:27 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_conf.l testlang_parse.y src/tests/lib/libcurses/slave: commands.c Log Message: tests/libcurses: fix error handling for non-system errors These errors are unrelated to errno. The scanf family of functions also does not set errno. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libcurses/director/testlang_conf.l cvs rdiff -u -r1.47 -r1.48 src/tests/lib/libcurses/director/testlang_parse.y cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libcurses/slave/commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.20 src/tests/lib/libcurses/director/testlang_conf.l:1.21 --- src/tests/lib/libcurses/director/testlang_conf.l:1.20 Sat Feb 13 08:14:46 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Mon Feb 15 07:06:27 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.20 2021/02/13 08:14:46 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.21 2021/02/15 07:06:27 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -223,7 +223,7 @@ include BEGIN(incl); yyterminate(); if (--include_ptr < 0) - err(2, "Include stack underflow"); + errx(2, "Include stack underflow"); free(cur_file); cur_file = include_files[include_ptr]; @@ -260,7 +260,7 @@ include BEGIN(incl); unsigned long val; if (sscanf(yytext, "%lx", ) != 1) -err(1, "Bad hex conversion"); +errx(1, "Bad hex conversion"); asprintf(, "%ld", val); return numeric; Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.47 src/tests/lib/libcurses/director/testlang_parse.y:1.48 --- src/tests/lib/libcurses/director/testlang_parse.y:1.47 Sat Feb 13 08:43:03 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Mon Feb 15 07:06:27 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.47 2021/02/13 08:43:03 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.48 2021/02/15 07:06:27 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -501,10 +501,10 @@ get_numeric_var(const char *var) int i; if ((i = find_var_index(var)) < 0) - err(1, "Variable %s is undefined", var); + errx(1, "Variable %s is undefined", var); if (vars[i].type != data_number) - err(1, "Variable %s is not a numeric type", var); + errx(1, "Variable %s is not a numeric type", var); return vars[i].value; } @@ -591,7 +591,7 @@ add_to_vals(data_enum_t argtype, void *a case data_var: if ((i = find_var_index((char *) arg)) < 0) - err(1, "%s:%zu: Variable %s is undefined", + errx(1, "%s:%zu: Variable %s is undefined", cur_file, line, (const char *) arg); switch (vars[i].type) { @@ -603,7 +603,8 @@ add_to_vals(data_enum_t argtype, void *a break; default: - err(1, "%s:%zu: Variable %s has invalid type for cchar", + errx(1, + "%s:%zu: Variable %s has invalid type for cchar", cur_file, line, (const char *) arg); break; @@ -611,7 +612,7 @@ add_to_vals(data_enum_t argtype, void *a break; default: - err(1, "%s:%zu: Internal error: Unhandled type for vals array", + errx(1, "%s:%zu: Internal error: Unhandled type for vals array", cur_file, line); /* if we get here without a value then tidy up */ @@ -670,7 +671,7 @@ set_cchar(char *name, void *attributes) attr_t attribs; if (nvals >= CURSES_CCHAR_MAX) - err(1, "%s:%zu: %s: too many characters in complex char type", + errx(1, "%s:%zu: %s: too many characters in complex char type", cur_file, line, __func__); i = find_var_index(name); @@ -678,7 +679,8 @@ set_cchar(char *name, void *attributes) i = assign_var(name); if (sscanf((char *) attributes, "%d", ) != 1) - err(1, "%s:%zu: %s: conversion of attributes to integer failed", + errx(1, + "%s:%zu: %s: conversion of attributes to integer failed", cur_file, line, __func__); vars[i].type = data_cchar; @@ -826,7 +828,7 @@ assign_rets(data_enum_t ret_type, void * cur.data_len); } else if (ret_type == data_ref) { if ((cur.data_index = find_var_index(ret)) < 0) -err(1, "Undefined variable reference"); +errx(1, "Undefined variable reference"); } } else { cur.data_index = find_var_index(ret); @@ -902,18 +904,18 @@ compare_streams(const char *filename, bo if (filename[0] != '/') { if (strlcpy(check_file, check_path, sizeof(check_file)) >= sizeof(check_file)) - err(2, "CHECK_PATH too long"); + errx(2, "CHECK_PATH too long"); if (strlcat(check_file, "/", sizeof(check_file)) >= sizeof(check_file)) - err(2, "Could not append / to check file path"); + errx(2, "Could not append / to check file path"); } else {
CVS commit: src/tests/lib/libcurses/tests
Module Name:src Committed By: rillig Date: Sun Feb 14 11:21:37 UTC 2021 Modified Files: src/tests/lib/libcurses/tests: addch Log Message: tests/libcurses: document the history about tab bugs in addch/addstr Verified by installing all versions of libcurses from 2012 to 2021 and running a simple test program on them: #include #include int main(int argc, char **argv) { int xstr, ystr, xch, ych; initscr(); addstr("\t"); xstr = getcurx(stdscr); addstr("\n"); ystr = getcury(stdscr); addch('\t'); xch = getcurx(stdscr); addch('\n'); ych = getcury(stdscr); endwin(); fprintf(stderr, "%s\t%d,%d\t%d,%d\n", argv[1], ystr, xstr, ych, xch); } Some selected outputs: ... 2016.11.24.14.49.08 1,0 2,8 2016.11.28.18.25.26 1,8 2,8 ... 2019.05.12.02.29.00 1,8 2,8 2019.05.20.22.17.41 1,8 2,16 ... 2021.02.13.10.37.00 1,8 2,16 2021.02.13.14.30.37 1,8 2,8 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/tests/addch Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/tests/addch diff -u src/tests/lib/libcurses/tests/addch:1.6 src/tests/lib/libcurses/tests/addch:1.7 --- src/tests/lib/libcurses/tests/addch:1.6 Sat Feb 13 14:30:37 2021 +++ src/tests/lib/libcurses/tests/addch Sun Feb 14 11:21:37 2021 @@ -1,3 +1,18 @@ +# $NetBSD: addch,v 1.7 2021/02/14 11:21:37 rillig Exp $ +# +# Between at least 2012 and 2016, addstr did not advance win->curx for a '\t', +# but addch did. This was inconsistent. +# +# On 2016.11.28.18.25.26 on NetBSD 7.99.43, this inconsistency was fixed. +# Now both functions advanced win->curx. +# +# On 2019.05.20.22.17.41 on NetBSD 8.99.41, the fix was modified, which +# introduced another inconsistency. Since then, addstr advanced win->curx as +# expected, but addch advanced it by twice the amount. +# +# On 2021.02.13.14.30.37 on NetBSD 9.99.80, this inconsistency was fixed. +# Now both functions advanced win->curx again. + include start call OK addch `\001t` call OK refresh @@ -5,17 +20,11 @@ call OK mvaddch 5 3 `\003e` call OK refresh call OK addch `\000\n` -# Somewhere between NetBSD 8.0 and 9.0, a bug was added to addch that -# doubled the spaces for a tab. Instead of 8 spaces, there were 16. -# Fixed in NetBSD 9.99.80. call OK addch `\000\t` call2 6 8 getyx STDSCR call OK addch `\0008` call OK addch `\000\n` -# Somewhere between NetBSD 8.0 and 9.0, a bug was added to addch that -# doubled the spaces for a tab. Instead of 1 space, there were 2. -# Fixed in NetBSD 9.99.80. call OK addstr "0123456" call OK addch `\000\t` call2 7 8 getyx STDSCR
CVS commit: src/tests/lib/libcurses/tests
Module Name:src Committed By: rillig Date: Sat Feb 13 22:19:47 UTC 2021 Modified Files: src/tests/lib/libcurses/tests: addbytes Log Message: tests/libcurses: note that addbytes is not part of the API https://mail-index.netbsd.org/source-changes-d/2021/02/13/msg013199.html To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/tests/addbytes Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/tests/addbytes diff -u src/tests/lib/libcurses/tests/addbytes:1.1 src/tests/lib/libcurses/tests/addbytes:1.2 --- src/tests/lib/libcurses/tests/addbytes:1.1 Sat Feb 13 06:29:45 2021 +++ src/tests/lib/libcurses/tests/addbytes Sat Feb 13 22:19:47 2021 @@ -1,6 +1,9 @@ -# $NetBSD: addbytes,v 1.1 2021/02/13 06:29:45 rillig Exp $ +# $NetBSD: addbytes,v 1.2 2021/02/13 22:19:47 rillig Exp $ # # Tests adding bytes to stdscr. +# +# Note that addbytes is not part of the official curses API, it is merely +# an internal helper function. include start
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sat Feb 13 19:23:11 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: commands.c Log Message: tests/libcurses: protect against short writes The previous code only errored out if a write failed completely. If it was partially written, the program continued without writing the rest of it. Extract the common code into a few functions that write raw data to the parent process. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/commands.c diff -u src/tests/lib/libcurses/slave/commands.c:1.12 src/tests/lib/libcurses/slave/commands.c:1.13 --- src/tests/lib/libcurses/slave/commands.c:1.12 Sat Feb 13 08:14:46 2021 +++ src/tests/lib/libcurses/slave/commands.c Sat Feb 13 19:23:11 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.12 2021/02/13 08:14:46 rillig Exp $ */ +/* $NetBSD: commands.c,v 1.13 2021/02/13 19:23:11 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -42,8 +42,7 @@ extern int initdone; -static void report_type(data_enum_t); -static void report_message(int, const char *); +static void report_message(data_enum_t, const char *); /* * Match the passed command string and execute the associated test @@ -85,6 +84,29 @@ command_execute(char *func, int nargs, c report_status("UNKNOWN_FUNCTION"); } +static void +write_to_director(const void *mem, size_t size) +{ + ssize_t nwritten = write(to_director, mem, size); + if (nwritten == -1) + err(1, "writing to director failed"); + if ((size_t)nwritten != size) + err(1, "short write to director, expected %zu, got %zd", + size, nwritten); +} + +static void +write_to_director_int(int i) +{ + write_to_director(, sizeof i); +} + +static void +write_to_director_type(data_enum_t return_type) +{ + write_to_director_int(return_type); +} + /* * Report an pointer value back to the director */ @@ -121,9 +143,9 @@ void report_return(int status) { if (status == ERR) - report_type(data_err); + write_to_director_type(data_err); else if (status == OK) - report_type(data_ok); + write_to_director_type(data_ok); else if (status == KEY_CODE_YES) report_int(status); else @@ -131,33 +153,13 @@ report_return(int status) } /* - * Report the type back to the director via the command pipe - */ -static void -report_type(data_enum_t return_type) -{ - int type; - - type = return_type; - if (write(to_director, , sizeof(int)) < 0) - err(1, "command pipe write for status type failed"); - -} - -/* * Report the number of returns back to the director via the command pipe */ void report_count(int count) { - int type; - - type = data_count; - if (write(to_director, , sizeof(int)) < 0) - err(1, "command pipe write for count type failed"); - - if (write(to_director, , sizeof(int)) < 0) - err(1, "command pipe write for count"); + write_to_director_type(data_count); + write_to_director_int(count); } /* @@ -183,20 +185,12 @@ report_error(const char *status) * command pipe. */ static void -report_message(int type, const char *status) +report_message(data_enum_t type, const char *status) { - int len; - - len = strlen(status); - - if (write(to_director, , sizeof(int)) < 0) - err(1, "command pipe write for message type failed"); - - if (write(to_director, , sizeof(int)) < 0) - err(1, "command pipe write for message length failed"); - - if (write(to_director, status, len) < 0) - err(1, "command pipe write of message data failed"); + size_t len = strlen(status); + write_to_director_type(type); + write_to_director_int(len); + write_to_director(status, len); } /* @@ -218,31 +212,17 @@ report_byte(chtype c) void report_nstr(chtype *string) { - int len, type; + size_t size; chtype *p; - len = 0; - p = string; + for (p = string; (*p & __CHARTEXT) != 0; p++) + continue; - while ((*p++ & __CHARTEXT) != 0) { - len++; - } + size = (size_t)(p + 1 - string) * sizeof *p; - len++; /* add in the termination chtype */ - len *= sizeof(chtype); - - type = data_byte; - if (write(to_director, , sizeof(int)) < 0) - err(1, "%s: command pipe write for status type failed", - __func__); - - if (write(to_director, , sizeof(int)) < 0) - err(1, "%s: command pipe write for status length failed", - __func__); - - if (write(to_director, string, len) < 0) - err(1, "%s: command pipe write of status data failed", - __func__); + write_to_director_type(data_byte); + write_to_director_int(size); + write_to_director(string, size); } /* @@ -251,21 +231,10 @@ report_nstr(chtype *string) void report_cchar(cchar_t c) { - int len, type; - len = sizeof(cchar_t); - type = data_cchar; - - if (write(to_director, , sizeof(int)) < 0) - err(1, "%s: command pipe write for status type failed", - __func__); - - if (write(to_director, , sizeof(int))
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sat Feb 13 18:24:11 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: lint.lua Log Message: tests/libcurses: remove unused code in linter To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/slave/lint.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/lint.lua diff -u src/tests/lib/libcurses/slave/lint.lua:1.1 src/tests/lib/libcurses/slave/lint.lua:1.2 --- src/tests/lib/libcurses/slave/lint.lua:1.1 Fri Feb 12 20:41:37 2021 +++ src/tests/lib/libcurses/slave/lint.lua Sat Feb 13 18:24:11 2021 @@ -1,5 +1,5 @@ #! /usr/bin/lua --- $NetBSD: lint.lua,v 1.1 2021/02/12 20:41:37 rillig Exp $ +-- $NetBSD: lint.lua,v 1.2 2021/02/13 18:24:11 rillig Exp $ --[[ @@ -83,15 +83,6 @@ local function check_args(errors) end -local function check_file(fname, msgs) - local errors = collect_errors(fname, msgs) - for _, err in ipairs(errors) do -print(err) - end - return #errors == 0 -end - - local function main(arg) local errors = new_errors() check_args(errors)
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 13 16:43:12 UTC 2021 Modified Files: src/tests/lib/libcurses: atf.terminfo Log Message: tests/libcurses: use ASCII only in terminfo description To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/atf.terminfo Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/atf.terminfo diff -u src/tests/lib/libcurses/atf.terminfo:1.2 src/tests/lib/libcurses/atf.terminfo:1.3 --- src/tests/lib/libcurses/atf.terminfo:1.2 Sat Feb 13 16:38:02 2021 +++ src/tests/lib/libcurses/atf.terminfo Sat Feb 13 16:43:12 2021 @@ -1,4 +1,4 @@ -# $NetBSD: atf.terminfo,v 1.2 2021/02/13 16:38:02 rillig Exp $ +# $NetBSD: atf.terminfo,v 1.3 2021/02/13 16:43:12 rillig Exp $ # # Based on xterm capabilities # @@ -29,12 +29,12 @@ atf|Automated Test Framework pseudo term csr=csr%i%p1%d;%p2%dX, cub=cub%p1%dX, cub1=^H, cud=cud%p1%dX, cud1=^J, - cuf=cuf%p1%dX, cuf1=, + cuf=cuf%p1%dX, cuf1=^F, cup=cup%i%p1%d;%p2%dX, - cuu=cuu%p1%dX, cuu1=, + cuu=cuu%p1%dX, cuu1=^U, cvvis=cvvis, - dch=dch%p1%dX, dch1=, - dl=dl%p1%dX, dl1=, + dch=dch%p1%dX, dch1=^D, + dl=dl%p1%dX, dl1=^K, dim=dim, ech=ech%p1%dX, ed=ed,
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 13 16:38:02 UTC 2021 Modified Files: src/tests/lib/libcurses: atf.terminfo Log Message: tests/libcurses: split terminfo entry over more lines This provides space to see each capability on its own, instead of having to search them in the blob of text. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/atf.terminfo Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/atf.terminfo diff -u src/tests/lib/libcurses/atf.terminfo:1.1 src/tests/lib/libcurses/atf.terminfo:1.2 --- src/tests/lib/libcurses/atf.terminfo:1.1 Sun Apr 10 09:55:08 2011 +++ src/tests/lib/libcurses/atf.terminfo Sat Feb 13 16:38:02 2021 @@ -1,44 +1,134 @@ +# $NetBSD: atf.terminfo,v 1.2 2021/02/13 16:38:02 rillig Exp $ +# # Based on xterm capabilities -atf|atf automatic test frame pseudo terminal, - am, bce, ccc, km, mc5i, mir, msgr, npc, xenl, - colors#8, cols#80, it#8, lines#24, pairs#64, +# +atf|Automated Test Framework pseudo terminal, + am, + bce, + ccc, + km, + mc5i, + mir, + msgr, + npc, + xenl, + colors#8, + cols#80, + it#8, + lines#24, + pairs#64, acsc=++\,\,--..00``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, - bel=bel, blink=blink, bold=bold, cbt=cbt, civis=civis, clear=clear, - cnorm=cnorm, cr=^M, csr=csr%i%p1%d;%p2%dX, cub=cub%p1%dX, - cub1=^H, cud=cud%p1%dX, cud1=^J, cuf=cuf%p1%dX, cuf1=, - cup=cup%i%p1%d;%p2%dX, cuu=cuu%p1%dX, cuu1=, cvvis=cvvis, - dch=dch%p1%dX, dch1=, dl=dl%p1%dX, dl1=, dim=dim, ech=ech%p1%dX, - ed=ed, el=el, el1=el1, enacs=enacs, flash=flash, home=home, - hpa=hpa%i%p1%dX, ht=^I, hts=hts, ich=ich%p1%dX, il=il%p1%dX, - il1=il1, ind=^M, indn=indn%p1%dX, invis=invis, - is2=is2, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, - kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, - kRIT=\E[1;2C, kb2=\EOE, kbs=^H, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, - kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kent=\EOM, - kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P, - kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, - kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, - kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, - kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, - kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, - kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, - kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS, - kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, - kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, - kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, - kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, - kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, - kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P, - kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, - khome=\EOH, kich1=\E[2~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~, - kpp=\E[5~, kri=\E[1;2A, mc0=mc0, mc4=mc4, mc5=mc5, - op=op, rc=rc, rev=rev, ri=ri, rin=rin%p1%dX, rmacs=rmacs, - rmam=rmam, rmcup=rmcup, rmir=rmir, rmkx=rmkx, - rmm=rmm, rmso=rmso, rmul=rmul, rs1=rs1, - rs2=rs2, sc=sc, setab=setab%p1%dX, - setaf=setaf%p1%dX, setb=setb%p1%dX, setf=setf%p1%dX, + bel=bel, + blink=blink, + bold=bold, + cbt=cbt, + civis=civis, + clear=clear, + cnorm=cnorm, + cr=^M, + csr=csr%i%p1%d;%p2%dX, + cub=cub%p1%dX, cub1=^H, + cud=cud%p1%dX, cud1=^J, + cuf=cuf%p1%dX, cuf1=, + cup=cup%i%p1%d;%p2%dX, + cuu=cuu%p1%dX, cuu1=, + cvvis=cvvis, + dch=dch%p1%dX, dch1=, + dl=dl%p1%dX, dl1=, + dim=dim, + ech=ech%p1%dX, + ed=ed, + el=el, + el1=el1, + enacs=enacs, + flash=flash, + home=home, + hpa=hpa%i%p1%dX, + ht=^I, + hts=hts, + ich=ich%p1%dX, + il=il%p1%dX, il1=il1, + ind=^M, + indn=indn%p1%dX, + invis=invis, + is2=is2, + kDC=\E[3;2~, + kEND=\E[1;2F, + kHOM=\E[1;2H, + kIC=\E[2;2~, + kLFT=\E[1;2D, + kNXT=\E[6;2~, + kPRV=\E[5;2~, + kRIT=\E[1;2C, + kb2=\EOE, + kbs=^H, + kcbt=\E[Z, + kcub1=\EOD, + kcud1=\EOB, + kcuf1=\EOC, + kcuu1=\EOA, + kdch1=\E[3~, + kend=\EOF, + kent=\EOM, + kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, + kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, + kf9=\E[20~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, + kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, + kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf20=\E[19;2~, + kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, + kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, + kf29=\E[15;5~, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, + kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, + kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf40=\E[1;6S, + kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, + kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, + kf49=\E[1;3P, kf50=\E[1;3Q, kf51=\E[1;3R, kf52=\E[1;3S, + kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, + kf57=\E[20;3~, kf58=\E[21;3~,
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sat Feb 13 10:03:49 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: slave.c Log Message: tests/libcurses: extract read_command_argument from process_commands Having code indented so far to the right that each word gets its own line is ridiculous. Fix that. While here, remove the cargo-cult realloc pattern, which is not needed if the process exits immediately on error. While here, reduce the indentation of the code by returning early. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/slave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/slave.c diff -u src/tests/lib/libcurses/slave/slave.c:1.15 src/tests/lib/libcurses/slave/slave.c:1.16 --- src/tests/lib/libcurses/slave/slave.c:1.15 Sat Feb 13 09:28:27 2021 +++ src/tests/lib/libcurses/slave/slave.c Sat Feb 13 10:03:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slave.c,v 1.15 2021/02/13 09:28:27 rillig Exp $ */ +/* $NetBSD: slave.c,v 1.16 2021/02/13 10:03:49 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -76,6 +76,50 @@ read_from_director(void *data, size_t n) n, (size_t)nread); } +static bool +read_command_argument(char ***pargs, int argslen) +{ + int type, len; + char **args = *pargs; + + read_from_director(, sizeof type); + read_from_director(, sizeof len); + if (len < 0) + return false; + + args = realloc(args, (argslen + 1) * sizeof args[0]); + if (args == NULL) + err(1, "slave realloc of args array failed"); + *pargs = args; + + if (type != data_null) { + args[argslen] = malloc(len + 1); + + if (args[argslen] == NULL) + err(1, "slave alloc of %d bytes for args failed", len); + } + + if (len == 0) { + if (type == data_null) + args[argslen] = NULL; + else + args[argslen][0] = '\0'; + } else { + read_from_director(args[argslen], len); + if (type != data_byte) + args[argslen][len] = '\0'; + + if (len == 6 && strcmp(args[argslen], "STDSCR") == 0) { + char *stdscr_buf; + if (asprintf(_buf, "%p", stdscr) < 0) +err(2, "asprintf of stdscr failed"); + free(args[argslen]); + args[argslen] = stdscr_buf; + } + } + return true; +} + /* * Read the command pipe for the function to execute, gather the args * and then process the command. @@ -83,8 +127,8 @@ read_from_director(void *data, size_t n) static void process_commands(void) { - int len, maxlen, argslen, i, ret, type; - char *cmdbuf, *tmpbuf, **args, **tmpargs; + int len, maxlen, argslen, i, type; + char *cmdbuf, *tmpbuf, **args; len = maxlen = 30; if ((cmdbuf = malloc(maxlen)) == NULL) @@ -109,54 +153,8 @@ process_commands(void) argslen = 0; args = NULL; - do { - read_from_director(, sizeof type); - read_from_director(, sizeof len); - - if (len >= 0) { -tmpargs = realloc(args, -(argslen + 1) * sizeof(char *)); -if (tmpargs == NULL) - err(1, "slave realloc of args array " - "failed"); - -args = tmpargs; -if (type != data_null) { - args[argslen] = malloc(len + 1); - - if (args[argslen] == NULL) - err(1, "slave alloc of %d bytes" - " for args failed", len); -} - -if (len == 0) { - if (type == data_null) - args[argslen] = NULL; - else - args[argslen][0] = '\0'; -} else { - read_from_director(args[argslen], len); - if (type != data_byte) - args[argslen][len] = '\0'; - - if (len == 6) { - if (strcmp(args[argslen], - "STDSCR") == 0) { - ret = asprintf(, - "%p", - stdscr); - if (ret < 0) -err(2, -"asprintf of stdscr failed"); - free(args[argslen]); - args[argslen] = tmpbuf; - } - } -} - -argslen++; - } - } while (len >= 0); + while (read_command_argument(, argslen)) + argslen++; command_execute(cmdbuf, argslen, args);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sat Feb 13 09:28:27 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: slave.c Log Message: tests/libcurses: fix reading from the parent process In case of a short read, processing the incomplete data invoked undefined behavior. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/slave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/slave.c diff -u src/tests/lib/libcurses/slave/slave.c:1.14 src/tests/lib/libcurses/slave/slave.c:1.15 --- src/tests/lib/libcurses/slave/slave.c:1.14 Sat Feb 13 09:18:12 2021 +++ src/tests/lib/libcurses/slave/slave.c Sat Feb 13 09:28:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slave.c,v 1.14 2021/02/13 09:18:12 rillig Exp $ */ +/* $NetBSD: slave.c,v 1.15 2021/02/13 09:28:27 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,31 @@ static const char *returns_enum_names[] }; #endif +static bool +try_read_from_director(void *data, size_t n) +{ + ssize_t nread = read(from_director, data, n); + if (nread < 0) + err(2, "error reading from command pipe"); + if (nread == 0) + return false; + if ((size_t)nread != n) + errx(2, "short read from command pipe: expected %zu, got %zu", + n, (size_t)nread); + return true; +} + +static void +read_from_director(void *data, size_t n) +{ + ssize_t nread = read(from_director, data, n); + if (nread < 0) + err(2, "error reading from command pipe"); + if ((size_t)nread != n) + errx(2, "short read from command pipe: expected %zu, got %zu", + n, (size_t)nread); +} + /* * Read the command pipe for the function to execute, gather the args * and then process the command. @@ -59,23 +85,16 @@ process_commands(void) { int len, maxlen, argslen, i, ret, type; char *cmdbuf, *tmpbuf, **args, **tmpargs; - ssize_t nread; len = maxlen = 30; if ((cmdbuf = malloc(maxlen)) == NULL) err(1, "slave cmdbuf malloc failed"); - for (;;) { - if ((nread = read(from_director, , sizeof(int))) < 0) - err(1, "slave command type read failed"); - if (nread == 0) - break; - + while (try_read_from_director(, sizeof type)) { if (type != data_string) errx(1, "Unexpected type for command, got %d", type); - if (read(from_director, , sizeof(int)) < 0) - err(1, "slave command len read failed"); + read_from_director(, sizeof len); if ((len + 1) > maxlen) { maxlen = len + 1; @@ -85,18 +104,14 @@ process_commands(void) cmdbuf = tmpbuf; } - if (read(from_director, cmdbuf, len) < 0) - err(1, "slave command read failed"); + read_from_director(cmdbuf, len); cmdbuf[len] = '\0'; argslen = 0; args = NULL; do { - if (read(from_director, , sizeof(int)) < 0) -err(1, "slave arg type read failed"); - - if (read(from_director, , sizeof(int)) < 0) -err(1, "slave arg len read failed"); + read_from_director(, sizeof type); + read_from_director(, sizeof len); if (len >= 0) { tmpargs = realloc(args, @@ -120,8 +135,7 @@ process_commands(void) else args[argslen][0] = '\0'; } else { - read(from_director, args[argslen], - len); + read_from_director(args[argslen], len); if (type != data_byte) args[argslen][len] = '\0';
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 13 09:18:12 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c src/tests/lib/libcurses/slave: slave.c Log Message: tests/libcurses: fix child process handling The child process needs to be properly controlled by the parent process. Otherwise it is not possible to get code coverage data from it using gcov since that requires the child process to exit normally. Previously the child process had been killed because its parent had exited. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libcurses/director/director.c cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libcurses/slave/slave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.27 src/tests/lib/libcurses/director/director.c:1.28 --- src/tests/lib/libcurses/director/director.c:1.27 Sat Feb 13 08:26:12 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 09:18:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.27 2021/02/13 08:26:12 rillig Exp $ */ +/* $NetBSD: director.c,v 1.28 2021/02/13 09:18:12 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -72,7 +73,7 @@ void init_parse_variables(int); /* in te * output in verbose mode, truncating the useful part of the error message. */ static void -slave_died(int param) +slave_died(int signo) { char last_words[256]; size_t count; @@ -276,5 +277,12 @@ main(int argc, char *argv[]) yyparse(); fclose(yyin); + signal(SIGCHLD, SIG_DFL); + (void)close(to_slave); + (void)close(from_slave); + + int status; + (void)waitpid(slave_pid, , 0); + exit(0); } Index: src/tests/lib/libcurses/slave/slave.c diff -u src/tests/lib/libcurses/slave/slave.c:1.13 src/tests/lib/libcurses/slave/slave.c:1.14 --- src/tests/lib/libcurses/slave/slave.c:1.13 Sat Feb 13 08:17:15 2021 +++ src/tests/lib/libcurses/slave/slave.c Sat Feb 13 09:18:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slave.c,v 1.13 2021/02/13 08:17:15 rillig Exp $ */ +/* $NetBSD: slave.c,v 1.14 2021/02/13 09:18:12 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -59,14 +59,17 @@ process_commands(void) { int len, maxlen, argslen, i, ret, type; char *cmdbuf, *tmpbuf, **args, **tmpargs; + ssize_t nread; len = maxlen = 30; if ((cmdbuf = malloc(maxlen)) == NULL) err(1, "slave cmdbuf malloc failed"); for (;;) { - if (read(from_director, , sizeof(int)) < 0) + if ((nread = read(from_director, , sizeof(int))) < 0) err(1, "slave command type read failed"); + if (nread == 0) + break; if (type != data_string) errx(1, "Unexpected type for command, got %d", type);
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sat Feb 13 08:43:03 UTC 2021 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: tests/libcurses: fix error messages To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.46 src/tests/lib/libcurses/director/testlang_parse.y:1.47 --- src/tests/lib/libcurses/director/testlang_parse.y:1.46 Sat Feb 13 08:14:46 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Sat Feb 13 08:43:03 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.46 2021/02/13 08:14:46 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.47 2021/02/13 08:43:03 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -767,7 +767,7 @@ assign_arg(data_enum_t arg_type, void *a if (cur.arg_type == data_var) { cur.var_index = find_var_index(arg); if (cur.var_index < 0) - err(1, "%s:%zu: Invalid variable %s", + errx(1, "%s:%zu: Invalid variable %s", cur_file, line, str); } else if (cur.arg_type == data_byte) { ret = arg; @@ -1085,7 +1085,7 @@ do_function_call(size_t nresults) */ read_cmd_pipe(_count); if (returns_count.data_type != data_count) - err(2, "expected return type of data_count but received %s", + errx(2, "expected return type of data_count but received %s", enum_names[returns_count.data_type]); perform_delay(_post_call); /* let slave catch up */
CVS commit: src/tests/lib/libcurses/tests
Module Name:src Committed By: rillig Date: Sat Feb 13 08:37:21 UTC 2021 Modified Files: src/tests/lib/libcurses/tests: mvwin Log Message: tests/libcurses: "fix" test mvwin The test mvwin previously expected an endless stream of bytes, by comparing the actual output with /dev/zero. This didn't make sense as the curses output does not contain '\0' in any of the test cases. Compare with /dev/null instead. This is as wrong as before, but the curses test framework currently ignores this situation, as for many other test cases. See the numerous "Excess" messages in atf-run.log. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/tests/mvwin Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/tests/mvwin diff -u src/tests/lib/libcurses/tests/mvwin:1.1 src/tests/lib/libcurses/tests/mvwin:1.2 --- src/tests/lib/libcurses/tests/mvwin:1.1 Sun Apr 10 09:55:10 2011 +++ src/tests/lib/libcurses/tests/mvwin Sat Feb 13 08:37:21 2021 @@ -2,11 +2,11 @@ include window call OK wmove $win1 1 1 call OK wprintw $win1 "%s" "" call OK wrefresh $win1 -compare /dev/zero +compare /dev/null call OK refresh -compare /dev/zero +compare /dev/null call OK mvwin $win1 4 7 call OK wrefresh $win1 -compare /dev/zero +compare /dev/null call OK refresh -compare /dev/zero +compare /dev/null
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sat Feb 13 08:26:12 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c Log Message: tests/libcurses: remove undocumented, unused command line option The option -T has the same effect as the removed option -p. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libcurses/director/director.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.26 src/tests/lib/libcurses/director/director.c:1.27 --- src/tests/lib/libcurses/director/director.c:1.26 Sat Feb 13 08:22:34 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 08:26:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.26 2021/02/13 08:22:34 rillig Exp $ */ +/* $NetBSD: director.c,v 1.27 2021/02/13 08:26:12 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -138,7 +138,7 @@ main(int argc, char *argv[]) verbose = 0; check_file_flag = 0; - while ((ch = getopt(argc, argv, "vgfC:p:s:t:T:")) != -1) { + while ((ch = getopt(argc, argv, "vgfC:s:t:T:")) != -1) { switch (ch) { case 'C': check_path = optarg; @@ -146,9 +146,6 @@ main(int argc, char *argv[]) case 'T': termpath = optarg; break; - case 'p': - termpath = optarg; - break; case 's': slave = optarg; break;
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sat Feb 13 08:22:34 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c Log Message: tests/libcurses: remove include path from usage message The option has been removed a few minutes ago. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libcurses/director/director.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.25 src/tests/lib/libcurses/director/director.c:1.26 --- src/tests/lib/libcurses/director/director.c:1.25 Sat Feb 13 08:14:46 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 08:22:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.25 2021/02/13 08:14:46 rillig Exp $ */ +/* $NetBSD: director.c,v 1.26 2021/02/13 08:22:34 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -114,7 +114,6 @@ usage(void) "file, or a file holding the terminfo description\n"); fprintf(stderr, "-s is the path to the slave executable\n"); fprintf(stderr, "-t is value to set TERM to for the test\n"); - fprintf(stderr, "-I is the directory to include files\n"); fprintf(stderr, "-C is the directory for check-files\n"); fprintf(stderr, "commandfile is a file of test directives\n"); exit(1);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sat Feb 13 08:17:15 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: slave.c slave.h Log Message: tests/libcurses: clean up remaining include guard, comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libcurses/slave/slave.c cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/slave.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/slave.c diff -u src/tests/lib/libcurses/slave/slave.c:1.12 src/tests/lib/libcurses/slave/slave.c:1.13 --- src/tests/lib/libcurses/slave/slave.c:1.12 Sat Feb 13 06:45:42 2021 +++ src/tests/lib/libcurses/slave/slave.c Sat Feb 13 08:17:15 2021 @@ -1,7 +1,8 @@ -/* $NetBSD: slave.c,v 1.12 2021/02/13 06:45:42 rillig Exp $ */ +/* $NetBSD: slave.c,v 1.13 2021/02/13 08:17:15 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn + * Copyright 2021 Roland Illig * * All rights reserved. * @@ -25,9 +26,8 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * */ + #include #include #include Index: src/tests/lib/libcurses/slave/slave.h diff -u src/tests/lib/libcurses/slave/slave.h:1.6 src/tests/lib/libcurses/slave/slave.h:1.7 --- src/tests/lib/libcurses/slave/slave.h:1.6 Sat Feb 13 06:45:42 2021 +++ src/tests/lib/libcurses/slave/slave.h Sat Feb 13 08:17:15 2021 @@ -1,7 +1,8 @@ -/* $NetBSD: slave.h,v 1.6 2021/02/13 06:45:42 rillig Exp $ */ +/* $NetBSD: slave.h,v 1.7 2021/02/13 08:17:15 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn + * Copyright 2021 Roland Illig * * All rights reserved. * @@ -25,11 +26,10 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * */ -#ifndef CURTEST_SLAVE_H -#define CURTEST_SLAVE_H + +#ifndef CTF_SLAVE_H +#define CTF_SLAVE_H #include
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 13 08:14:46 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c director.h returns.h testlang_conf.l testlang_parse.y src/tests/lib/libcurses/slave: command_table.h commands.c curses_commands.c curses_commands.h Log Message: tests/libcurses: clean up inclusion guards, function declarations No functional change. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/tests/lib/libcurses/director/director.c cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libcurses/director/director.h cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/director/returns.h cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libcurses/director/testlang_conf.l cvs rdiff -u -r1.45 -r1.46 src/tests/lib/libcurses/director/testlang_parse.y cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libcurses/slave/command_table.h \ src/tests/lib/libcurses/slave/curses_commands.h cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libcurses/slave/commands.c cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.24 src/tests/lib/libcurses/director/director.c:1.25 --- src/tests/lib/libcurses/director/director.c:1.24 Sat Feb 13 08:00:07 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 08:14:46 2021 @@ -1,7 +1,8 @@ -/* $NetBSD: director.c,v 1.24 2021/02/13 08:00:07 rillig Exp $ */ +/* $NetBSD: director.c,v 1.25 2021/02/13 08:14:46 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn + * Copyright 2021 Roland Illig * * All rights reserved. * @@ -25,8 +26,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * */ #include Index: src/tests/lib/libcurses/director/director.h diff -u src/tests/lib/libcurses/director/director.h:1.3 src/tests/lib/libcurses/director/director.h:1.4 --- src/tests/lib/libcurses/director/director.h:1.3 Sat Feb 13 07:08:45 2021 +++ src/tests/lib/libcurses/director/director.h Sat Feb 13 08:14:46 2021 @@ -1,8 +1,9 @@ -/* $NetBSD: director.h,v 1.3 2021/02/13 07:08:45 rillig Exp $ */ +/* $NetBSD: director.h,v 1.4 2021/02/13 08:14:46 rillig Exp $ */ /*- * Copyright 2020 Naman Jain , this code was * created as part of the Google Summer of Code 2020. + * Copyright 2021 Roland Illig * * All rights reserved. * @@ -26,11 +27,10 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * */ -#ifndef DIRECTOR_H -#define DIRECTOR_H + +#ifndef CTF_DIRECTOR_H +#define CTF_DIRECTOR_H #define GEN_CHECK_FILE 1 #define FORCE_GEN 2 @@ -38,4 +38,4 @@ extern int to_slave; extern int from_slave; -#endif /* DIRECTOR_H */ +#endif Index: src/tests/lib/libcurses/director/returns.h diff -u src/tests/lib/libcurses/director/returns.h:1.5 src/tests/lib/libcurses/director/returns.h:1.6 --- src/tests/lib/libcurses/director/returns.h:1.5 Mon Feb 8 19:15:20 2021 +++ src/tests/lib/libcurses/director/returns.h Sat Feb 13 08:14:46 2021 @@ -1,7 +1,8 @@ -/* $NetBSD: returns.h,v 1.5 2021/02/08 19:15:20 rillig Exp $ */ +/* $NetBSD: returns.h,v 1.6 2021/02/13 08:14:46 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn + * Copyright 2021 Roland Illig * * All rights reserved. * @@ -25,12 +26,10 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * */ -#ifndef CTF_RETURNS_H -#define CTF_RETURNS_H 1 +#ifndef CTF_RETURNS_H +#define CTF_RETURNS_H typedef enum { data_number = 1, @@ -66,4 +65,4 @@ typedef struct { char *data; } saved_data_t; -#endif /* CTF_RETURNS_H */ +#endif Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.19 src/tests/lib/libcurses/director/testlang_conf.l:1.20 --- src/tests/lib/libcurses/director/testlang_conf.l:1.19 Sat Feb 13 08:00:07 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Sat Feb 13 08:14:46 2021 @@ -1,8 +1,9 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.19 2021/02/13 08:00:07 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.20 2021/02/13 08:14:46 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn + * Copyright 2021 Roland Illig * * All rights reserved. * @@ -26,8 +27,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 13 08:00:07 UTC 2021 Modified Files: src/tests/lib/libcurses: t_curses.sh src/tests/lib/libcurses/director: director.c testlang_conf.l Log Message: tests/libcurses: remove include path handling All include commands in the current test suite use relative paths. Instead of a fixed include path, interpret the included filename relative to the including file. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/t_curses.sh cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libcurses/director/director.c cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libcurses/director/testlang_conf.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/t_curses.sh diff -u src/tests/lib/libcurses/t_curses.sh:1.22 src/tests/lib/libcurses/t_curses.sh:1.23 --- src/tests/lib/libcurses/t_curses.sh:1.22 Sat Feb 13 06:29:45 2021 +++ src/tests/lib/libcurses/t_curses.sh Sat Feb 13 08:00:07 2021 @@ -25,7 +25,6 @@ r_run() $(atf_get_srcdir)/director $2 \ -T $(atf_get_srcdir) \ -t atf \ - -I $(atf_get_srcdir)/tests \ -C $(atf_get_srcdir)/check_files \ -s $(atf_get_srcdir)/slave $file || atf_fail "test ${file} failed" } Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.23 src/tests/lib/libcurses/director/director.c:1.24 --- src/tests/lib/libcurses/director/director.c:1.23 Sat Feb 13 07:32:19 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 08:00:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.23 2021/02/13 07:32:19 rillig Exp $ */ +/* $NetBSD: director.c,v 1.24 2021/02/13 08:00:07 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -51,7 +51,6 @@ void yyparse(void); #define DEF_SLAVE "./slave" const char *def_check_path = "./"; /* default check path */ -const char *def_include_path = "./"; /* default include path */ extern size_t nvars; /* In testlang_conf.y */ saved_data_t saved_output; /* In testlang_conf.y */ @@ -62,7 +61,6 @@ int verbose; /* control verbosity of t int check_file_flag; /* control check-file generation */ const char *check_path; /* path to prepend to check files for output validation */ -const char *include_path; /* path to prepend to include files */ char *cur_file; /* name of file currently being read */ void init_parse_variables(int); /* in testlang_parse.y */ @@ -142,11 +140,8 @@ main(int argc, char *argv[]) verbose = 0; check_file_flag = 0; - while ((ch = getopt(argc, argv, "vgfC:I:p:s:t:T:")) != -1) { + while ((ch = getopt(argc, argv, "vgfC:p:s:t:T:")) != -1) { switch (ch) { - case 'I': - include_path = optarg; - break; case 'C': check_path = optarg; break; @@ -199,14 +194,6 @@ main(int argc, char *argv[]) check_path = def_check_path; } - if (include_path == NULL) - include_path = getenv("INCLUDE_PATH"); - if ((include_path == NULL) || (include_path[0] == '\0')) { - warnx("$INCLUDE_PATH not set, defaulting to %s", - def_include_path); - include_path = def_include_path; - } - signal(SIGCHLD, slave_died); if (setenv("TERM", term, 1) != 0) Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.18 src/tests/lib/libcurses/director/testlang_conf.l:1.19 --- src/tests/lib/libcurses/director/testlang_conf.l:1.18 Mon Feb 8 23:54:03 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Sat Feb 13 08:00:07 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.18 2021/02/08 23:54:03 rillig Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.19 2021/02/13 08:00:07 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -45,7 +45,6 @@ int yylex(void); extern size_t line; -extern char *include_path; /* from director.c */ extern char *cur_file; /* from director.c */ static int include_stack[MAX_INCLUDES]; @@ -175,7 +174,7 @@ include BEGIN(incl); [ \t]* /* eat the whitespace */ [^ \t\n]+ { /* got the include file name */ - char inc_file[MAXPATHLEN]; + char *inc_file; if (include_ptr > MAX_INCLUDES) { fprintf(stderr, @@ -184,23 +183,27 @@ include BEGIN(incl); exit(2); } - if (yytext[0] != '/') { - if (strlcpy(inc_file, include_path, sizeof(inc_file)) - >= sizeof(inc_file)) -err(2, "CHECK_PATH too long"); - if ((include_path[strlen(include_path) - 1] != '/') && - ((strlcat(inc_file, "/", sizeof(inc_file)) - >= sizeof(inc_file -err(2, "Could not append / to include file path"); + const char *dir_begin; + int dir_len; + if (yytext[0] == '/') { + dir_begin = ""; + dir_len = 0; } else { - inc_file[0] = '\0'; + dir_begin = cur_file; + const char *dir_end = strrchr(cur_file, '/'); + if (dir_end != NULL) { +dir_len = (int)(dir_end + 1 - dir_begin); + } else { +dir_begin = "."; +dir_len = 1; + } } -
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sat Feb 13 07:32:19 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c Log Message: tests/libcurses: align comments To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/tests/lib/libcurses/director/director.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.22 src/tests/lib/libcurses/director/director.c:1.23 --- src/tests/lib/libcurses/director/director.c:1.22 Sat Feb 13 07:31:07 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 07:32:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.22 2021/02/13 07:31:07 rillig Exp $ */ +/* $NetBSD: director.c,v 1.23 2021/02/13 07:32:19 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -53,19 +53,19 @@ void yyparse(void); const char *def_check_path = "./"; /* default check path */ const char *def_include_path = "./"; /* default include path */ -extern size_t nvars; /* In testlang_conf.y */ +extern size_t nvars; /* In testlang_conf.y */ saved_data_t saved_output; /* In testlang_conf.y */ int to_slave; int from_slave; -int master; /* pty to the slave */ -int verbose; /* control verbosity of tests */ +int master; /* pty to the slave */ +int verbose; /* control verbosity of tests */ int check_file_flag; /* control check-file generation */ -const char *check_path; /* path to prepend to check files for output - validation */ +const char *check_path; /* path to prepend to check files for output + validation */ const char *include_path; /* path to prepend to include files */ -char *cur_file; /* name of file currently being read */ +char *cur_file; /* name of file currently being read */ -void init_parse_variables(int); /* in testlang_parse.y */ +void init_parse_variables(int); /* in testlang_parse.y */ /* * Handle the slave exiting unexpectedly, try to recover the exit message
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sat Feb 13 07:31:07 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c Log Message: tests/libcurses: fix misleading usage documentation The check-files are not config files. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/tests/lib/libcurses/director/director.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.21 src/tests/lib/libcurses/director/director.c:1.22 --- src/tests/lib/libcurses/director/director.c:1.21 Sat Feb 13 07:08:45 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 07:31:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.21 2021/02/13 07:08:45 rillig Exp $ */ +/* $NetBSD: director.c,v 1.22 2021/02/13 07:31:07 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -59,7 +59,7 @@ int to_slave; int from_slave; int master; /* pty to the slave */ int verbose; /* control verbosity of tests */ -int check_file_flag; /* control checkfile generation */ +int check_file_flag; /* control check-file generation */ const char *check_path; /* path to prepend to check files for output validation */ const char *include_path; /* path to prepend to include files */ @@ -111,14 +111,14 @@ usage(void) "commandfile\n", getprogname()); fprintf(stderr, " where:\n"); fprintf(stderr, "-v enables verbose test output\n"); - fprintf(stderr, "-g enables check file generation if does not exist\n"); - fprintf(stderr, "-f forces check file generation if -g flag is set\n"); + fprintf(stderr, "-g generates check-files if they do not exist\n"); + fprintf(stderr, "-f overwrites check-files with the actual data\n"); fprintf(stderr, "-T is a directory containing the terminfo.cdb " "file, or a file holding the terminfo description\n"); fprintf(stderr, "-s is the path to the slave executable\n"); fprintf(stderr, "-t is value to set TERM to for the test\n"); fprintf(stderr, "-I is the directory to include files\n"); - fprintf(stderr, "-C is the directory for config files\n"); + fprintf(stderr, "-C is the directory for check-files\n"); fprintf(stderr, "commandfile is a file of test directives\n"); exit(1); }
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sat Feb 13 07:08:45 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c director.h testlang_parse.y Log Message: tests/libcurses: fix pipe handling in the parent process The parent process, like the child process, needs only 2 of the 4 pipe ends. In verbose mode (now at testlang_parse.y:1151 and :1154), both ends of the pipe_from_slave were examined. This looked like a typo and has been fixed to those pipe ends that are relevant to the parent process. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libcurses/director/director.c cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/director/director.h cvs rdiff -u -r1.44 -r1.45 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.20 src/tests/lib/libcurses/director/director.c:1.21 --- src/tests/lib/libcurses/director/director.c:1.20 Sat Feb 13 06:45:42 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 07:08:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.20 2021/02/13 06:45:42 rillig Exp $ */ +/* $NetBSD: director.c,v 1.21 2021/02/13 07:08:45 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -55,8 +55,8 @@ const char *def_include_path = "./"; /* extern size_t nvars; /* In testlang_conf.y */ saved_data_t saved_output; /* In testlang_conf.y */ -int cmdpipe[2]; /* command pipe between director and slave */ -int slvpipe[2]; /* reply pipe back from slave */ +int to_slave; +int from_slave; int master; /* pty to the slave */ int verbose; /* control verbosity of tests */ int check_file_flag; /* control checkfile generation */ @@ -136,6 +136,7 @@ main(int argc, char *argv[]) char *arg1, *arg2; struct termios term_attr; struct stat st; + int pipe_to_slave[2], pipe_from_slave[2]; termpath = term = slave = NULL; verbose = 0; @@ -238,11 +239,13 @@ main(int argc, char *argv[]) munmap(tinfo, (size_t)st.st_size); } - if (pipe(cmdpipe) < 0) + if (pipe(pipe_to_slave) < 0) err(1, "Command pipe creation failed"); + to_slave = pipe_to_slave[1]; - if (pipe(slvpipe) < 0) + if (pipe(pipe_from_slave) < 0) err(1, "Slave pipe creation failed"); + from_slave = pipe_from_slave[0]; /* * Create default termios settings for later use @@ -261,12 +264,12 @@ main(int argc, char *argv[]) if (slave_pid == 0) { /* slave side, just exec the slave process */ - if (asprintf(, "%d", cmdpipe[0]) < 0) + if (asprintf(, "%d", pipe_to_slave[0]) < 0) err(1, "arg1 conversion failed"); - close(cmdpipe[1]); + close(pipe_to_slave[1]); - close(slvpipe[0]); - if (asprintf(, "%d", slvpipe[1]) < 0) + close(pipe_from_slave[0]); + if (asprintf(, "%d", pipe_from_slave[1]) < 0) err(1, "arg2 conversion failed"); if (execl(slave, slave, arg1, arg2, (char *)0) < 0) @@ -275,6 +278,9 @@ main(int argc, char *argv[]) /* NOT REACHED */ } + (void)close(pipe_to_slave[0]); + (void)close(pipe_from_slave[1]); + fcntl(master, F_SETFL, O_NONBLOCK); if ((yyin = fopen(argv[0], "r")) == NULL) Index: src/tests/lib/libcurses/director/director.h diff -u src/tests/lib/libcurses/director/director.h:1.2 src/tests/lib/libcurses/director/director.h:1.3 --- src/tests/lib/libcurses/director/director.h:1.2 Mon Feb 8 19:15:20 2021 +++ src/tests/lib/libcurses/director/director.h Sat Feb 13 07:08:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.h,v 1.2 2021/02/08 19:15:20 rillig Exp $ */ +/* $NetBSD: director.h,v 1.3 2021/02/13 07:08:45 rillig Exp $ */ /*- * Copyright 2020 Naman Jain , this code was @@ -30,9 +30,12 @@ * */ #ifndef DIRECTOR_H -#define DIRECTOR_H 1 +#define DIRECTOR_H #define GEN_CHECK_FILE 1 #define FORCE_GEN 2 +extern int to_slave; +extern int from_slave; + #endif /* DIRECTOR_H */ Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.44 src/tests/lib/libcurses/director/testlang_parse.y:1.45 --- src/tests/lib/libcurses/director/testlang_parse.y:1.44 Tue Feb 9 20:42:31 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Sat Feb 13 07:08:45 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.44 2021/02/09 20:42:31 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.45 2021/02/13 07:08:45 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -51,8 +51,6 @@ extern int verbose; extern int check_file_flag; -extern int cmdpipe[2]; -extern int slvpipe[2]; extern int master; extern struct pollfd readfd; extern char *check_path; @@ -84,9 +82,6 @@ static bool no_input; /* don't need more static wchar_t *vals = NULL; /* wchars to attach to a cchar type */ static unsigned nvals; /* number of wchars */ -#define READ_PIPE 0 -#define WRITE_PIPE 1 - const char *enum_names[]
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sat Feb 13 06:45:42 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c src/tests/lib/libcurses/slave: commands.c slave.c slave.h Log Message: tests/libcurses: fix pipe handling in child process The child process only ever needs 2 ends of the pipes: one for reading the commands, one for writing back the results. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libcurses/director/director.c cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libcurses/slave/commands.c cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libcurses/slave/slave.c cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/slave.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.19 src/tests/lib/libcurses/director/director.c:1.20 --- src/tests/lib/libcurses/director/director.c:1.19 Sat Feb 13 05:38:16 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 06:45:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.19 2021/02/13 05:38:16 rillig Exp $ */ +/* $NetBSD: director.c,v 1.20 2021/02/13 06:45:42 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -133,7 +133,7 @@ main(int argc, char *argv[]) int ch; pid_t slave_pid; extern FILE *yyin; - char *arg1, *arg2, *arg3, *arg4; + char *arg1, *arg2; struct termios term_attr; struct stat st; @@ -263,17 +263,13 @@ main(int argc, char *argv[]) /* slave side, just exec the slave process */ if (asprintf(, "%d", cmdpipe[0]) < 0) err(1, "arg1 conversion failed"); + close(cmdpipe[1]); - if (asprintf(, "%d", cmdpipe[1]) < 0) + close(slvpipe[0]); + if (asprintf(, "%d", slvpipe[1]) < 0) err(1, "arg2 conversion failed"); - if (asprintf(, "%d", slvpipe[0]) < 0) - err(1, "arg3 conversion failed"); - - if (asprintf(, "%d", slvpipe[1]) < 0) - err(1, "arg4 conversion failed"); - - if (execl(slave, slave, arg1, arg2, arg3, arg4, (char *)0) < 0) + if (execl(slave, slave, arg1, arg2, (char *)0) < 0) err(1, "Exec of slave %s failed", slave); /* NOT REACHED */ Index: src/tests/lib/libcurses/slave/commands.c diff -u src/tests/lib/libcurses/slave/commands.c:1.10 src/tests/lib/libcurses/slave/commands.c:1.11 --- src/tests/lib/libcurses/slave/commands.c:1.10 Tue Feb 9 20:42:31 2021 +++ src/tests/lib/libcurses/slave/commands.c Sat Feb 13 06:45:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.10 2021/02/09 20:42:31 rillig Exp $ */ +/* $NetBSD: commands.c,v 1.11 2021/02/13 06:45:42 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -40,8 +40,6 @@ #include "slave.h" #include "command_table.h" -extern int cmdpipe[2]; -extern int slvpipe[2]; extern int initdone; static void report_type(data_enum_t); @@ -141,7 +139,7 @@ report_type(data_enum_t return_type) int type; type = return_type; - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "command pipe write for status type failed"); } @@ -155,10 +153,10 @@ report_count(int count) int type; type = data_count; - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "command pipe write for count type failed"); - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "command pipe write for count"); } @@ -191,13 +189,13 @@ report_message(int type, const char *sta len = strlen(status); - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "command pipe write for message type failed"); - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "command pipe write for message length failed"); - if (write(slvpipe[WRITE_PIPE], status, len) < 0) + if (write(to_director, status, len) < 0) err(1, "command pipe write of message data failed"); } @@ -234,15 +232,15 @@ report_nstr(chtype *string) len *= sizeof(chtype); type = data_byte; - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "%s: command pipe write for status type failed", __func__); - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "%s: command pipe write for status length failed", __func__); - if (write(slvpipe[WRITE_PIPE], string, len) < 0) + if (write(to_director, string, len) < 0) err(1, "%s: command pipe write of status data failed", __func__); } @@ -257,15 +255,15 @@ report_cchar(cchar_t c) len = sizeof(cchar_t); type = data_cchar; - if (write(slvpipe[WRITE_PIPE], , sizeof(int)) < 0) + if (write(to_director, , sizeof(int)) < 0) err(1, "%s: command pipe write for status type failed", __func__); -
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sat Feb 13 05:38:16 UTC 2021 Modified Files: src/tests/lib/libcurses/director: director.c Log Message: tests/libcurses: fix warnings for missing environment variables To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libcurses/director/director.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.18 src/tests/lib/libcurses/director/director.c:1.19 --- src/tests/lib/libcurses/director/director.c:1.18 Tue Feb 9 20:42:31 2021 +++ src/tests/lib/libcurses/director/director.c Sat Feb 13 05:38:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.18 2021/02/09 20:42:31 rillig Exp $ */ +/* $NetBSD: director.c,v 1.19 2021/02/13 05:38:16 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -194,14 +194,14 @@ main(int argc, char *argv[]) if (check_path == NULL) check_path = getenv("CHECK_PATH"); if ((check_path == NULL) || (check_path[0] == '\0')) { - warn("$CHECK_PATH not set, defaulting to %s", def_check_path); + warnx("$CHECK_PATH not set, defaulting to %s", def_check_path); check_path = def_check_path; } if (include_path == NULL) include_path = getenv("INCLUDE_PATH"); if ((include_path == NULL) || (include_path[0] == '\0')) { - warn("$INCLUDE_PATH not set, defaulting to %s", + warnx("$INCLUDE_PATH not set, defaulting to %s", def_include_path); include_path = def_include_path; }
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 21:29:54 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: slave.c Log Message: tests/libcurses: format misleading do-while loop To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libcurses/slave/slave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/slave.c diff -u src/tests/lib/libcurses/slave/slave.c:1.10 src/tests/lib/libcurses/slave/slave.c:1.11 --- src/tests/lib/libcurses/slave/slave.c:1.10 Tue Feb 9 20:42:31 2021 +++ src/tests/lib/libcurses/slave/slave.c Fri Feb 12 21:29:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slave.c,v 1.10 2021/02/09 20:42:31 rillig Exp $ */ +/* $NetBSD: slave.c,v 1.11 2021/02/12 21:29:54 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -64,7 +64,7 @@ process_commands(void) if ((cmdbuf = malloc(maxlen)) == NULL) err(1, "slave cmdbuf malloc failed"); - while (1) { + for (;;) { if (read(cmdpipe[READ_PIPE], , sizeof(int)) < 0) err(1, "slave command type read failed"); @@ -139,8 +139,7 @@ process_commands(void) argslen++; } - } - while (len >= 0); + } while (len >= 0); command_execute(cmdbuf, argslen, args);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 21:29:03 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: command_table.h curses_commands.h Log Message: tests/libcurses: remove wrong comments To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libcurses/slave/command_table.h \ src/tests/lib/libcurses/slave/curses_commands.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/command_table.h diff -u src/tests/lib/libcurses/slave/command_table.h:1.5 src/tests/lib/libcurses/slave/command_table.h:1.6 --- src/tests/lib/libcurses/slave/command_table.h:1.5 Mon Feb 8 19:15:21 2021 +++ src/tests/lib/libcurses/slave/command_table.h Fri Feb 12 21:29:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: command_table.h,v 1.5 2021/02/08 19:15:21 rillig Exp $ */ +/* $NetBSD: command_table.h,v 1.6 2021/02/12 21:29:03 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -430,4 +430,4 @@ struct command_def commands[] = { size_t ncmds = sizeof(commands) / sizeof(struct command_def); -#endif /* _COMMAND_TABLE_H */ +#endif Index: src/tests/lib/libcurses/slave/curses_commands.h diff -u src/tests/lib/libcurses/slave/curses_commands.h:1.5 src/tests/lib/libcurses/slave/curses_commands.h:1.6 --- src/tests/lib/libcurses/slave/curses_commands.h:1.5 Mon Feb 8 19:15:21 2021 +++ src/tests/lib/libcurses/slave/curses_commands.h Fri Feb 12 21:29:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.h,v 1.5 2021/02/08 19:15:21 rillig Exp $ */ +/* $NetBSD: curses_commands.h,v 1.6 2021/02/12 21:29:03 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -458,4 +458,4 @@ void cmd_slk_set(int, char**); void cmd_slk_touch(int, char**); void cmd_slk_wset(int, char**); -#endif /* !_CURSES_COMMAND_H_ */ +#endif
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 20:45:00 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: remove excess empty lines To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.20 src/tests/lib/libcurses/slave/curses_commands.c:1.21 --- src/tests/lib/libcurses/slave/curses_commands.c:1.20 Fri Feb 12 20:41:37 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 20:45:00 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.20 2021/02/12 20:41:37 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.21 2021/02/12 20:45:00 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -971,7 +971,6 @@ cmd_mvinstr(int nargs, char **args) } - void cmd_mvwaddbytes(int nargs, char **args) { @@ -3532,7 +3531,6 @@ cmd_winsstr(int nargs, char **args) } - void cmd_chgat(int nargs, char **args) { @@ -3645,7 +3643,6 @@ cmd_mvwadd_wch(int nargs, char **args) } - void cmd_add_wchnstr(int nargs, char **args) { @@ -3734,7 +3731,6 @@ cmd_mvwadd_wchstr(int nargs, char **args } - void cmd_addnwstr(int nargs, char **args) { @@ -3839,7 +3835,6 @@ cmd_waddwstr(int nargs, char **args) } - void cmd_echo_wchar(int nargs, char **args) { @@ -3875,7 +3870,6 @@ cmd_pecho_wchar(int nargs, char **args) } - /* insert */ void cmd_ins_wch(int nargs, char **args) @@ -3927,7 +3921,6 @@ cmd_mvwins_wch(int nargs, char **args) } - void cmd_ins_nwstr(int nargs, char **args) { @@ -4032,7 +4025,6 @@ cmd_wins_wstr(int nargs, char **args) } - /* input */ void cmd_get_wch(int nargs, char **args) @@ -4102,7 +4094,6 @@ cmd_wget_wch(int nargs, char **args) } - void cmd_getn_wstr(int nargs, char **args) { @@ -4221,7 +4212,6 @@ cmd_wget_wstr(int nargs, char **args) } - void cmd_in_wch(int nargs, char **args) { @@ -4367,7 +4357,6 @@ cmd_win_wchstr(int nargs, char **args) } - void cmd_innwstr(int nargs, char **args) { @@ -4487,7 +4476,6 @@ cmd_winwstr(int nargs, char **args) } - /* cchar handling */ void cmd_setcchar(int nargs, char **args) @@ -4529,7 +4517,6 @@ cmd_getcchar(int nargs, char **args) } - /* misc */ void cmd_key_name(int nargs, char **args)
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 20:41:37 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Added Files: src/tests/lib/libcurses/slave: lint.lua Log Message: tests/libcurses: query function arguments in consistent order To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/lib/libcurses/slave/curses_commands.c cvs rdiff -u -r0 -r1.1 src/tests/lib/libcurses/slave/lint.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.19 src/tests/lib/libcurses/slave/curses_commands.c:1.20 --- src/tests/lib/libcurses/slave/curses_commands.c:1.19 Fri Feb 12 18:20:05 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 20:41:37 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.19 2021/02/12 18:20:05 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.20 2021/02/12 20:41:37 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -150,6 +150,16 @@ set_scrn(char *arg, SCREEN **x) if (set_scrn(args[i], ) != 0)\ return +/* + * Required by the API, intended for future extensions, but this + * implementation does not support the extension. + */ +#define ARG_NULL(i) \ + (void)0 + +#define ARG_IGNORE(i) \ + (void)0 + void cmd_DRAIN(int nargs, char **args) { @@ -391,7 +401,7 @@ cmd_color_set(int nargs, char **args) { ARGC(2); ARG_SHORT(0, colour_pair); - /* TODO: arg 1 */ + ARG_NULL(1); report_count(1); report_return(color_set(colour_pair, NULL)); @@ -1947,8 +1957,8 @@ cmd_mvhline(int nargs, char **args) ARGC(4); ARG_INT(0, y); ARG_INT(1, x); - ARG_INT(3, n); ARG_CHTYPE(2, ch); + ARG_INT(3, n); report_count(1); report_return(mvhline(y, x, ch, n)); @@ -1991,8 +2001,8 @@ cmd_mvvline(int nargs, char **args) ARGC(4); ARG_INT(0, y); ARG_INT(1, x); - ARG_INT(3, n); ARG_CHTYPE(2, ch); + ARG_INT(3, n); report_count(1); report_return(mvvline(y, x, ch, n)); @@ -2006,8 +2016,8 @@ cmd_mvwhline(int nargs, char **args) ARG_WINDOW(0, win); ARG_INT(1, y); ARG_INT(2, x); - ARG_INT(4, n); ARG_CHTYPE(3, ch); + ARG_INT(4, n); report_count(1); report_return(mvwhline(win, y, x, ch, n)); @@ -2021,8 +2031,8 @@ cmd_mvwvline(int nargs, char **args) ARG_WINDOW(0, win); ARG_INT(1, y); ARG_INT(2, x); - ARG_INT(4, n); ARG_CHTYPE(3, ch); + ARG_INT(4, n); report_count(1); report_return(mvwvline(win, y, x, ch, n)); @@ -3007,7 +3017,7 @@ cmd_wcolor_set(int nargs, char **args) ARGC(3); ARG_WINDOW(0, win); ARG_SHORT(1, pair); - /* TODO: arg 2 */ + ARG_NULL(2); report_count(1); report_return(wcolor_set(win, pair, NULL)); @@ -3107,8 +3117,8 @@ cmd_whline(int nargs, char **args) { ARGC(3); ARG_WINDOW(0, win); - ARG_INT(2, count); ARG_CHTYPE(1, ch); + ARG_INT(2, count); report_count(1); report_return(whline(win, ch, count)); @@ -3409,8 +3419,8 @@ cmd_wvline(int nargs, char **args) { ARGC(3); ARG_WINDOW(0, win); - ARG_INT(2, n); ARG_CHTYPE(1, ch); + ARG_INT(2, n); report_count(1); report_return(wvline(win, ch, n)); @@ -3530,8 +3540,8 @@ cmd_chgat(int nargs, char **args) ARG_INT(0, n); ARG_INT(1, attr); ARG_INT(2, colour); + ARG_NULL(3); - /* Note: 4th argument unused in current curses implementation */ report_count(1); report_return(chgat(n, attr, colour, NULL)); } @@ -3545,6 +3555,7 @@ cmd_wchgat(int nargs, char **args) ARG_INT(1, n); ARG_INT(2, attr); ARG_SHORT(3, colour); + ARG_NULL(4); report_count(1); report_return(wchgat(win, n, attr, colour, NULL)); @@ -3560,6 +3571,7 @@ cmd_mvchgat(int nargs, char **args) ARG_INT(2, n); ARG_INT(3, attr); ARG_SHORT(4, colour); + ARG_NULL(5); report_count(1); report_return(mvchgat(y, x, n, attr, colour, NULL)); @@ -3576,6 +3588,7 @@ cmd_mvwchgat(int nargs, char **args) ARG_INT(3, n); ARG_INT(4, attr); ARG_SHORT(5, colour); + ARG_NULL(6); report_count(1); report_return(mvwchgat(win, y, x, n, attr, colour, NULL)); @@ -3637,6 +3650,7 @@ void cmd_add_wchnstr(int nargs, char **args) { ARGC(1); + ARG_IGNORE(0); report_count(1); report_error("UNSUPPORTED"); @@ -3647,6 +3661,7 @@ void cmd_add_wchstr(int nargs, char **args) { ARGC(1); + ARG_IGNORE(0); report_count(1); report_error("UNSUPPORTED"); @@ -3657,6 +3672,7 @@ void cmd_wadd_wchnstr(int nargs, char **args) { ARGC(1); + ARG_IGNORE(0); report_count(1); report_error("UNSUPPORTED"); @@ -3667,6 +3683,7 @@ void cmd_wadd_wchstr(int nargs, char **args) { ARGC(1); + ARG_IGNORE(0); report_count(1); report_error("UNSUPPORTED"); @@ -3677,6 +3694,7 @@ void cmd_mvadd_wchnstr(int nargs, char **args) { ARGC(1); + ARG_IGNORE(0); report_count(1); report_error("UNSUPPORTED"); @@ -3687,6 +3705,7 @@ void cmd_mvadd_wchstr(int nargs, char **args) { ARGC(1); + ARG_IGNORE(0);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 18:20:05 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: don't access args directly By providing declarative syntax for accessing the arguments, the unnecessarily detailed boilerplate code is hidden. This allows easy inspection by tools and humans, to check for typos and other mistakes. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.18 src/tests/lib/libcurses/slave/curses_commands.c:1.19 --- src/tests/lib/libcurses/slave/curses_commands.c:1.18 Fri Feb 12 16:59:32 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 18:20:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.18 2021/02/12 16:59:32 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.19 2021/02/12 18:20:05 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -119,10 +119,23 @@ set_scrn(char *arg, SCREEN **x) return #define ARG_CHTYPE(i, arg) \ - chtype arg = ((chtype *)args[i])[0] + chtype arg = ((const chtype *)args[i])[0] + +#define ARG_WCHAR(i, arg) \ + wchar_t arg = ((const wchar_t *)args[i])[0] + +#define ARG_STRING(i, arg) \ + const char *arg = args[i] + +/* Only used for legacy interfaces that are missing the 'const'. */ +#define ARG_MODIFIABLE_STRING(i, arg) \ + char *arg = args[i] + +#define ARG_CHTYPE_STRING(i, arg) \ + const chtype *arg = (const chtype *)args[i] #define ARG_CCHAR_STRING(i, arg) \ - cchar_t *arg = (cchar_t *)args[i] + const cchar_t *arg = (const cchar_t *)args[i] #define ARG_WCHAR_STRING(i, arg) \ wchar_t *arg = (wchar_t *)args[i] @@ -152,11 +165,11 @@ void cmd_addbytes(int nargs, char **args) { ARGC(2); - /* TODO: arg 0 */ + ARG_STRING(0, str); ARG_INT(1, count); report_count(1); - report_return(addbytes(args[0], count)); + report_return(addbytes(str, count)); } @@ -175,11 +188,11 @@ void cmd_addchnstr(int nargs, char **args) { ARGC(2); - /* TODO: arg 0 */ + ARG_CHTYPE_STRING(0, chstr); ARG_INT(1, count); report_count(1); - report_return(addchnstr((chtype *) args[0], count)); + report_return(addchnstr(chstr, count)); } @@ -187,10 +200,10 @@ void cmd_addchstr(int nargs, char **args) { ARGC(1); - /* TODO: arg 0 */ + ARG_CHTYPE_STRING(0, chstr); report_count(1); - report_return(addchstr((chtype *) args[0])); + report_return(addchstr(chstr)); } @@ -198,11 +211,11 @@ void cmd_addnstr(int nargs, char **args) { ARGC(2); - /* TODO: arg 0 */ + ARG_STRING(0, str); ARG_INT(1, count); report_count(1); - report_return(addnstr(args[0], count)); + report_return(addnstr(str, count)); } @@ -210,10 +223,10 @@ void cmd_addstr(int nargs, char **args) { ARGC(1); - /* TODO: arg 0 */ + ARG_STRING(0, str); report_count(1); - report_return(addstr(args[0])); + report_return(addstr(str)); } @@ -684,11 +697,11 @@ cmd_waddbytes(int nargs, char **args) { ARGC(3); ARG_WINDOW(0, win); - /* TODO: arg 1 */ + ARG_STRING(1, str); ARG_INT(2, count); report_count(1); - report_return(waddbytes(win, args[1], count)); + report_return(waddbytes(win, str, count)); } @@ -697,10 +710,10 @@ cmd_waddstr(int nargs, char **args) { ARGC(2); ARG_WINDOW(0, win); - /* TODO: arg 1 */ + ARG_STRING(1, str); report_count(1); - report_return(waddstr(win, args[1])); + report_return(waddstr(win, str)); } @@ -710,11 +723,11 @@ cmd_mvaddbytes(int nargs, char **args) ARGC(4); ARG_INT(0, y); ARG_INT(1, x); - /* TODO: arg 2 */ + ARG_STRING(2, str); ARG_INT(3, count); report_count(1); - report_return(mvaddbytes(y, x, args[2], count)); + report_return(mvaddbytes(y, x, str, count)); } @@ -737,11 +750,11 @@ cmd_mvaddchnstr(int nargs, char **args) ARGC(4); ARG_INT(0, y); ARG_INT(1, x); - /* TODO: arg 2 */ + ARG_CHTYPE_STRING(2, chstr); ARG_INT(3, count); report_count(1); - report_return(mvaddchnstr(y, x, (chtype *) args[2], count)); + report_return(mvaddchnstr(y, x, chstr, count)); } @@ -751,10 +764,10 @@ cmd_mvaddchstr(int nargs, char **args) ARGC(3); ARG_INT(0, y); ARG_INT(1, x); - /* TODO: arg 2 */ + ARG_CHTYPE_STRING(2, chstr); report_count(1); - report_return(mvaddchstr(y, x, (chtype *) args[2])); + report_return(mvaddchstr(y, x, chstr)); } @@ -764,11 +777,11 @@ cmd_mvaddnstr(int nargs, char **args) ARGC(4); ARG_INT(0, y); ARG_INT(1, x); - /* TODO: arg 2 */ + ARG_STRING(2, str); ARG_INT(3, count); report_count(1); - report_return(mvaddnstr(y, x, args[2], count)); + report_return(mvaddnstr(y, x, str, count)); } @@ -778,10 +791,10 @@ cmd_mvaddstr(int nargs, char **args) ARGC(3); ARG_INT(0, y); ARG_INT(1, x); - /* TODO: arg 2 */ +
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 16:59:32 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: replace ARG_CHTYPE_STRING with ARG_CHTYPE All uses of the previous macro did not treat the argument as a string or array of chtype, but as a single chtype. It's strange that the previous code arbitrarily split the access to the argument by first storing it as a pointer and then dereferencing it. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.17 src/tests/lib/libcurses/slave/curses_commands.c:1.18 --- src/tests/lib/libcurses/slave/curses_commands.c:1.17 Fri Feb 12 16:49:18 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 16:59:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.17 2021/02/12 16:49:18 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.18 2021/02/12 16:59:32 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -118,8 +118,8 @@ set_scrn(char *arg, SCREEN **x) if (set_uint(args[i], ) != 0)\ return -#define ARG_CHTYPE_STRING(i, arg) \ - chtype *arg = (chtype *)args[i] +#define ARG_CHTYPE(i, arg) \ + chtype arg = ((chtype *)args[i])[0] #define ARG_CCHAR_STRING(i, arg) \ cchar_t *arg = (cchar_t *)args[i] @@ -164,10 +164,10 @@ void cmd_addch(int nargs, char **args) { ARGC(1); - ARG_CHTYPE_STRING(0, ch); + ARG_CHTYPE(0, ch); report_count(1); - report_return(addch(ch[0])); + report_return(addch(ch)); } @@ -306,10 +306,10 @@ void cmd_bkgd(int nargs, char **args) { ARGC(1); - ARG_CHTYPE_STRING(0, ch); + ARG_CHTYPE(0, ch); report_count(1); - report_return(bkgd(ch[0])); + report_return(bkgd(ch)); } @@ -317,9 +317,9 @@ void cmd_bkgdset(int nargs, char **args) { ARGC(1); - ARG_CHTYPE_STRING(0, ch); + ARG_CHTYPE(0, ch); - bkgdset(ch[0]); /* returns void */ + bkgdset(ch); /* returns void */ report_count(1); report_return(OK); } @@ -409,11 +409,11 @@ void cmd_echochar(int nargs, char **args) { ARGC(1); - ARG_CHTYPE_STRING(0, ch); + ARG_CHTYPE(0, ch); /* XXX causes refresh */ report_count(1); - report_return(echochar(ch[0])); + report_return(echochar(ch)); } @@ -541,10 +541,10 @@ void cmd_insch(int nargs, char **args) { ARGC(1); - ARG_CHTYPE_STRING(0, ch); + ARG_CHTYPE(0, ch); report_count(1); - report_return(insch(ch[0])); + report_return(insch(ch)); } @@ -724,10 +724,10 @@ cmd_mvaddch(int nargs, char **args) ARGC(3); ARG_INT(0, y); ARG_INT(1, x); - ARG_CHTYPE_STRING(2, ch); + ARG_CHTYPE(2, ch); report_count(1); - report_return(mvaddch(y, x, ch[0])); + report_return(mvaddch(y, x, ch)); } @@ -926,10 +926,10 @@ cmd_mvinsch(int nargs, char **args) ARGC(3); ARG_INT(0, y); ARG_INT(1, x); - ARG_CHTYPE_STRING(2, ch); + ARG_CHTYPE(2, ch); report_count(1); - report_return(mvinsch(y, x, ch[0])); + report_return(mvinsch(y, x, ch)); } @@ -971,10 +971,10 @@ cmd_mvwaddch(int nargs, char **args) ARG_WINDOW(0, win); ARG_INT(1, y); ARG_INT(2, x); - ARG_CHTYPE_STRING(3, ch); + ARG_CHTYPE(3, ch); report_count(1); - report_return(mvwaddch(win, y, x, ch[0])); + report_return(mvwaddch(win, y, x, ch)); } @@ -1120,10 +1120,10 @@ cmd_mvwinsch(int nargs, char **args) ARG_WINDOW(0, win); ARG_INT(1, y); ARG_INT(2, x); - ARG_CHTYPE_STRING(3, ch); + ARG_CHTYPE(3, ch); report_count(1); - report_return(mvwinsch(win, y, x, ch[0])); + report_return(mvwinsch(win, y, x, ch)); } @@ -1697,11 +1697,11 @@ void cmd_hline(int nargs, char **args) { ARGC(2); - ARG_CHTYPE_STRING(0, ch); + ARG_CHTYPE(0, ch); ARG_INT(1, count); report_count(1); - report_return(hline(ch[0], count)); + report_return(hline(ch, count)); } @@ -1932,10 +1932,10 @@ cmd_mvhline(int nargs, char **args) ARG_INT(0, y); ARG_INT(1, x); ARG_INT(3, n); - ARG_CHTYPE_STRING(2, ch); + ARG_CHTYPE(2, ch); report_count(1); - report_return(mvhline(y, x, ch[0], n)); + report_return(mvhline(y, x, ch, n)); } @@ -1973,10 +1973,10 @@ cmd_mvvline(int nargs, char **args) ARG_INT(0, y); ARG_INT(1, x); ARG_INT(3, n); - ARG_CHTYPE_STRING(2, ch); + ARG_CHTYPE(2, ch); report_count(1); - report_return(mvvline(y, x, ch[0], n)); + report_return(mvvline(y, x, ch, n)); } @@ -1988,10 +1988,10 @@ cmd_mvwhline(int nargs, char **args) ARG_INT(1, y); ARG_INT(2, x); ARG_INT(4, n); - ARG_CHTYPE_STRING(3, ch); + ARG_CHTYPE(3, ch); report_count(1); - report_return(mvwhline(win, y, x, ch[0], n)); + report_return(mvwhline(win, y, x, ch, n)); } @@ -2003,10 +2003,10 @@ cmd_mvwvline(int nargs, char **args) ARG_INT(1, y); ARG_INT(2, x); ARG_INT(4, n); - ARG_CHTYPE_STRING(3,
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 16:49:19 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: add shortcut macros for SCREEN and unsigned int To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.16 src/tests/lib/libcurses/slave/curses_commands.c:1.17 --- src/tests/lib/libcurses/slave/curses_commands.c:1.16 Fri Feb 12 14:05:57 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 16:49:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.16 2021/02/12 14:05:57 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.17 2021/02/12 16:49:18 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -113,6 +113,11 @@ set_scrn(char *arg, SCREEN **x) if (set_int(args[i], ) != 0)\ return +#define ARG_UINT(i, arg) \ + unsigned int arg; \ + if (set_uint(args[i], ) != 0)\ + return + #define ARG_CHTYPE_STRING(i, arg) \ chtype *arg = (chtype *)args[i] @@ -127,6 +132,11 @@ set_scrn(char *arg, SCREEN **x) if (set_win(args[i], ) != 0)\ return +#define ARG_SCREEN(i, arg) \ + SCREEN *arg; \ + if (set_scrn(args[i], ) != 0)\ + return + void cmd_DRAIN(int nargs, char **args) { @@ -1200,15 +1210,14 @@ cmd_clearok(int nargs, char **args) void cmd_color_content(int nargs, char **args) { - short colour, red, green, blue; - ARGC(1); + ARG_SHORT(0, colour); - if (set_short(args[0], ) != 0) - return; + short red, green, blue; + int ret = color_content(colour, , , ); report_count(4); - report_return(color_content(colour, , , )); + report_return(ret); report_int(red); report_int(green); report_int(blue); @@ -1291,14 +1300,11 @@ cmd_delay_output(int nargs, char **args) void cmd_delscreen(int nargs, char **args) { - SCREEN *scrn; - ARGC(1); - - if (set_scrn(args[0], ) != 0) - return; + ARG_SCREEN(0, scrn); delscreen(scrn); /* void return */ + report_count(1); report_return(OK); } @@ -1841,12 +1847,8 @@ cmd_is_keypad(int nargs, char **args) void cmd_keyname(int nargs, char **args) { - unsigned int key; - ARGC(1); - - if (set_uint(args[0], ) != 0) - return; + ARG_UINT(0, key); report_count(1); report_status(keyname(key)); @@ -2311,15 +2313,14 @@ cmd_overwrite(int nargs, char **args) void cmd_pair_content(int nargs, char **args) { - short pair, fore, back; - ARGC(1); + ARG_SHORT(0, pair); - if (set_short(args[0], ) != 0) - return; + short fore, back; + int ret = pair_content(pair, , ); report_count(3); - report_return(pair_content(pair, , )); + report_return(ret); report_int(fore); report_int(back); } @@ -2536,11 +2537,8 @@ cmd_setterm(int nargs, char **args) void cmd_set_term(int nargs, char **args) { - SCREEN *scrn; - ARGC(1); - - if (set_scrn(args[0], ) != 0) return; + ARG_SCREEN(0, scrn); report_count(1); report_ptr(set_term(scrn));
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 14:05:57 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: remove redundant comments There is nothing surprising about call2, call3 or call4. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.15 src/tests/lib/libcurses/slave/curses_commands.c:1.16 --- src/tests/lib/libcurses/slave/curses_commands.c:1.15 Fri Feb 12 12:58:52 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 14:05:57 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.15 2021/02/12 12:58:52 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.16 2021/02/12 14:05:57 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -218,7 +218,6 @@ cmd_attr_get(int nargs, char **args) retval = attr_get(, , NULL); - /* - call3 */ report_count(3); report_return(retval); report_int(attrs); @@ -442,7 +441,7 @@ cmd_getnstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_return(getnstr(string, limit)); report_status(string); @@ -457,7 +456,6 @@ cmd_getstr(int nargs, char **args) ARGC(0); - /* XXX call2 */ report_count(2); report_return(getstr(string)); report_status(string); @@ -487,7 +485,7 @@ cmd_inchnstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_return(inchnstr(string, limit)); report_nstr(string); @@ -502,7 +500,6 @@ cmd_inchstr(int nargs, char **args) ARGC(0); - /* XXX call2 */ report_count(2); report_return(inchstr(string)); report_nstr(string); @@ -522,7 +519,7 @@ cmd_innstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_int(innstr(string, limit)); report_status(string); @@ -569,7 +566,6 @@ cmd_instr(int nargs, char **args) ARGC(0); - /* XXX call2 */ report_count(2); report_return(instr(string)); report_status(string); @@ -818,7 +814,7 @@ cmd_mvgetnstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_return(mvgetnstr(y, x, string, count)); report_status(string); @@ -835,7 +831,6 @@ cmd_mvgetstr(int nargs, char **args) ARG_INT(0, y); ARG_INT(1, x); - /* XXX call2 */ report_count(2); report_return(mvgetstr(y, x, string)); report_status(string); @@ -869,7 +864,7 @@ cmd_mvinchnstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_return(mvinchnstr(y, x, string, count)); report_nstr(string); @@ -886,7 +881,6 @@ cmd_mvinchstr(int nargs, char **args) ARG_INT(0, y); ARG_INT(1, x); - /* XXX call2 */ report_count(2); report_return(mvinchstr(y, x, string)); report_nstr(string); @@ -908,7 +902,7 @@ cmd_mvinnstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_int(mvinnstr(y, x, string, count)); report_status(string); @@ -1072,7 +1066,7 @@ cmd_mvwgetnstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_return(mvwgetnstr(win, y, x, string, count)); report_status(string); @@ -1090,7 +1084,6 @@ cmd_mvwgetstr(int nargs, char **args) ARG_INT(1, y); ARG_INT(2, x); - /* XXX - call2 */ report_count(2); report_return(mvwgetstr(win, y, x, string)); report_status(string); @@ -1214,7 +1207,6 @@ cmd_color_content(int nargs, char **args if (set_short(args[0], ) != 0) return; - /* XXX - call4 */ report_count(4); report_return(color_content(colour, , , )); report_int(red); @@ -1429,7 +1421,6 @@ cmd_fullname(int nargs, char **args) ARGC(1); - /* XXX - call2 */ report_count(2); report_status(fullname(args[0], string)); report_status(string); @@ -1967,7 +1958,6 @@ cmd_mvscanw(int nargs, char **args) ARG_INT(0, y); ARG_INT(1, x); - /* XXX - call2 */ report_count(2); report_return(mvscanw(y, x, args[2], )); report_status(string); @@ -2047,7 +2037,7 @@ cmd_mvwinchnstr(int nargs, char **args) report_error("MALLOC_FAILED"); return; } - /* XXX call2 */ + report_count(2); report_return(mvwinchnstr(win, y, x, string, count)); report_nstr(string); @@ -2065,7 +2055,6 @@ cmd_mvwinchstr(int nargs, char **args) ARG_INT(1, y); ARG_INT(2, x); - /* XXX call2 */ report_count(2); report_return(mvwinchstr(win, y, x, string)); report_nstr(string); @@ -2078,7 +2067,6 @@ cmd_mvwinnstr(int nargs, char **args) char *string; ARGC(4); - ARG_WINDOW(0, win); ARG_INT(1, y);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 12:58:52 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: reduce boilerplate in function dispatcher No functional change. The generated code for GCC 9.3 on NetBSD 9.99.80 x86_64 is exactly the same as before. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.14 src/tests/lib/libcurses/slave/curses_commands.c:1.15 --- src/tests/lib/libcurses/slave/curses_commands.c:1.14 Fri Feb 12 08:55:32 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 12:58:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.14 2021/02/12 08:55:32 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.15 2021/02/12 12:58:52 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -103,11 +103,25 @@ set_scrn(char *arg, SCREEN **x) if (check_arg_count(nargs, n) == 1)\ return +#define ARG_SHORT(i, arg) \ + short arg; \ + if (set_short(args[i], ) != 0)\ + return + #define ARG_INT(i, arg) \ int arg; \ if (set_int(args[i], ) != 0)\ return +#define ARG_CHTYPE_STRING(i, arg) \ + chtype *arg = (chtype *)args[i] + +#define ARG_CCHAR_STRING(i, arg) \ + cchar_t *arg = (cchar_t *)args[i] + +#define ARG_WCHAR_STRING(i, arg) \ + wchar_t *arg = (wchar_t *)args[i] + #define ARG_WINDOW(i, arg) \ WINDOW *arg; \ if (set_win(args[i], ) != 0)\ @@ -128,6 +142,7 @@ void cmd_addbytes(int nargs, char **args) { ARGC(2); + /* TODO: arg 0 */ ARG_INT(1, count); report_count(1); @@ -138,11 +153,9 @@ cmd_addbytes(int nargs, char **args) void cmd_addch(int nargs, char **args) { - chtype *ch; - ARGC(1); + ARG_CHTYPE_STRING(0, ch); - ch = (chtype *) args[0]; report_count(1); report_return(addch(ch[0])); } @@ -152,6 +165,7 @@ void cmd_addchnstr(int nargs, char **args) { ARGC(2); + /* TODO: arg 0 */ ARG_INT(1, count); report_count(1); @@ -163,6 +177,7 @@ void cmd_addchstr(int nargs, char **args) { ARGC(1); + /* TODO: arg 0 */ report_count(1); report_return(addchstr((chtype *) args[0])); @@ -173,6 +188,7 @@ void cmd_addnstr(int nargs, char **args) { ARGC(2); + /* TODO: arg 0 */ ARG_INT(1, count); report_count(1); @@ -184,6 +200,7 @@ void cmd_addstr(int nargs, char **args) { ARGC(1); + /* TODO: arg 0 */ report_count(1); report_return(addstr(args[0])); @@ -234,14 +251,9 @@ cmd_attr_on(int nargs, char **args) void cmd_attr_set(int nargs, char **args) { - int attrib; - short pair; - ARGC(2); - - if ((set_int(args[0], ) != 0) || - (set_short(args[1], ) != 0)) - return; + ARG_INT(0, attrib); + ARG_SHORT(1, pair); report_count(1); report_return(attr_set(attrib, pair, NULL)); @@ -284,11 +296,9 @@ cmd_attrset(int nargs, char **args) void cmd_bkgd(int nargs, char **args) { - chtype *ch; - ARGC(1); + ARG_CHTYPE_STRING(0, ch); - ch = (chtype *) args[0]; report_count(1); report_return(bkgd(ch[0])); } @@ -297,11 +307,8 @@ cmd_bkgd(int nargs, char **args) void cmd_bkgdset(int nargs, char **args) { - chtype *ch; - ARGC(1); - - ch = (chtype *) args[0]; + ARG_CHTYPE_STRING(0, ch); bkgdset(ch[0]); /* returns void */ report_count(1); @@ -312,19 +319,15 @@ cmd_bkgdset(int nargs, char **args) void cmd_border(int nargs, char **args) { - int ls, rs, ts, bs, tl, tr, bl, br; - ARGC(8); - - if ((set_int(args[0], ) != 0) || - (set_int(args[1], ) != 0) || - (set_int(args[2], ) != 0) || - (set_int(args[3], ) != 0) || - (set_int(args[4], ) != 0) || - (set_int(args[5], ) != 0) || - (set_int(args[6], ) != 0) || - (set_int(args[7], ) != 0)) - return; + ARG_INT(0, ls); + ARG_INT(1, rs); + ARG_INT(2, ts); + ARG_INT(3, bs); + ARG_INT(4, tl); + ARG_INT(5, tr); + ARG_INT(6, bl); + ARG_INT(7, br); report_count(1); report_return(border(ls, rs, ts, bs, tl, tr, bl, br)); @@ -364,13 +367,9 @@ cmd_clrtoeol(int nargs, char **args) void cmd_color_set(int nargs, char **args) { - short colour_pair; - ARGC(2); - - if (set_short(args[0], _pair) != 0) - return; - /* XXX: args[1] is unused */ + ARG_SHORT(0, colour_pair); + /* TODO: arg 1 */ report_count(1); report_return(color_set(colour_pair, NULL)); @@ -400,10 +399,9 @@ cmd_deleteln(int nargs, char **args) void cmd_echochar(int nargs, char **args) { - chtype *ch; ARGC(1); + ARG_CHTYPE_STRING(0, ch); - ch = (chtype *) args[0]; /* XXX causes refresh */ report_count(1); report_return(echochar(ch[0])); @@ -535,10 +533,9 @@ cmd_innstr(int nargs, char **args) void cmd_insch(int nargs, char **args) { - chtype *ch; ARGC(1); + ARG_CHTYPE_STRING(0, ch); - ch = (chtype *) args[0]; report_count(1);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Fri Feb 12 08:55:32 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: curses_commands.c Log Message: tests/libcurses: reduce boilerplate in function dispatcher This makes the code more declarative and easier to reason about. The generated code stays exactly the same. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libcurses/slave/curses_commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/curses_commands.c diff -u src/tests/lib/libcurses/slave/curses_commands.c:1.13 src/tests/lib/libcurses/slave/curses_commands.c:1.14 --- src/tests/lib/libcurses/slave/curses_commands.c:1.13 Tue Feb 9 20:22:11 2021 +++ src/tests/lib/libcurses/slave/curses_commands.c Fri Feb 12 08:55:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: curses_commands.c,v 1.13 2021/02/09 20:22:11 rillig Exp $ */ +/* $NetBSD: curses_commands.c,v 1.14 2021/02/12 08:55:32 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -99,16 +99,25 @@ set_scrn(char *arg, SCREEN **x) return 0; } +#define ARGC(n) \ + if (check_arg_count(nargs, n) == 1)\ + return + +#define ARG_INT(i, arg) \ + int arg; \ + if (set_int(args[i], ) != 0)\ + return + +#define ARG_WINDOW(i, arg) \ + WINDOW *arg; \ + if (set_win(args[i], ) != 0)\ + return void cmd_DRAIN(int nargs, char **args) { - WINDOW *win; - if (check_arg_count(nargs, 1) == 1) - return; - - if (set_win(args[0], ) != 0) - return; + ARGC(1); + ARG_WINDOW(0, win); while (wgetch(win) != ERR); report_count(1); @@ -118,13 +127,8 @@ cmd_DRAIN(int nargs, char **args) void cmd_addbytes(int nargs, char **args) { - int count; - - if (check_arg_count(nargs, 2) == 1) - return; - - if (set_int(args[1], ) != 0) - return; + ARGC(2); + ARG_INT(1, count); report_count(1); report_return(addbytes(args[0], count)); @@ -136,8 +140,7 @@ cmd_addch(int nargs, char **args) { chtype *ch; - if (check_arg_count(nargs, 1) == 1) - return; + ARGC(1); ch = (chtype *) args[0]; report_count(1); @@ -148,13 +151,8 @@ cmd_addch(int nargs, char **args) void cmd_addchnstr(int nargs, char **args) { - int count; - - if (check_arg_count(nargs, 2) == 1) - return; - - if (set_int(args[1], ) != 0) - return; + ARGC(2); + ARG_INT(1, count); report_count(1); report_return(addchnstr((chtype *) args[0], count)); @@ -164,8 +162,7 @@ cmd_addchnstr(int nargs, char **args) void cmd_addchstr(int nargs, char **args) { - if (check_arg_count(nargs, 1) == 1) - return; + ARGC(1); report_count(1); report_return(addchstr((chtype *) args[0])); @@ -175,13 +172,8 @@ cmd_addchstr(int nargs, char **args) void cmd_addnstr(int nargs, char **args) { - int count; - - if (check_arg_count(nargs, 2) == 1) - return; - - if (set_int(args[1], ) != 0) - return; + ARGC(2); + ARG_INT(1, count); report_count(1); report_return(addnstr(args[0], count)); @@ -191,8 +183,7 @@ cmd_addnstr(int nargs, char **args) void cmd_addstr(int nargs, char **args) { - if (check_arg_count(nargs, 1) == 1) - return; + ARGC(1); report_count(1); report_return(addstr(args[0])); @@ -206,8 +197,7 @@ cmd_attr_get(int nargs, char **args) short colours; int retval; - if (check_arg_count(nargs, 0) == 1) - return; + ARGC(0); retval = attr_get(, , NULL); @@ -222,13 +212,8 @@ cmd_attr_get(int nargs, char **args) void cmd_attr_off(int nargs, char **args) { - int attrib; - - if (check_arg_count(nargs, 1) == 1) - return; - - if (set_int(args[0], ) != 0) - return; + ARGC(1); + ARG_INT(0, attrib); report_count(1); report_return(attr_off(attrib, NULL)); @@ -238,13 +223,8 @@ cmd_attr_off(int nargs, char **args) void cmd_attr_on(int nargs, char **args) { - int attrib; - - if (check_arg_count(nargs, 1) == 1) - return; - - if (set_int(args[0], ) != 0) - return; + ARGC(1); + ARG_INT(0, attrib); report_count(1); report_return(attr_on(attrib, NULL)); @@ -257,8 +237,7 @@ cmd_attr_set(int nargs, char **args) int attrib; short pair; - if (check_arg_count(nargs, 2) == 1) - return; + ARGC(2); if ((set_int(args[0], ) != 0) || (set_short(args[1], ) != 0)) @@ -272,13 +251,8 @@ cmd_attr_set(int nargs, char **args) void cmd_attroff(int nargs, char **args) { - int attrib; - - if (check_arg_count(nargs, 1) == 1) - return; - - if (set_int(args[0], ) != 0) - return; + ARGC(1); + ARG_INT(0, attrib); report_count(1); report_return(attroff(attrib)); @@ -288,13 +262,8 @@ cmd_attroff(int nargs, char **args) void cmd_attron(int nargs, char **args) { - int attrib; - - if (check_arg_count(nargs, 1) == 1) - return; - - if (set_int(args[0], ) != 0) - return; + ARGC(1); + ARG_INT(0, attrib); report_count(1); report_return(attron(attrib)); @@ -304,13 +273,8 @@ cmd_attron(int nargs, char **args) void cmd_attrset(int nargs, char **args) { - int attrib; - - if
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Tue Feb 9 20:42:31 UTC 2021 Modified Files: src/tests/lib/libcurses: t_curses.sh src/tests/lib/libcurses/director: director.c testlang_parse.y src/tests/lib/libcurses/slave: commands.c slave.c Log Message: tests/libcurses: add missing space after control flow keywords To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libcurses/t_curses.sh cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/director/director.c cvs rdiff -u -r1.43 -r1.44 src/tests/lib/libcurses/director/testlang_parse.y cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libcurses/slave/commands.c \ src/tests/lib/libcurses/slave/slave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/t_curses.sh diff -u src/tests/lib/libcurses/t_curses.sh:1.20 src/tests/lib/libcurses/t_curses.sh:1.21 --- src/tests/lib/libcurses/t_curses.sh:1.20 Thu Oct 29 00:27:50 2020 +++ src/tests/lib/libcurses/t_curses.sh Tue Feb 9 20:42:31 2021 @@ -1,4 +1,5 @@ -h_run(){ +h_run() +{ file=$1 if [ -z "$2" ]; then export LC_ALL=C Index: src/tests/lib/libcurses/director/director.c diff -u src/tests/lib/libcurses/director/director.c:1.17 src/tests/lib/libcurses/director/director.c:1.18 --- src/tests/lib/libcurses/director/director.c:1.17 Mon Feb 8 19:15:20 2021 +++ src/tests/lib/libcurses/director/director.c Tue Feb 9 20:42:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: director.c,v 1.17 2021/02/08 19:15:20 rillig Exp $ */ +/* $NetBSD: director.c,v 1.18 2021/02/09 20:42:31 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -142,7 +142,7 @@ main(int argc, char *argv[]) check_file_flag = 0; while ((ch = getopt(argc, argv, "vgfC:I:p:s:t:T:")) != -1) { - switch(ch) { + switch (ch) { case 'I': include_path = optarg; break; Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.43 src/tests/lib/libcurses/director/testlang_parse.y:1.44 --- src/tests/lib/libcurses/director/testlang_parse.y:1.43 Mon Feb 8 23:54:03 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Tue Feb 9 20:42:31 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.43 2021/02/08 23:54:03 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.44 2021/02/09 20:42:31 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -1116,7 +1116,7 @@ do_function_call(size_t nresults) fds[1].events = POLLOUT; p = input_str; save_slave_output(false); - while(*p != '\0') { + while (*p != '\0') { perform_delay(_spec); if (poll(fds, 2, 0) < 0) @@ -1774,11 +1774,11 @@ validate_wchar(wchar_t *expected, wchar_ wchar_t *p; p = expected; - while(*p++ != L'\0') + while (*p++ != L'\0') len1++; p = value; - while(*p++ != L'\0') + while (*p++ != L'\0') len2++; /* @@ -2036,7 +2036,7 @@ read_cmd_pipe(ct_data_t *response) save_slave_output(false); } } - while((rfd[1].revents & POLLIN) == POLLIN); + while ((rfd[1].revents & POLLIN) == POLLIN); if (read(slvpipe[READ_PIPE], , sizeof(int)) < 0) err(1, "command pipe read for type failed"); Index: src/tests/lib/libcurses/slave/commands.c diff -u src/tests/lib/libcurses/slave/commands.c:1.9 src/tests/lib/libcurses/slave/commands.c:1.10 --- src/tests/lib/libcurses/slave/commands.c:1.9 Tue Feb 9 20:39:20 2021 +++ src/tests/lib/libcurses/slave/commands.c Tue Feb 9 20:42:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.9 2021/02/09 20:39:20 rillig Exp $ */ +/* $NetBSD: commands.c,v 1.10 2021/02/09 20:42:31 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -61,7 +61,7 @@ command_execute(char *func, int nargs, c if (strcmp(func, commands[i].name) == 0) { /* Check only restricted set of functions is called before * initscr/newterm */ - if (!initdone){ + if (!initdone) { j = 0; while (j < nrcmds) { if (strcmp(func, restricted_commands[j]) == 0) { Index: src/tests/lib/libcurses/slave/slave.c diff -u src/tests/lib/libcurses/slave/slave.c:1.9 src/tests/lib/libcurses/slave/slave.c:1.10 --- src/tests/lib/libcurses/slave/slave.c:1.9 Mon Feb 8 19:15:21 2021 +++ src/tests/lib/libcurses/slave/slave.c Tue Feb 9 20:42:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: slave.c,v 1.9 2021/02/08 19:15:21 rillig Exp $ */ +/* $NetBSD: slave.c,v 1.10 2021/02/09 20:42:31 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -64,7 +64,7 @@ process_commands(void) if ((cmdbuf = malloc(maxlen)) == NULL) err(1, "slave cmdbuf malloc failed"); - while(1) { + while (1) { if (read(cmdpipe[READ_PIPE], , sizeof(int)) < 0) err(1, "slave command type read failed"); @@ -140,7 +140,7 @@ process_commands(void) argslen++; } } - while(len >= 0); + while (len >= 0); command_execute(cmdbuf, argslen, args);
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Tue Feb 9 20:39:20 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: commands.c Log Message: tests/libcurses: replace remaining strcasecmp with strcmp There is no reason to write special functions in a different case than the canonical one, just like for the regular curses functions. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/slave/commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/commands.c diff -u src/tests/lib/libcurses/slave/commands.c:1.8 src/tests/lib/libcurses/slave/commands.c:1.9 --- src/tests/lib/libcurses/slave/commands.c:1.8 Tue Feb 9 20:24:02 2021 +++ src/tests/lib/libcurses/slave/commands.c Tue Feb 9 20:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.8 2021/02/09 20:24:02 rillig Exp $ */ +/* $NetBSD: commands.c,v 1.9 2021/02/09 20:39:20 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -61,12 +61,12 @@ command_execute(char *func, int nargs, c if (strcmp(func, commands[i].name) == 0) { /* Check only restricted set of functions is called before * initscr/newterm */ - if(!initdone){ + if (!initdone){ j = 0; -while(j < nrcmds) { - if(strcasecmp(func, restricted_commands[j]) == 0){ - if(strcasecmp(func, "initscr") == 0 || - strcasecmp(func, "newterm") == 0) +while (j < nrcmds) { + if (strcmp(func, restricted_commands[j]) == 0) { + if (strcmp(func, "initscr") == 0 || + strcmp(func, "newterm") == 0) initdone = 1; /* matched function */ commands[i].func(nargs, args);
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Tue Feb 9 20:31:02 UTC 2021 Modified Files: src/tests/lib/libcurses: testframe.txt src/tests/lib/libcurses/tests: timeout wtimeout Log Message: tests/libcurses: fix spelling of the special call to DRAIN To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/testframe.txt cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libcurses/tests/timeout cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libcurses/tests/wtimeout Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/testframe.txt diff -u src/tests/lib/libcurses/testframe.txt:1.7 src/tests/lib/libcurses/testframe.txt:1.8 --- src/tests/lib/libcurses/testframe.txt:1.7 Sun Feb 7 20:20:06 2021 +++ src/tests/lib/libcurses/testframe.txt Tue Feb 9 20:31:02 2021 @@ -1,4 +1,4 @@ -$NetBSD: testframe.txt,v 1.7 2021/02/07 20:20:06 rillig Exp $ +$NetBSD: testframe.txt,v 1.8 2021/02/09 20:31:02 rillig Exp $ CURSES TESTFRAME @@ -261,8 +261,8 @@ of the operation can either be used as a be used as an expected result for a call. In addition to all the curses calls being supported by the slave, -there is one more special call called "drain". This call repeatedly -called wgetch(win) until there are no more characters in win. The call +there is one more special call called "DRAIN". This call repeatedly +calls wgetch(win) until there are no more characters in win. The call assumes that the curses input is either in no delay or timed input mode otherwise the test will time out and fail. This call can be used to clear any pending input when testing a timed read, to prevent the Index: src/tests/lib/libcurses/tests/timeout diff -u src/tests/lib/libcurses/tests/timeout:1.2 src/tests/lib/libcurses/tests/timeout:1.3 --- src/tests/lib/libcurses/tests/timeout:1.2 Sat Oct 24 04:46:17 2020 +++ src/tests/lib/libcurses/tests/timeout Tue Feb 9 20:31:02 2021 @@ -10,8 +10,8 @@ input "b" # since delay is in effect and we set timeout the following getch should # return ERR not the character b. call -1 getch -# drain input -call OK drain STDSCR +# drain input ... +call OK DRAIN STDSCR call OK timeout -1 call OK keypad STDSCR 1 delay 0 Index: src/tests/lib/libcurses/tests/wtimeout diff -u src/tests/lib/libcurses/tests/wtimeout:1.1 src/tests/lib/libcurses/tests/wtimeout:1.2 --- src/tests/lib/libcurses/tests/wtimeout:1.1 Sat Oct 24 04:46:17 2020 +++ src/tests/lib/libcurses/tests/wtimeout Tue Feb 9 20:31:02 2021 @@ -10,8 +10,8 @@ input "b" # since delay is in effect and we set timeout the following getch should # return ERR not the character b. call -1 wgetch $win1 -# drain input -call OK drain $win1 +# drain input ... +call OK DRAIN $win1 call OK wtimeout $win1 -1 call OK keypad $win1 1 delay 0
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Tue Feb 9 20:24:02 UTC 2021 Modified Files: src/tests/lib/libcurses/slave: commands.c Log Message: tests/libcurses: compare function names case-sensitive There is absolutely no reason to write function names in upper case or mixed case. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libcurses/slave/commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/slave/commands.c diff -u src/tests/lib/libcurses/slave/commands.c:1.7 src/tests/lib/libcurses/slave/commands.c:1.8 --- src/tests/lib/libcurses/slave/commands.c:1.7 Mon Feb 8 19:15:21 2021 +++ src/tests/lib/libcurses/slave/commands.c Tue Feb 9 20:24:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.7 2021/02/08 19:15:21 rillig Exp $ */ +/* $NetBSD: commands.c,v 1.8 2021/02/09 20:24:02 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -58,7 +58,7 @@ command_execute(char *func, int nargs, c i = 0; while (i < ncmds) { - if (strcasecmp(func, commands[i].name) == 0) { + if (strcmp(func, commands[i].name) == 0) { /* Check only restricted set of functions is called before * initscr/newterm */ if(!initdone){