Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc/stdio In the fopen_regular and fopen_symlink ...



details:   https://anonhg.NetBSD.org/src/rev/c2a239826a00
branches:  trunk
changeset: 827652:c2a239826a00
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Nov 06 23:06:55 2017 +0000

description:
In the fopen_regular and fopen_symlink tests, when (that is, if) a
failure occurs, distinguish in the failure message the cases where the
open succeeded (and should not have), and where it failed, but not for
the expected reason (the "wrong errno" case not tested, would require
manufacturing a broken kernel...).

Add O_NOFOLLOW ('l' mode modifier) tests to the fopen_mode test case
(tests that are intended to open the file) and also add a few missing
commas which were causing a few of the sub-tests to be skipped, and
others to be not quite testing exactly what was intended.

diffstat:

 tests/lib/libc/stdio/t_fopen.c |  32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diffs (71 lines):

diff -r 4cb39d28765c -r c2a239826a00 tests/lib/libc/stdio/t_fopen.c
--- a/tests/lib/libc/stdio/t_fopen.c    Mon Nov 06 21:40:04 2017 +0000
+++ b/tests/lib/libc/stdio/t_fopen.c    Mon Nov 06 23:06:55 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_fopen.c,v 1.4 2017/11/06 17:32:53 christos Exp $ */
+/*     $NetBSD: t_fopen.c,v 1.5 2017/11/06 23:06:55 kre Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_fopen.c,v 1.4 2017/11/06 17:32:53 christos Exp $");
+__RCSID("$NetBSD: t_fopen.c,v 1.5 2017/11/06 23:06:55 kre Exp $");
 
 #include <atf-c.h>
 #include <errno.h>
@@ -253,9 +253,10 @@
 
        static const char *mode[] = {
                "r", "r+", "w", "w+", "a", "a+",
-               "rb", "r+b", "wb", "w+b", "ab", "a+b"
-               "re", "r+e", "we", "w+e", "ae", "a+e"
-               "rf", "r+f", "wf", "w+f", "af", "a+f"
+               "rb", "r+b", "wb", "w+b", "ab", "a+b",
+               "re", "r+e", "we", "w+e", "ae", "a+e",
+               "rf", "r+f", "wf", "w+f", "af", "a+f",
+               "rl", "r+l", "wl", "w+l", "al", "a+l"
        };
 
        f = fopen(path, "w+");
@@ -327,11 +328,16 @@
                        if (f == NULL && errno == EFTYPE)
                                continue;
 
-                       if (f != NULL)
+                       if (f != NULL) {
                                (void)fclose(f);
 
-                       atf_tc_fail_nonfatal("opened %s as %s",
-                           devs[i], mode[j]);
+                               atf_tc_fail_nonfatal("opened %s as %s",
+                                   devs[i], mode[j]);
+                       } else {
+                               atf_tc_fail_nonfatal(
+                                   "err %d (%s) from open of %s as %s", errno,
+                                   strerror(errno), devs[i], mode[j]);
+                       }
                }
        }
 }
@@ -360,10 +366,16 @@
                if (f == NULL && errno == EFTYPE)
                        continue;
 
-               if (f != NULL)
+               if (f != NULL) {
                        (void)fclose(f);
 
-               atf_tc_fail_nonfatal("opened %s as %s", linkpath, mode[j]);
+                       atf_tc_fail_nonfatal("opened %s as %s", linkpath,
+                           mode[j]);
+               } else {
+                       atf_tc_fail_nonfatal(
+                           "err %d (%s) from open of %s as %s", errno,
+                           strerror(errno), linkpath, mode[j]);
+               }
        }
        ATF_REQUIRE(unlink(linkpath) == 0);
 }



Home | Main Index | Thread Index | Old Index