1 /* 2 * Copyright (c) 2002, Intel Corporation. All rights reserved. 3 * This file is licensed under the GPL license. For the full content 4 * of this license, see the COPYING file at the top level of this 5 * source tree. 6 * 7 * The fsync() function shall fail if: 8 * [EINVAL] The fildes argument does not refer to a file 9 * on which this operation is possible. 10 * 11 * Test Step: 12 * 1. Create a pipe; 13 * 2. fsync on the pipe, should fail with EINVAL; 14 * 15 */ 16 17 #include <stdio.h> 18 #include <stdlib.h> 19 #include <unistd.h> 20 #include <sys/mman.h> 21 #include <sys/types.h> 22 #include <sys/stat.h> 23 #include <fcntl.h> 24 #include <string.h> 25 #include <errno.h> 26 #include "posixtest.h" 27 28 #define TNAME "fsync/7-1.c" 29 main(void)30int main(void) 31 { 32 int fd[2]; 33 34 if (pipe(fd) == -1) { 35 printf(TNAME " Test UNRESOLVED: Error at pipe: %s\n", 36 strerror(errno)); 37 exit(PTS_UNRESOLVED); 38 } 39 40 if (fsync(fd[1]) == -1 && errno == EINVAL) { 41 printf("Got EINVAL when fsync on pipe\n"); 42 printf("Test PASSED\n"); 43 close(fd[0]); 44 close(fd[1]); 45 exit(PTS_PASS); 46 } else { 47 printf(TNAME " Test Fail: Expect EINVAL, get: %s\n", 48 strerror(errno)); 49 close(fd[0]); 50 close(fd[1]); 51 exit(PTS_FAIL); 52 } 53 } 54