Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / NetBSD / netent.cpp
blobb574a931082c4cdde24a2481956458d01bc2286f
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
3 #include <inttypes.h>
4 #include <netdb.h>
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <stdlib.h>
9 #define STRING_OR_NULL(x) ((x) ? (x) : "null")
11 void test1() {
12 struct netent *ntp = getnetent();
14 printf("%s ", ntp->n_name);
16 for (char **cp = ntp->n_aliases; *cp != NULL; cp++)
17 printf("%s ", STRING_OR_NULL(*cp));
19 printf("%d ", ntp->n_addrtype);
20 printf("%" PRIu32 "\n", ntp->n_net);
22 endnetent();
25 void test2() {
26 struct netent *ntp = getnetbyname("loopback");
28 printf("%s ", ntp->n_name);
30 for (char **cp = ntp->n_aliases; *cp != NULL; cp++)
31 printf("%s ", STRING_OR_NULL(*cp));
33 printf("%d ", ntp->n_addrtype);
34 printf("%" PRIu32 "\n", ntp->n_net);
36 endnetent();
39 void test3() {
40 struct netent *ntp = getnetbyaddr(127, 2);
42 printf("%s ", ntp->n_name);
44 for (char **cp = ntp->n_aliases; *cp != NULL; cp++)
45 printf("%s ", STRING_OR_NULL(*cp));
47 printf("%d ", ntp->n_addrtype);
48 printf("%" PRIu32 "\n", ntp->n_net);
50 endnetent();
53 void test4() {
54 setnetent(1);
56 struct netent *ntp = getnetent();
58 printf("%s ", ntp->n_name);
60 for (char **cp = ntp->n_aliases; *cp != NULL; cp++)
61 printf("%s ", STRING_OR_NULL(*cp));
63 printf("%d ", ntp->n_addrtype);
64 printf("%" PRIu32 "\n", ntp->n_net);
66 endnetent();
69 int main(void) {
70 printf("netent\n");
72 test1();
73 test2();
74 test3();
75 test4();
77 // CHECK: netent
78 // CHECK: loopback 2 127
79 // CHECK: loopback 2 127
80 // CHECK: loopback 2 127
81 // CHECK: loopback 2 127
83 return 0;