Files
clang-p2996/compiler-rt/test/sanitizer_common/TestCases/Linux/xdrrec.cpp
Stephan Bergmann 2ead4fca79 Test including rpc/xdr.h requires sunrpc
...which is set based on HAVE_RPC_XDR_H.  At least Fedora 32 does not have a
/usr/include/rpc/xdr.h, so failed this test introduced with
<https://reviews.llvm.org/D83358> "[Sanitizers] Add interceptor for
xdrrec_create".

Differential Revision: https://reviews.llvm.org/D84740
2020-07-29 08:20:20 +02:00

28 lines
586 B
C++

// RUN: %clangxx -O0 %s -o %t && %run %t | FileCheck %s
// REQUIRES: sunrpc, !android
#include <cassert>
#include <rpc/xdr.h>
int print_msg(char *handle, char *buf, int len) {
if (len > 0) {
for (size_t i = 0; i < len; i++) {
printf("%02x ", (uint8_t)buf[i]);
}
printf("\n");
}
return len;
}
int main() {
XDR xdrs;
xdrs.x_op = XDR_ENCODE;
xdrrec_create(&xdrs, 0, 0, nullptr, nullptr, print_msg);
unsigned foo = 42;
assert(xdr_u_int(&xdrs, &foo));
assert(xdrrec_endofrecord(&xdrs, /*sendnow*/ true));
xdr_destroy(&xdrs);
}
// CHECK: 00 00 00 2a