Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / NetBSD / protoent.cpp
blobc88c6f904a4994f09a6bbd810c62940588706dc4
1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
3 #include <netdb.h>
4 #include <stdio.h>
5 #include <stdlib.h>
7 #define STRING_OR_NULL(x) ((x) ? (x) : "null")
9 void test1() {
10 struct protoent *ptp = getprotoent();
12 printf("%s ", STRING_OR_NULL(ptp->p_name));
14 for (char **cp = ptp->p_aliases; *cp != NULL; cp++)
15 printf("%s ", STRING_OR_NULL(*cp));
17 printf("%d\n", ptp->p_proto);
18 endprotoent();
21 void test2() {
22 struct protoent *ptp = getprotobyname("icmp");
24 printf("%s ", STRING_OR_NULL(ptp->p_name));
26 for (char **cp = ptp->p_aliases; *cp != NULL; cp++)
27 printf("%s ", STRING_OR_NULL(*cp));
29 printf("%d\n", ptp->p_proto);
30 endprotoent();
33 void test3() {
34 struct protoent *ptp = getprotobynumber(1);
36 printf("%s ", STRING_OR_NULL(ptp->p_name));
38 for (char **cp = ptp->p_aliases; *cp != NULL; cp++)
39 printf("%s ", STRING_OR_NULL(*cp));
41 printf("%d\n", ptp->p_proto);
42 endprotoent();
45 void test4() {
46 setprotoent(1);
47 struct protoent *ptp = getprotobynumber(1);
49 ptp = getprotobynumber(2);
51 printf("%s ", STRING_OR_NULL(ptp->p_name));
53 for (char **cp = ptp->p_aliases; *cp != NULL; cp++)
54 printf("%s ", STRING_OR_NULL(*cp));
56 printf("%d\n", ptp->p_proto);
57 endprotoent();
60 void test5() {
61 struct protoent *ptp = getprotobyname("ttp");
63 printf("%s ", STRING_OR_NULL(ptp->p_name));
65 for (char **cp = ptp->p_aliases; *cp != NULL; cp++)
66 printf("%s ", STRING_OR_NULL(*cp));
68 printf("%d\n", ptp->p_proto);
69 endprotoent();
72 int main(void) {
73 printf("protoent\n");
75 test1();
76 test2();
77 test3();
78 test4();
79 test5();
81 // CHECK: protoent
82 // CHECK: hopopt HOPOPT 0
83 // CHECK: icmp ICMP 1
84 // CHECK: icmp ICMP 1
85 // CHECK: igmp IGMP 2
86 // CHECK: ttp TTP iptm IPTM 84
88 return 0;