diff options
author | Kamil Rytarowski <n54@gmx.com> | 2018-02-27 02:32:04 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2018-02-27 02:32:04 +0000 |
commit | 2332b74dc3067b27a5577ff203789c41d7ca09d8 (patch) | |
tree | bcda94441465338fb79620e16cb1b27e7806de99 /test/sanitizer_common | |
parent | cb26bd2b62ab2eb08d31d848e0c961c5234c490f (diff) |
Add new interceptors: getprotoent(3) family
Summary:
getprotoent, getprotobynumber, getprotobyname - get protocol entry
Reuse them on NetBSD.
Sponsored by <The NetBSD Foundation>
Reviewers: joerg, vitalybuka
Reviewed By: vitalybuka
Subscribers: kubamracek, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D43541
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@326162 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common')
-rw-r--r-- | test/sanitizer_common/TestCases/NetBSD/protoent.cc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/NetBSD/protoent.cc b/test/sanitizer_common/TestCases/NetBSD/protoent.cc new file mode 100644 index 000000000..c88c6f904 --- /dev/null +++ b/test/sanitizer_common/TestCases/NetBSD/protoent.cc @@ -0,0 +1,89 @@ +// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s + +#include <netdb.h> +#include <stdio.h> +#include <stdlib.h> + +#define STRING_OR_NULL(x) ((x) ? (x) : "null") + +void test1() { + struct protoent *ptp = getprotoent(); + + printf("%s ", STRING_OR_NULL(ptp->p_name)); + + for (char **cp = ptp->p_aliases; *cp != NULL; cp++) + printf("%s ", STRING_OR_NULL(*cp)); + + printf("%d\n", ptp->p_proto); + endprotoent(); +} + +void test2() { + struct protoent *ptp = getprotobyname("icmp"); + + printf("%s ", STRING_OR_NULL(ptp->p_name)); + + for (char **cp = ptp->p_aliases; *cp != NULL; cp++) + printf("%s ", STRING_OR_NULL(*cp)); + + printf("%d\n", ptp->p_proto); + endprotoent(); +} + +void test3() { + struct protoent *ptp = getprotobynumber(1); + + printf("%s ", STRING_OR_NULL(ptp->p_name)); + + for (char **cp = ptp->p_aliases; *cp != NULL; cp++) + printf("%s ", STRING_OR_NULL(*cp)); + + printf("%d\n", ptp->p_proto); + endprotoent(); +} + +void test4() { + setprotoent(1); + struct protoent *ptp = getprotobynumber(1); + + ptp = getprotobynumber(2); + + printf("%s ", STRING_OR_NULL(ptp->p_name)); + + for (char **cp = ptp->p_aliases; *cp != NULL; cp++) + printf("%s ", STRING_OR_NULL(*cp)); + + printf("%d\n", ptp->p_proto); + endprotoent(); +} + +void test5() { + struct protoent *ptp = getprotobyname("ttp"); + + printf("%s ", STRING_OR_NULL(ptp->p_name)); + + for (char **cp = ptp->p_aliases; *cp != NULL; cp++) + printf("%s ", STRING_OR_NULL(*cp)); + + printf("%d\n", ptp->p_proto); + endprotoent(); +} + +int main(void) { + printf("protoent\n"); + + test1(); + test2(); + test3(); + test4(); + test5(); + + // CHECK: protoent + // CHECK: hopopt HOPOPT 0 + // CHECK: icmp ICMP 1 + // CHECK: icmp ICMP 1 + // CHECK: igmp IGMP 2 + // CHECK: ttp TTP iptm IPTM 84 + + return 0; +} |