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
10void test_fdevname() {
11 int fd = open(file: "/dev/null", O_RDONLY);
12 char *name;
13
14 printf(format: "test_fdevname\n");
15 assert(fd != -1);
16 assert((name = fdevname(fd)));
17 close(fd: fd);
18
19 printf(format: "%s\n", name);
20}
21
22void test_fdevname_r() {
23 int fd = open(file: "/dev/null", O_RDONLY);
24 char *name;
25 char buf[5];
26
27 printf(format: "test_fdevname_r\n");
28 assert(fd != -1);
29 assert((name = fdevname_r(fd, buf, sizeof(buf))));
30 close(fd: fd);
31
32 printf(format: "%s\n", name);
33}
34
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

source code of compiler-rt/test/sanitizer_common/TestCases/FreeBSD/fdevname.cpp