[git commit] tests: mmap2: ignore permission denied errors on /dev/mem

Mike Frysinger vapier at gentoo.org
Mon Jan 16 20:55:10 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=386a22b920780077d882e051689e6a3a6c92682b
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Non-root users can't open /dev/mem, so it makes it hard to pass.
Ignore that case.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 test/mmap/mmap2.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/test/mmap/mmap2.c b/test/mmap/mmap2.c
index b9a8f9a..8b94c61 100644
--- a/test/mmap/mmap2.c
+++ b/test/mmap/mmap2.c
@@ -25,7 +25,12 @@ int main(int argc, char **argv) {
     void* map_base = 0;
     int fd;
     off_t target = 0xfffff000;
-    if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
+    if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
+        /* skip test for non-root users */
+        if (errno == EACCES)
+            return 0;
+        FATAL;
+    }
     printf("/dev/mem opened.\n");
     fflush(stdout);
 


More information about the uClibc-cvs mailing list