Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/stdlib Make the mkstemps_basic and mkostemps_...



details:   https://anonhg.NetBSD.org/src/rev/bfd7a2f849e3
branches:  trunk
changeset: 1015824:bfd7a2f849e3
user:      gson <gson%NetBSD.org@localhost>
date:      Sun Nov 01 18:19:54 2020 +0000

description:
Make the mkstemps_basic and mkostemps_basic test cases not randomly
fail when the replacement string happens to contain the letter "y".

diffstat:

 tests/lib/libc/stdlib/t_mktemp.c |  16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diffs (58 lines):

diff -r 7f54a696c656 -r bfd7a2f849e3 tests/lib/libc/stdlib/t_mktemp.c
--- a/tests/lib/libc/stdlib/t_mktemp.c  Sun Nov 01 17:58:17 2020 +0000
+++ b/tests/lib/libc/stdlib/t_mktemp.c  Sun Nov 01 18:19:54 2020 +0000
@@ -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_BODY(mkstemps_basic, tc)
 {
        char template[] = "/tmp/mktemp.XXXyyy";
+       char *suffix = strchr(template, 'y');
        struct stat sa;
        int fd;
 
@@ -145,10 +146,7 @@
 
        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 @@
        };
 
        char template[] = "/tmp/mktemp.XXXyyy";
+       char *suffix = strchr(template, 'y');
        struct stat sa;
        size_t i;
        int fd;
@@ -239,10 +238,7 @@
 
                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);



Home | Main Index | Thread Index | Old Index