Module Name: src
Committed By: gson
Date: Sun Nov 1 18:19:54 UTC 2020
Modified Files:
src/tests/lib/libc/stdlib: t_mktemp.c
Log Message:
Make the mkstemps_basic and mkostemps_basic test cases not randomly
fail when the replacement string happens to contain the letter "y".
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/stdlib/t_mktemp.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/stdlib/t_mktemp.c
diff -u src/tests/lib/libc/stdlib/t_mktemp.c:1.2 src/tests/lib/libc/stdlib/t_mktemp.c:1.3
--- src/tests/lib/libc/stdlib/t_mktemp.c:1.2 Wed Jul 1 05:37:25 2020
+++ src/tests/lib/libc/stdlib/t_mktemp.c Sun Nov 1 18:19:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mktemp.c,v 1.2 2020/07/01 05:37:25 jruoho Exp $ */
+/* $NetBSD: t_mktemp.c,v 1.3 2020/11/01 18:19:54 gson Exp $ */
/*-
* Copyright (c) 2013, 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mktemp.c,v 1.2 2020/07/01 05:37:25 jruoho Exp $");
+__RCSID("$NetBSD: t_mktemp.c,v 1.3 2020/11/01 18:19:54 gson Exp $");
#include <sys/stat.h>
@@ -136,6 +136,7 @@ ATF_TC_HEAD(mkstemps_basic, tc)
ATF_TC_BODY(mkstemps_basic, tc)
{
char template[] = "/tmp/mktemp.XXXyyy";
+ char *suffix = strchr(template, 'y');
struct stat sa;
int fd;
@@ -145,10 +146,7 @@ ATF_TC_BODY(mkstemps_basic, tc)
ATF_REQUIRE(fd != -1);
ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
-
- char *str = strchr(template, 'y');
-
- ATF_REQUIRE(strcmp(str, "yyy") == 0);
+ ATF_REQUIRE(strcmp(suffix, "yyy") == 0);
ATF_REQUIRE(write(fd, "X", 1) == 1);
ATF_REQUIRE(fstat(fd, &sa) == 0);
ATF_REQUIRE(check_mode(sa, 0600, 0) == 0);
@@ -227,6 +225,7 @@ ATF_TC_BODY(mkostemps_basic, tc)
};
char template[] = "/tmp/mktemp.XXXyyy";
+ char *suffix = strchr(template, 'y');
struct stat sa;
size_t i;
int fd;
@@ -239,10 +238,7 @@ ATF_TC_BODY(mkostemps_basic, tc)
ATF_REQUIRE(fd != -1);
ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
-
- char *str = strchr(template, 'y');
-
- ATF_REQUIRE(strcmp(str, "yyy") == 0);
+ ATF_REQUIRE(strcmp(suffix, "yyy") == 0);
ATF_REQUIRE(write(fd, "X", 1) == 1);
ATF_REQUIRE(fstat(fd, &sa) == 0);
ATF_REQUIRE(check_mode(sa, 0600 | flags[i], 0) == 0);