Home | History | Annotate | Download | only in shm_unlink
      1 /*
      2  *  This program is free software; you can redistribute it and/or modify
      3  *  it under the terms of the GNU General Public License version 2.
      4  *
      5  *  This program is distributed in the hope that it will be useful,
      6  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      7  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      8  *  GNU General Public License for more details.
      9  *
     10  * Test that the shm_unlink() function returns zero upon successful completion.
     11  */
     12 
     13 #include <stdio.h>
     14 #include <sys/mman.h>
     15 #include <sys/stat.h>
     16 #include <fcntl.h>
     17 #include "posixtest.h"
     18 
     19 #define SHM_NAME "posixtest_6-1"
     20 
     21 int main(void)
     22 {
     23 	int fd;
     24 
     25 	fd = shm_open(SHM_NAME, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
     26 	if (fd == -1) {
     27 		perror("An error occurs when calling shm_open()");
     28 		return PTS_UNRESOLVED;
     29 	}
     30 
     31 	if (shm_unlink(SHM_NAME) == 0) {
     32 		printf("Test PASSED\n");
     33 		return PTS_PASS;
     34 	} else {
     35 		perror("shm_unlink() does not return zero");
     36 		return PTS_FAIL;
     37 	}
     38 
     39 }
     40