[PATCH] D17639: [asan] Fix recvfrom.cc testcase failure in large parallel tests run.

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 03:50:36 PST 2016


filcab added a subscriber: filcab.
filcab added a comment.

Shouldn't all this be in `TestCases/Posix`?


================
Comment at: compiler-rt/trunk/test/asan/TestCases/Linux/recvfrom.cc:16
@@ -16,10 +15,3 @@
 
-const int kPortNum = 1234;
-const int kBufSize = 10;
-
-static void *server_thread_udp(void *data) {
-  char buf[kBufSize / 2];
-  struct sockaddr_in serveraddr; // server's addr
-  int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
-  if (sockfd < 0)
-    fprintf(stderr, "ERROR opening socket\n");
+#define CHECK_ERROR(p, m)                                                      \
+  do {                                                                         \
----------------
Maybe use `perror`?

We can even do something like:
```
#define CHECK_ERROR(p, name)                                                   \
  do {                                                                         \
    if (p) {                                                                   \
      perror(#name);                                                           \
      exit(1);                                                                 \
    } else {                                                                   \
      printf("%s succeeded.\n", #name);                                        \
    }                                                                          \
  }

...
CHECK_ERROR(succeeded < 0, getsockname);
// CHECK: getsockname succeeded.
```

That way, even though we're slightly more noisy when there's no error (and with the `CHECK` lines), you should immediately see the proper error string when the test fails, since `FileCheck` will fail on that line.
(Then again, `FileCheck` might show the appropriate line already, so no need to switch that part (except for `perror`).


Repository:
  rL LLVM

http://reviews.llvm.org/D17639





More information about the llvm-commits mailing list