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

Yury Gribov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 04:20:26 PST 2016


ygribov added a comment.

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


We don't have (easy) access to Mac so we are really scared to break it...


================
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 {                                                                         \
----------------
filcab wrote:
> 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`).
We thought about doing a more proper macro but later decided to not invest too much time in it. That's throwaway test code used in just one file anyway.


Repository:
  rL LLVM

http://reviews.llvm.org/D17639





More information about the llvm-commits mailing list