]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/sanitizer_common/TestCases/Posix/devname_r.cc
Vendor import of compiler-rt trunk r338150:
[FreeBSD/FreeBSD.git] / test / sanitizer_common / TestCases / Posix / devname_r.cc
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
2 // UNSUPPORTED: linux, solaris
3
4 #include <sys/cdefs.h>
5 #include <sys/stat.h>
6
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 int main(void) {
11   struct stat st;
12   char name[100];
13   mode_t type;
14
15   if (stat("/dev/null", &st))
16     exit(1);
17
18   type = S_ISCHR(st.st_mode) ? S_IFCHR : S_IFBLK;
19
20   if (!devname_r(st.st_rdev, type, name, sizeof(name)))
21     exit(1);
22
23   printf("%s\n", name);
24
25   // CHECK: null
26
27   return 0;
28 }