From 1eaf575264c813a759974fbfb6175e038ef84ecf Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 11 Feb 2014 18:15:14 +0000 Subject: [PATCH 2/2] Add a test for mmap of empty file --- common/tests/test-compat.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/tests/test-compat.c b/common/tests/test-compat.c index 872170d..931ad39 100644 --- a/common/tests/test-compat.c +++ b/common/tests/test-compat.c @@ -83,6 +83,21 @@ test_getauxval (void) free (path); } +static void +test_mmap (void) +{ + p11_mmap *map; + void *data; + size_t size; + char file[] = "emptyfileXXXXXX"; + int fd = mkstemp(file); + close(fd); + /* mmap on empty file returns NULL */ + map = p11_mmap_open(file, NULL, &data, &size); + unlink(file); + assert_ptr_eq(map, NULL); +} + #endif /* OS_UNIX */ int @@ -95,6 +110,7 @@ main (int argc, if (!getenv ("FAKED_MODE")) { p11_test (test_getauxval, "/compat/getauxval"); } + p11_test (test_mmap, "/compat/mmap"); #endif return p11_test_run (argc, argv); } -- 1.8.5.4