Source-Changes-HG archive

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

[src/trunk]: src/tests/include Don't fail if open() of sysmon devices returns...



details:   https://anonhg.NetBSD.org/src/rev/c9e6a6640482
branches:  trunk
changeset: 808133:c9e6a6640482
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu May 07 01:35:35 2015 +0000

description:
Don't fail if open() of sysmon devices returns ENODEV.  This can
occur if sysmon subcomponents are not included in the kernel and
autoloading of modules is not allowed or not supported.

diffstat:

 tests/include/t_paths.c |  23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diffs (75 lines):

diff -r 1d56fe63e426 -r c9e6a6640482 tests/include/t_paths.c
--- a/tests/include/t_paths.c   Wed May 06 23:08:30 2015 +0000
+++ b/tests/include/t_paths.c   Thu May 07 01:35:35 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_paths.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */
+/*     $NetBSD: t_paths.c,v 1.15 2015/05/07 01:35:35 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_paths.c,v 1.14 2014/11/04 00:20:19 justin Exp $");
+__RCSID("$NetBSD: t_paths.c,v 1.15 2015/05/07 01:35:35 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -47,6 +47,7 @@
 #define PATH_DIR       __BIT(1)        /* A directory          */
 #define PATH_FILE      __BIT(2)        /* A file               */
 #define PATH_ROOT      __BIT(3)        /* Access for root only */
+#define PATH_OPT       __BIT(3)        /* Optional, ENODEV if not supported */
 
 static const struct {
        const char      *path;
@@ -82,7 +83,7 @@
        { _PATH_MIXER,          PATH_DEV                },
        { _PATH_MIXER0,         PATH_DEV                },
        { _PATH_NOLOGIN,        PATH_FILE               },
-       { _PATH_POWER,          PATH_DEV | PATH_ROOT    },
+       { _PATH_POWER,          PATH_DEV | PATH_ROOT | PATH_OPT },
        { _PATH_PRINTCAP,       PATH_FILE               },
        { _PATH_PUD,            PATH_DEV | PATH_ROOT    },
        { _PATH_PUFFS,          PATH_DEV | PATH_ROOT    },
@@ -92,12 +93,13 @@
        { _PATH_SKEYKEYS,       PATH_FILE | PATH_ROOT   },
        { _PATH_SOUND,          PATH_DEV                },
        { _PATH_SOUND0,         PATH_DEV                },
-       { _PATH_SYSMON,         PATH_DEV                },
+       { _PATH_SYSMON,         PATH_DEV | PATH_OPT     },
        { _PATH_TTY,            PATH_DEV                },
        { _PATH_UNIX,           PATH_FILE | PATH_ROOT   },
        { _PATH_URANDOM,        PATH_DEV                },
        { _PATH_VIDEO,          PATH_DEV                },
        { _PATH_VIDEO0,         PATH_DEV                },
+       { _PATH_WATCHDOG,       PATH_DEV | PATH_OPT     },
 
        { _PATH_DEV,            PATH_DIR                },
        { _PATH_DEV_PTS,        PATH_DIR                },
@@ -143,13 +145,22 @@
 
                        switch (errno) {
 
+                       case ENODEV:
+                               if ((paths[i].flags & PATH_OPT) == 0) {
+
+                                       atf_tc_fail("Required path %s does "
+                                           "not exist", paths[i].path);
+                               }
+                               break;
+
                        case EPERM:     /* FALLTHROUGH */
                        case EACCES:    /* FALLTHROUGH */
 
                                if ((paths[i].flags & PATH_ROOT) == 0) {
 
-                                       atf_tc_fail("UID %u failed to open %s",
-                                           (uint32_t)uid, paths[i].path);
+                                       atf_tc_fail("UID %u failed to open %s, "
+                                           "error %d", (uint32_t)uid,
+                                            paths[i].path, error);
                                }
 
                        case EBUSY:     /* FALLTHROUGH */



Home | Main Index | Thread Index | Old Index