1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s 2 3 #include <assert.h> 4 #include <fcntl.h> 5 #include <stdio.h> 6 #include <stdlib.h> 7 #include <unistd.h> 8 #include <sys/stat.h> 9 test_fdevname()10void test_fdevname() { 11 int fd = open("/dev/null", O_RDONLY); 12 char *name; 13 14 printf("test_fdevname\n"); 15 assert(fd != -1); 16 assert((name = fdevname(fd))); 17 close(fd); 18 19 printf("%s\n", name); 20 } 21 test_fdevname_r()22void test_fdevname_r() { 23 int fd = open("/dev/null", O_RDONLY); 24 char *name; 25 char buf[5]; 26 27 printf("test_fdevname_r\n"); 28 assert(fd != -1); 29 assert((name = fdevname_r(fd, buf, sizeof(buf)))); 30 close(fd); 31 32 printf("%s\n", name); 33 } 34 main(void)35int main(void) { 36 test_fdevname(); 37 test_fdevname_r(); 38 // CHECK: test_fdevname 39 // CHECK: null 40 // CHECK: test_fdevname_r 41 // CHECK: null 42 43 return 0; 44 } 45