[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / netent.cpp
blob8104ae0723391438f5cec3826c4305cb6faccff1
1 // RUN: %clangxx -O0 -g %s -o %t
3 // bionic/netdb.cpp is not implemented.
4 // UNSUPPORTED: android
6 #include <inttypes.h>
7 #include <netdb.h>
8 #include <stdint.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <assert.h>
13 #if defined(__linux__)
14 #define LOOPBACK "loopback"
15 #else
16 #define LOOPBACK "your-net"
17 #endif
19 void test1() {
20 struct netent *ntp = getnetent();
21 assert(ntp && ntp->n_name);
22 assert(ntp->n_addrtype == 2);
23 assert(ntp->n_net == 127);
24 char **aliases = ntp->n_aliases;
25 while (aliases) {
26 printf("%s\n", *aliases);
27 aliases++;
29 endnetent();
32 void test2() {
33 struct netent *ntp = getnetbyname(LOOPBACK);
34 assert(ntp && ntp->n_name);
35 assert(ntp->n_addrtype == 2);
36 assert(ntp->n_net == 127);
37 char **aliases = ntp->n_aliases;
38 while (aliases) {
39 printf("%s\n", *aliases);
40 aliases++;
42 endnetent();
45 void test3() {
46 struct netent *lb = getnetbyname(LOOPBACK);
47 assert(lb);
48 struct netent *ntp = getnetbyaddr(lb->n_net, lb->n_addrtype);
49 assert(ntp && ntp->n_name);
50 assert(ntp->n_addrtype == 2);
51 assert(ntp->n_net == 127);
52 char **aliases = ntp->n_aliases;
53 while (aliases) {
54 printf("%s\n", *aliases);
55 aliases++;
57 endnetent();
60 void test4() {
61 setnetent(1);
63 struct netent *ntp = getnetent();
64 assert(ntp && ntp->n_name);
65 assert(ntp->n_addrtype == 2);
66 assert(ntp->n_net == 127);
67 endnetent();
70 int main(void) {
71 printf("netent\n");
73 test1();
74 test2();
75 test3();
76 test4();
78 return 0;