[NFC][AArch64] Explicitly define undefined bits for instructions (#122129)
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / protoent.cpp
blob91c7cdae58687504e55eb4f4af41f851eabb47ba
1 // RUN: %clangxx -O0 -g %s -o %t
2 //
4 // bionic/netdb.cpp is not implemented.
5 // UNSUPPORTED: android
7 #include <netdb.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <assert.h>
12 void test1() {
13 struct protoent *ptp = getprotoent();
14 assert(ptp && ptp->p_name);
15 assert(ptp->p_proto == 0);
16 char **aliases = ptp->p_aliases;
17 while (aliases) {
18 printf("%s\n", *aliases);
19 aliases++;
21 endprotoent();
24 void test2() {
25 struct protoent *ptp = getprotobyname("tcp");
26 assert(ptp && ptp->p_name);
27 assert(ptp->p_proto == 6);
28 char **aliases = ptp->p_aliases;
29 while (aliases) {
30 printf("%s\n", *aliases);
31 aliases++;
33 endprotoent();
36 void test3() {
37 struct protoent *ptp = getprotobynumber(1);
38 assert(ptp && ptp->p_name);
39 assert(ptp->p_proto == 1);
40 char **aliases = ptp->p_aliases;
41 while (aliases) {
42 printf("%s\n", *aliases);
43 aliases++;
45 endprotoent();
48 void test4() {
49 setprotoent(1);
50 struct protoent *ptp = getprotobynumber(1);
52 ptp = getprotobynumber(2);
53 assert(ptp && ptp->p_name);
54 assert(ptp->p_proto == 2);
55 endprotoent();
58 int main(void) {
59 printf("protoent\n");
61 test1();
62 test2();
63 test3();
64 test4();
66 return 0;