* Fixed more incorrect occurrences of the pid_t == int assumption.

* Automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-04-08 17:32:09 +00:00
parent d7754ff079
commit e99d1fd16f
9 changed files with 274 additions and 274 deletions
@@ -1,19 +1,19 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* The mmap( ) function shall fail if: * The mmap( ) function shall fail if:
* [ENOMEM] MAP_FIXED was specified, * [ENOMEM] MAP_FIXED was specified,
* and the range [addr,addr+len) exceeds that allowed * and the range [addr,addr+len) exceeds that allowed
* for the address space of a process; or, if MAP_FIXED was not specified and * for the address space of a process; or, if MAP_FIXED was not specified and
* there is insufficient room in the address space to effect the mapping. * there is insufficient room in the address space to effect the mapping.
* *
* Test Step: * Test Step:
* 1. Map a shared memory object, with size exceeding the value get from * 1. Map a shared memory object, with size exceeding the value get from
* rlim_cur of resource RLIMIT_AS, setting MAP_FIXED; * rlim_cur of resource RLIMIT_AS, setting MAP_FIXED;
* 3. Should get ENOMEM. * 3. Should get ENOMEM.
*/ */
#define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE 600
@@ -29,7 +29,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "mmap/24-2.c" #define TNAME "mmap/24-2.c"
int main() int main()
@@ -37,23 +37,23 @@ int main()
char tmpfname[256]; char tmpfname[256];
int shm_fd; int shm_fd;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t len; size_t len;
int prot = PROT_READ | PROT_WRITE; int prot = PROT_READ | PROT_WRITE;
int flag = MAP_SHARED; int flag = MAP_SHARED;
int fd; int fd;
off_t off = 0; off_t off = 0;
/* Size of the shared memory object */ /* Size of the shared memory object */
size_t shm_size; size_t shm_size;
struct rlimit rlim; struct rlimit rlim;
unsigned long page_size = sysconf(_SC_PAGE_SIZE); unsigned long page_size = sysconf(_SC_PAGE_SIZE);
shm_size = 2 * page_size; shm_size = 2 * page_size;
snprintf(tmpfname, sizeof(tmpfname), "pts_mmap_24_2_%d", snprintf(tmpfname, sizeof(tmpfname), "pts_mmap_24_2_%ld",
getpid()); (long)getpid());
/* Create shared object */ /* Create shared object */
shm_unlink(tmpfname); shm_unlink(tmpfname);
shm_fd = shm_open(tmpfname, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR); shm_fd = shm_open(tmpfname, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
@@ -62,7 +62,7 @@ int main()
printf(TNAME " Error at shm_open(): %s\n", strerror(errno)); printf(TNAME " Error at shm_open(): %s\n", strerror(errno));
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
} }
shm_unlink(tmpfname); shm_unlink(tmpfname);
if(ftruncate(shm_fd, shm_size) == -1) { if(ftruncate(shm_fd, shm_size) == -1) {
printf(TNAME " Error at ftruncate(): %s\n", strerror(errno)); printf(TNAME " Error at ftruncate(): %s\n", strerror(errno));
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
@@ -74,25 +74,25 @@ int main()
printf(TNAME " Error at getrlimit(): %s\n", strerror(errno)); printf(TNAME " Error at getrlimit(): %s\n", strerror(errno));
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
} }
printf("available memory: %lu\n", rlim.rlim_cur); printf("available memory: %lu\n", rlim.rlim_cur);
/* First mmap, just to get a legal addr for second mmap */ /* First mmap, just to get a legal addr for second mmap */
fd = shm_fd; fd = shm_fd;
len = shm_size; len = shm_size;
pa = mmap (addr, len, prot, flag, fd, off); pa = mmap (addr, len, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf ("Test Fail: " TNAME " Error at first mmap(): %s\n", printf ("Test Fail: " TNAME " Error at first mmap(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
fd = shm_fd; fd = shm_fd;
len = rlim.rlim_cur; len = rlim.rlim_cur;
flag = MAP_FIXED | MAP_SHARED; flag = MAP_FIXED | MAP_SHARED;
addr = pa; addr = pa;
printf("addr: %lx, len: %lx\n", (unsigned long)addr, printf("addr: %lx, len: %lx\n", (unsigned long)addr,
(unsigned long)len); (unsigned long)len);
/* Make sure addr and len is aligned to page size */ /* Make sure addr and len is aligned to page size */
if ((unsigned long)addr % page_size) if ((unsigned long)addr % page_size)
{ {
@@ -104,17 +104,17 @@ int main()
{ {
/* Lower boundary */ /* Lower boundary */
len &= ~(page_size - 1); len &= ~(page_size - 1);
} }
printf("addr: %lx, len: %lx\n", (unsigned long)addr, printf("addr: %lx, len: %lx\n", (unsigned long)addr,
(unsigned long)len); (unsigned long)len);
pa = mmap (addr, len, prot, flag, fd, off); pa = mmap (addr, len, prot, flag, fd, off);
if (pa == MAP_FAILED && errno == ENOMEM) if (pa == MAP_FAILED && errno == ENOMEM)
{ {
printf ("Test Pass: " TNAME " Get ENOMEM: %s\n", printf ("Test Pass: " TNAME " Get ENOMEM: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_PASS); exit(PTS_PASS);
} }
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
perror("Error at mmap()"); perror("Error at mmap()");
else else
@@ -1,24 +1,24 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* MPR An implementation may permit accesses other than those specified by prot; * MPR An implementation may permit accesses other than those specified by prot;
* however, if the Memory Protection option is supported, the implementation * however, if the Memory Protection option is supported, the implementation
* shall not permit a write to succeed where PROT_WRITE has not been set or * shall not permit a write to succeed where PROT_WRITE has not been set or
* shall not permit any access where PROT_NONE alone has been set. * shall not permit any access where PROT_NONE alone has been set.
* The implementation shall support at least the following values of prot: * The implementation shall support at least the following values of prot:
* PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of PROT_READ and * PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of PROT_READ and
* PROT_WRITE. * PROT_WRITE.
* *
* Test Step: * Test Step:
* *
* If Memory Protection option is supported: * If Memory Protection option is supported:
* 1. Spawn a child process. * 1. Spawn a child process.
* 2. The child process mmap a memory region setting prot as PROT_READ. * 2. The child process mmap a memory region setting prot as PROT_READ.
* 3. Try to write the mapped memory. * 3. Try to write the mapped memory.
* 4. If the writing triger SIGSEGV, the PASS. * 4. If the writing triger SIGSEGV, the PASS.
* *
* Please refer to IEEE_1003.1-2001. 2.8.3.3 Memory Protection. * Please refer to IEEE_1003.1-2001. 2.8.3.3 Memory Protection.
*/ */
@@ -35,16 +35,16 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "mmap/6-1.c" #define TNAME "mmap/6-1.c"
int main() int main()
{ {
#ifdef _POSIX_MEMORY_PROTECTION #ifdef _POSIX_MEMORY_PROTECTION
char tmpfname[256]; char tmpfname[256];
int total_size = 1024; int total_size = 1024;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t size = total_size; size_t size = total_size;
int flag = MAP_SHARED; int flag = MAP_SHARED;
@@ -58,39 +58,39 @@ int main()
int status; int status;
int sig_num; int sig_num;
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_6_1_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_6_1_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
child = fork(); child = fork();
if (child == 0) if (child == 0)
{ {
if(ftruncate(fd, total_size) == -1) if(ftruncate(fd, total_size) == -1)
{ {
printf(TNAME "Error at ftruncate(): %s\n", printf(TNAME "Error at ftruncate(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
prot = PROT_READ; prot = PROT_READ;
pa = mmap(addr, size, prot, flag, fd, off); pa = mmap(addr, size, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf("Test Fail: " TNAME " Error at mmap: %s\n", printf("Test Fail: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
ch = pa; ch = pa;
*ch = 'b'; *ch = 'b';
@@ -103,10 +103,10 @@ int main()
if (WIFSTOPPED(status)) if (WIFSTOPPED(status))
{ {
sig_num = WSTOPSIG(status); sig_num = WSTOPSIG(status);
printf("Child process stopped by signal %d\n", sig_num); printf("Child process stopped by signal %d\n", sig_num);
if (sig_num == SIGSEGV) if (sig_num == SIGSEGV)
{ {
printf("Test Pass: " TNAME printf("Test Pass: " TNAME
" Got SIGSEGV when writing to the mapped memory, " " Got SIGSEGV when writing to the mapped memory, "
"without setting PROT_WRITE\n"); "without setting PROT_WRITE\n");
return PTS_PASS; return PTS_PASS;
@@ -115,10 +115,10 @@ int main()
if (WIFSIGNALED(status)) if (WIFSIGNALED(status))
{ {
sig_num = WTERMSIG(status); sig_num = WTERMSIG(status);
printf("Child process terminated by signal %d\n", sig_num); printf("Child process terminated by signal %d\n", sig_num);
if (sig_num == SIGSEGV) if (sig_num == SIGSEGV)
{ {
printf ("Test Pass: " TNAME printf ("Test Pass: " TNAME
" Got SIGSEGV when writing to the mapped memory, " " Got SIGSEGV when writing to the mapped memory, "
"without setting PROT_WRITE\n"); "without setting PROT_WRITE\n");
return PTS_PASS; return PTS_PASS;
@@ -128,7 +128,7 @@ int main()
{ {
if (WEXITSTATUS(status) == 0) if (WEXITSTATUS(status) == 0)
{ {
printf ("Test FAIL: " TNAME printf ("Test FAIL: " TNAME
" Did not got SIGSEGV when writing to the mapped memory," " Did not got SIGSEGV when writing to the mapped memory,"
" without setting PROT_WRITE\n"); " without setting PROT_WRITE\n");
return PTS_FAIL; return PTS_FAIL;
@@ -139,9 +139,9 @@ int main()
} }
#else #else
printf ("Test Unresolved: " TNAME printf ("Test Unresolved: " TNAME
" _POSIX_MEMORY_PROTECTION not defined\n"); " _POSIX_MEMORY_PROTECTION not defined\n");
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
#endif #endif
} }
@@ -1,25 +1,25 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* MPR An implementation may permit accesses other than those specified by prot; * MPR An implementation may permit accesses other than those specified by prot;
* however, if the Memory Protection option is supported, the implementation * however, if the Memory Protection option is supported, the implementation
* shall not permit a write to succeed where PROT_WRITE has not been set or * shall not permit a write to succeed where PROT_WRITE has not been set or
* shall not permit any access where PROT_NONE alone has been set. * shall not permit any access where PROT_NONE alone has been set.
* The implementation shall support at least the following values of prot: * The implementation shall support at least the following values of prot:
* PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of PROT_READ and * PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of PROT_READ and
* PROT_WRITE. * PROT_WRITE.
* *
* Test Step: * Test Step:
* *
* If the Memory Protection option is supported: * If the Memory Protection option is supported:
* *
* 1. Spawn a child process. * 1. Spawn a child process.
* 2. The child process mmap a memory region setting prot as PROT_NONE. * 2. The child process mmap a memory region setting prot as PROT_NONE.
* 3. Try to read the mapped memory. * 3. Try to read the mapped memory.
* 4. If the read will triger SIGSEGV, the PASS. * 4. If the read will triger SIGSEGV, the PASS.
* *
* Please refer to IEEE_1003.1-2001. 2.8.3.3 Memory Protection. * Please refer to IEEE_1003.1-2001. 2.8.3.3 Memory Protection.
*/ */
@@ -38,7 +38,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "mmap/6-2.c" #define TNAME "mmap/6-2.c"
int main() int main()
@@ -47,9 +47,9 @@ int main()
#ifdef _POSIX_MEMORY_PROTECTION #ifdef _POSIX_MEMORY_PROTECTION
char tmpfname[256]; char tmpfname[256];
char* data; char* data;
int total_size = 1024; int total_size = 1024;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t size = total_size; size_t size = total_size;
int flag = MAP_SHARED; int flag = MAP_SHARED;
@@ -63,49 +63,49 @@ int main()
int status; int status;
int sig_num; int sig_num;
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_6_2_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_6_2_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
child = fork(); child = fork();
if (child == 0) if (child == 0)
{ {
fflush (NULL); fflush (NULL);
data = (char *) malloc(total_size); data = (char *) malloc(total_size);
memset(data, 'a', total_size); memset(data, 'a', total_size);
if (write(fd, data, total_size) != total_size) if (write(fd, data, total_size) != total_size)
{ {
printf(TNAME "Error at write(): %s\n", printf(TNAME "Error at write(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
free(data); free(data);
prot = PROT_NONE; prot = PROT_NONE;
pa = mmap(addr, size, prot, flag, fd, off); pa = mmap(addr, size, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf("Test Fail: " TNAME " Error at mmap: %s\n", printf("Test Fail: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
ch = pa; ch = pa;
/* Read acess */ /* Read acess */
if(*ch != 'a') if(*ch != 'a')
{ {
printf ("Test Fail: " TNAME printf ("Test Fail: " TNAME
" The file did not mapped to memory\n"); " The file did not mapped to memory\n");
exit(PTS_FAIL); exit(PTS_FAIL);
} }
exit(0); exit(0);
@@ -119,44 +119,44 @@ int main()
sig_num = WSTOPSIG(status); sig_num = WSTOPSIG(status);
if (sig_num == SIGSEGV) if (sig_num == SIGSEGV)
{ {
printf("Test Pass: " TNAME printf("Test Pass: " TNAME
" Got SIGSEGV when reading the mapped memory, " " Got SIGSEGV when reading the mapped memory, "
"setting PROT_NONE\n"); "setting PROT_NONE\n");
return PTS_PASS; return PTS_PASS;
} }
printf("Child process stopped by signal %d\n", sig_num); printf("Child process stopped by signal %d\n", sig_num);
} }
if (WIFSIGNALED(status)) if (WIFSIGNALED(status))
{ {
sig_num = WTERMSIG(status); sig_num = WTERMSIG(status);
if (sig_num == SIGSEGV) if (sig_num == SIGSEGV)
{ {
printf ("Test Pass: " TNAME printf ("Test Pass: " TNAME
" Got SIGSEGV when reading the mapped memory, " " Got SIGSEGV when reading the mapped memory, "
" setting PROT_NOTE\n"); " setting PROT_NOTE\n");
return PTS_PASS; return PTS_PASS;
} }
printf("Child process terminated by signal %d\n", sig_num); printf("Child process terminated by signal %d\n", sig_num);
} }
if (WIFEXITED(status)) if (WIFEXITED(status))
{ {
if (WEXITSTATUS(status) == 0) if (WEXITSTATUS(status) == 0)
{ {
printf ("Test FAIL: " TNAME printf ("Test FAIL: " TNAME
" Did not got SIGSEGV when reading the mapped memory," " Did not got SIGSEGV when reading the mapped memory,"
" setting PROT_NOTE\n"); " setting PROT_NOTE\n");
return PTS_FAIL; return PTS_FAIL;
} }
} }
printf ("Test Unresolved\n"); printf ("Test Unresolved\n");
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
} }
#else #else
printf ("Test Unresolved: " TNAME printf ("Test Unresolved: " TNAME
" _POSIX_MEMORY_PROTECTION not defined\n"); " _POSIX_MEMORY_PROTECTION not defined\n");
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
#endif #endif
} }
@@ -1,23 +1,23 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* MPR An implementation may permit accesses other than those specified by prot; * MPR An implementation may permit accesses other than those specified by prot;
* however, if the Memory Protection option is supported, the implementation * however, if the Memory Protection option is supported, the implementation
* shall not permit a write to succeed where PROT_WRITE has not been set or * shall not permit a write to succeed where PROT_WRITE has not been set or
* shall not permit any access where PROT_NONE alone has been set. * shall not permit any access where PROT_NONE alone has been set.
* The implementation shall support at least the following values of prot: * The implementation shall support at least the following values of prot:
* PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of PROT_READ and * PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of PROT_READ and
* PROT_WRITE. * PROT_WRITE.
* *
* Test Step: * Test Step:
* If Memory Protection option is suppored: * If Memory Protection option is suppored:
* 1. Spawn a child process. * 1. Spawn a child process.
* 2. The child process mmap a memory region setting prot as PROT_NONE. * 2. The child process mmap a memory region setting prot as PROT_NONE.
* 3. Try to write the mapped memory. * 3. Try to write the mapped memory.
* 4. If the write will triger SIGSEGV, the PASS. * 4. If the write will triger SIGSEGV, the PASS.
* *
* Please refer to IEEE_1003.1-2001. 2.8.3.3 Memory Protection. * Please refer to IEEE_1003.1-2001. 2.8.3.3 Memory Protection.
*/ */
@@ -36,7 +36,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "mmap/6-3.c" #define TNAME "mmap/6-3.c"
int main() int main()
@@ -44,9 +44,9 @@ int main()
#ifdef _POSIX_MEMORY_PROTECTION #ifdef _POSIX_MEMORY_PROTECTION
char tmpfname[256]; char tmpfname[256];
int total_size = 1024; int total_size = 1024;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t size = total_size; size_t size = total_size;
int flag = MAP_SHARED; int flag = MAP_SHARED;
@@ -60,40 +60,40 @@ int main()
int status; int status;
int sig_num; int sig_num;
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_6_3_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_6_3_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
child = fork(); child = fork();
if (child == 0) if (child == 0)
{ {
fflush (NULL); fflush (NULL);
if (ftruncate(fd, total_size) == -1) if (ftruncate(fd, total_size) == -1)
{ {
printf(TNAME "Error at ftruncate(): %s\n", printf(TNAME "Error at ftruncate(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
prot = PROT_NONE; prot = PROT_NONE;
pa = mmap(addr, size, prot, flag, fd, off); pa = mmap(addr, size, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf("Test Fail: " TNAME " Error at mmap: %s\n", printf("Test Fail: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
ch = pa; ch = pa;
/* Write acess */ /* Write acess */
@@ -109,43 +109,43 @@ int main()
sig_num = WSTOPSIG(status); sig_num = WSTOPSIG(status);
if (sig_num == SIGSEGV) if (sig_num == SIGSEGV)
{ {
printf("Test Pass: " TNAME printf("Test Pass: " TNAME
" Got SIGSEGV when writing the mapped memory, " " Got SIGSEGV when writing the mapped memory, "
"setting PROT_NONE\n"); "setting PROT_NONE\n");
return PTS_PASS; return PTS_PASS;
} }
printf("Child process stopped by signal %d\n", sig_num); printf("Child process stopped by signal %d\n", sig_num);
} }
if (WIFSIGNALED(status)) if (WIFSIGNALED(status))
{ {
sig_num = WTERMSIG(status); sig_num = WTERMSIG(status);
if (sig_num == SIGSEGV) if (sig_num == SIGSEGV)
{ {
printf ("Test Pass: " TNAME printf ("Test Pass: " TNAME
" Got SIGSEGV when writing the mapped memory, " " Got SIGSEGV when writing the mapped memory, "
" setting PROT_NOTE\n"); " setting PROT_NOTE\n");
return PTS_PASS; return PTS_PASS;
} }
printf("Child process terminated by signal %d\n", sig_num); printf("Child process terminated by signal %d\n", sig_num);
} }
if (WIFEXITED(status)) if (WIFEXITED(status))
{ {
if (WEXITSTATUS(status) == 0) if (WEXITSTATUS(status) == 0)
{ {
printf ("Test FAIL: " TNAME printf ("Test FAIL: " TNAME
" Did not got SIGSEGV when writing the mapped memory," " Did not got SIGSEGV when writing the mapped memory,"
" setting PROT_NOTE\n"); " setting PROT_NOTE\n");
return PTS_FAIL; return PTS_FAIL;
} }
} }
printf ("Test Unresolved\n"); printf ("Test Unresolved\n");
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
} }
#else #else
printf ("Test Unresolved: " TNAME printf ("Test Unresolved: " TNAME
" _POSIX_MEMORY_PROTECTION not defined\n"); " _POSIX_MEMORY_PROTECTION not defined\n");
return PTS_UNRESOLVED; return PTS_UNRESOLVED;
#endif #endif
} }
@@ -1,14 +1,14 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* The munmap( ) function shall remove any mappings for those * The munmap( ) function shall remove any mappings for those
* entire pages containing any part of the address space of * entire pages containing any part of the address space of
* the process starting at addr and continuing for len bytes. * the process starting at addr and continuing for len bytes.
* Further references to these pages shall result in the * Further references to these pages shall result in the
* generation of a SIGSEGV signal to the process. * generation of a SIGSEGV signal to the process.
* *
* Test Step: * Test Step:
* 1. map a file into memory; * 1. map a file into memory;
@@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "munmap/1-1.c" #define TNAME "munmap/1-1.c"
void sigsegv_handler(int signum) void sigsegv_handler(int signum)
@@ -44,9 +44,9 @@ void sigsegv_handler(int signum)
int main() int main()
{ {
char tmpfname[256]; char tmpfname[256];
long file_size; long file_size;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t len; size_t len;
int flag; int flag;
@@ -55,66 +55,66 @@ int main()
int prot; int prot;
int page_size; int page_size;
char *ch1; char *ch1;
struct sigaction sa; struct sigaction sa;
sigfillset(&sa.sa_mask); sigfillset(&sa.sa_mask);
sa.sa_handler = sigsegv_handler; sa.sa_handler = sigsegv_handler;
sigaction(SIGSEGV, &sa, NULL); sigaction(SIGSEGV, &sa, NULL);
page_size = sysconf(_SC_PAGE_SIZE); page_size = sysconf(_SC_PAGE_SIZE);
file_size = 2 * page_size; file_size = 2 * page_size;
/* We hope to map 2 pages */ /* We hope to map 2 pages */
len = page_size + 1; len = page_size + 1;
/* Create tmp file */ /* Create tmp file */
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
if (ftruncate (fd, file_size) == -1) if (ftruncate (fd, file_size) == -1)
{ {
printf("Error at ftruncate: %s\n", strerror(errno)); printf("Error at ftruncate: %s\n", strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
flag = MAP_SHARED; flag = MAP_SHARED;
prot = PROT_READ | PROT_WRITE; prot = PROT_READ | PROT_WRITE;
pa = mmap(addr, len, prot, flag, fd, off); pa = mmap(addr, len, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf ("Test UNRESOLVED: " TNAME " Error at mmap: %s\n", printf ("Test UNRESOLVED: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
/* ch1 is outside the mapped object, but in the mapped file */ /* ch1 is outside the mapped object, but in the mapped file */
ch1 = pa + len + 1; ch1 = pa + len + 1;
*ch1 = 'b'; *ch1 = 'b';
close (fd); close (fd);
if (munmap (pa, len) == -1) if (munmap (pa, len) == -1)
{ {
printf ("Test FAILED: " TNAME " Error at munmap: %s\n", printf ("Test FAILED: " TNAME " Error at munmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
/* Try to reference the unmapped area, should trigger SIGSEGV */ /* Try to reference the unmapped area, should trigger SIGSEGV */
*ch1 = 'a'; *ch1 = 'a';
/* If reach this point, test fail */ /* If reach this point, test fail */
printf ("Test FAILED: Did not trigger SIGSEGV\n"); printf ("Test FAILED: Did not trigger SIGSEGV\n");
return PTS_FAIL; return PTS_FAIL;
@@ -1,19 +1,19 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* The munmap( ) function shall remove any mappings for those * The munmap( ) function shall remove any mappings for those
* entire pages containing any part of the address space of * entire pages containing any part of the address space of
* the process starting at addr and continuing for len bytes. * the process starting at addr and continuing for len bytes.
* Further references to these pages shall result in the * Further references to these pages shall result in the
* generation of a SIGSEGV signal to the process. * generation of a SIGSEGV signal to the process.
* *
* Test Step: * Test Step:
* 1. map a file into memory; * 1. map a file into memory;
* 2. unmap; * 2. unmap;
* 3. Try to reference the unmapped memory, test whether SIGSEGV * 3. Try to reference the unmapped memory, test whether SIGSEGV
* is triggered. * is triggered.
*/ */
@@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "munmap/1-2.c" #define TNAME "munmap/1-2.c"
void sigsegv_handler(int signum) void sigsegv_handler(int signum)
@@ -44,9 +44,9 @@ void sigsegv_handler(int signum)
int main() int main()
{ {
char tmpfname[256]; char tmpfname[256];
long file_size; long file_size;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t len; size_t len;
int flag; int flag;
@@ -55,60 +55,60 @@ int main()
int prot; int prot;
int page_size; int page_size;
char *ch; char *ch;
struct sigaction sa; struct sigaction sa;
sigfillset(&sa.sa_mask); sigfillset(&sa.sa_mask);
sa.sa_handler = sigsegv_handler; sa.sa_handler = sigsegv_handler;
sigaction(SIGSEGV, &sa, NULL); sigaction(SIGSEGV, &sa, NULL);
page_size = sysconf(_SC_PAGE_SIZE); page_size = sysconf(_SC_PAGE_SIZE);
file_size = 2 * page_size; file_size = 2 * page_size;
/* We hope to map 2 pages */ /* We hope to map 2 pages */
len = page_size + 1; len = page_size + 1;
/* Create tmp file */ /* Create tmp file */
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
if (ftruncate (fd, file_size) == -1) if (ftruncate (fd, file_size) == -1)
{ {
printf("Error at ftruncate: %s\n", strerror(errno)); printf("Error at ftruncate: %s\n", strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
flag = MAP_SHARED; flag = MAP_SHARED;
prot = PROT_READ | PROT_WRITE; prot = PROT_READ | PROT_WRITE;
pa = mmap(addr, len, prot, flag, fd, off); pa = mmap(addr, len, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf ("Test UNRESOLVED: " TNAME " Error at mmap: %s\n", printf ("Test UNRESOLVED: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
ch = pa; ch = pa;
*ch = 'b'; *ch = 'b';
close (fd); close (fd);
munmap (pa, len); munmap (pa, len);
/* Should trigger SIGSEGV here */ /* Should trigger SIGSEGV here */
*ch = 'a'; *ch = 'a';
printf ("Test FAILED: Did not trigger SIGSEGV\n"); printf ("Test FAILED: Did not trigger SIGSEGV\n");
return PTS_FAIL; return PTS_FAIL;
} }
@@ -1,12 +1,12 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* The implementation shall require that addr be a multiple * The implementation shall require that addr be a multiple
* of the page size {PAGESIZE}. * of the page size {PAGESIZE}.
* *
* Test step: * Test step:
* Try to call unmap, with addr NOT a multiple of page size. * Try to call unmap, with addr NOT a multiple of page size.
* Should get EINVAL. * Should get EINVAL.
@@ -26,15 +26,15 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "munmap/3-1.c" #define TNAME "munmap/3-1.c"
int main() int main()
{ {
char tmpfname[256]; char tmpfname[256];
long file_size; long file_size;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t len; size_t len;
int flag; int flag;
@@ -43,43 +43,43 @@ int main()
int prot; int prot;
int page_size; int page_size;
char *pa2; char *pa2;
page_size = sysconf(_SC_PAGE_SIZE); page_size = sysconf(_SC_PAGE_SIZE);
file_size = 2 * page_size; file_size = 2 * page_size;
/* We hope to map 2 pages */ /* We hope to map 2 pages */
len = page_size + 1; len = page_size + 1;
/* Create tmp file */ /* Create tmp file */
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
if (ftruncate (fd, file_size) == -1) if (ftruncate (fd, file_size) == -1)
{ {
printf("Error at ftruncate: %s\n", strerror(errno)); printf("Error at ftruncate: %s\n", strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
flag = MAP_SHARED; flag = MAP_SHARED;
prot = PROT_READ | PROT_WRITE; prot = PROT_READ | PROT_WRITE;
pa = mmap(addr, len, prot, flag, fd, off); pa = mmap(addr, len, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf ("Test Unresolved: " TNAME " Error at mmap: %s\n", printf ("Test Unresolved: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
@@ -88,18 +88,18 @@ int main()
while (((unsigned long)pa2 % page_size) == 0) while (((unsigned long)pa2 % page_size) == 0)
pa2++; pa2++;
close (fd); close (fd);
if (munmap (pa2, len) == -1 && errno == EINVAL) if (munmap (pa2, len) == -1 && errno == EINVAL)
{ {
printf ("Got EINVAL\n"); printf ("Got EINVAL\n");
printf ("Test PASSED\n"); printf ("Test PASSED\n");
exit(PTS_PASS); exit(PTS_PASS);
} }
else else
{ {
printf ("Test FAILED: " TNAME " munmap returns: %s\n", printf ("Test FAILED: " TNAME " munmap returns: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
} }
@@ -1,11 +1,11 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* *
* If a mapping to be removed was private, any modifications * If a mapping to be removed was private, any modifications
* made in this address range shall be discarded. * made in this address range shall be discarded.
* *
* Test Step: * Test Step:
@@ -14,7 +14,7 @@
* the file; * the file;
* 3. munmap the mapped memory; * 3. munmap the mapped memory;
* 4. mmap the same file again into memory; * 4. mmap the same file again into memory;
* 5. If the modification in step 2 appears in the mapped memory, then fail, * 5. If the modification in step 2 appears in the mapped memory, then fail,
* otherwise pass. * otherwise pass.
*/ */
@@ -32,18 +32,18 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "munmap/4-1.c" #define TNAME "munmap/4-1.c"
int main() int main()
{ {
int rc; int rc;
char tmpfname[256]; char tmpfname[256];
char* data; char* data;
int total_size = 1024; int total_size = 1024;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t size = total_size; size_t size = total_size;
int flag; int flag;
@@ -53,39 +53,39 @@ int main()
char * ch; char * ch;
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_4_1_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_4_1_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
data = (char *) malloc(total_size); data = (char *) malloc(total_size);
memset(data, 'a', total_size); memset(data, 'a', total_size);
if (write(fd, data, total_size) != total_size) if (write(fd, data, total_size) != total_size)
{ {
printf(TNAME "Error at write(): %s\n", printf(TNAME "Error at write(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
free(data); free(data);
prot = PROT_READ | PROT_WRITE; prot = PROT_READ | PROT_WRITE;
flag = MAP_PRIVATE; flag = MAP_PRIVATE;
pa = mmap(addr, size, prot, flag, fd, off); pa = mmap(addr, size, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf("Test Fail: " TNAME " Error at mmap: %s\n", printf("Test Fail: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
ch = pa; ch = pa;
*ch = 'b'; *ch = 'b';
@@ -93,25 +93,25 @@ int main()
if ((rc =msync(pa, size, MS_SYNC)) != 0) if ((rc =msync(pa, size, MS_SYNC)) != 0)
{ {
printf(TNAME " Error at msync(): %s\n", printf(TNAME " Error at msync(): %s\n",
strerror(rc)); strerror(rc));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
munmap(pa, size); munmap(pa, size);
/* Mmap again */ /* Mmap again */
pa = mmap(addr, size, prot, flag, fd, off); pa = mmap(addr, size, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf("Test Fail: " TNAME " Error at 2nd mmap: %s\n", printf("Test Fail: " TNAME " Error at 2nd mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_FAIL); exit(PTS_FAIL);
} }
ch = pa; ch = pa;
if (*ch == 'b') if (*ch == 'b')
{ {
printf("Test FAIL\n"); printf("Test FAIL\n");
exit(PTS_FAIL); exit(PTS_FAIL);
@@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2002, Intel Corporation. All rights reserved. * Copyright (c) 2002, Intel Corporation. All rights reserved.
* This file is licensed under the GPL license. For the full content * This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this * of this license, see the COPYING file at the top level of this
* source tree. * source tree.
* *
* The munmap( ) function shall fail if: * The munmap( ) function shall fail if:
@@ -23,15 +23,15 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "posixtest.h" #include "posixtest.h"
#define TNAME "munmap/9-1.c" #define TNAME "munmap/9-1.c"
int main() int main()
{ {
char tmpfname[256]; char tmpfname[256];
long file_size; long file_size;
void *pa = NULL; void *pa = NULL;
void *addr = NULL; void *addr = NULL;
size_t len; size_t len;
int flag; int flag;
@@ -40,50 +40,50 @@ int main()
int prot; int prot;
int page_size; int page_size;
page_size = sysconf(_SC_PAGE_SIZE); page_size = sysconf(_SC_PAGE_SIZE);
file_size = 2 * page_size; file_size = 2 * page_size;
/* We hope to map 2 pages */ /* We hope to map 2 pages */
len = page_size + 1; len = page_size + 1;
/* Create tmp file */ /* Create tmp file */
snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%d", snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_munmap_1_1_%ld",
getpid()); (long)getpid());
unlink(tmpfname); unlink(tmpfname);
fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd == -1) if (fd == -1)
{ {
printf(TNAME " Error at open(): %s\n", printf(TNAME " Error at open(): %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
unlink(tmpfname); unlink(tmpfname);
if (ftruncate (fd, file_size) == -1) if (ftruncate (fd, file_size) == -1)
{ {
printf("Error at ftruncate: %s\n", strerror(errno)); printf("Error at ftruncate: %s\n", strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
flag = MAP_SHARED; flag = MAP_SHARED;
prot = PROT_READ | PROT_WRITE; prot = PROT_READ | PROT_WRITE;
pa = mmap(addr, len, prot, flag, fd, off); pa = mmap(addr, len, prot, flag, fd, off);
if (pa == MAP_FAILED) if (pa == MAP_FAILED)
{ {
printf ("Test Unresolved: " TNAME " Error at mmap: %s\n", printf ("Test Unresolved: " TNAME " Error at mmap: %s\n",
strerror(errno)); strerror(errno));
exit(PTS_UNRESOLVED); exit(PTS_UNRESOLVED);
} }
close (fd); close (fd);
/* Set len as 0 */ /* Set len as 0 */
if (munmap (pa, 0) == -1 && errno == EINVAL) if (munmap (pa, 0) == -1 && errno == EINVAL)
{ {
printf ("Get EINVAL when len=0\n"); printf ("Get EINVAL when len=0\n");
printf ("Test PASSED\n"); printf ("Test PASSED\n");
exit(PTS_PASS); exit(PTS_PASS);
} }
else else