[PATCH] D60327: [TSan][libdispatch] Add RunLoop helper to ease porting tests

Julian Lettner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 13:00:37 PDT 2019


yln marked 3 inline comments as done.
yln added inline comments.


================
Comment at: compiler-rt/test/tsan/Darwin/gcd-blocks.mm:27
-  CFRunLoopRun();
-  fprintf(stderr, "done\n");
 }
----------------
kubamracek wrote:
> Can we keep the print in main?
We could pass a block that expresses "the rest of the program".
```
RunLoopRun(^{
  fprintf(stderr, "Done.\n");
});
```

I looked at all usages of `CFRunLoopRun` and that's what the block would ever be used for. I agree that having a `CHECK: Done.` line that has no obvious source in the test is ugly, but in this case I would prefer it over the block alternative.
We could also make the check lines more explicit, e.g., `CHECK: RunLoopShutdown`.



================
Comment at: compiler-rt/test/tsan/Darwin/runloop.h:22
+      fprintf(stderr, "Done.\n");
+      exit(0);
+    } else {
----------------
kubamracek wrote:
> Can we somehow exit() from by returning from main instead? That would be much cleaner.
I don't know how to do this. The main crux here is that `dispatch_main` never returns, and doesn't provide a built-in means to stop the run loop. Do you have a suggestion?


================
Comment at: compiler-rt/test/tsan/Darwin/runloop.h:24
+    } else {
+      dispatch_async(dispatch_get_main_queue(), exitBlock);
+    }
----------------
kubamracek wrote:
> This keeps burning the CPU until we exit.
Yes, we could introduce a short sleep for cases where we are waiting on something (i.e., a timer).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60327/new/

https://reviews.llvm.org/D60327





More information about the llvm-commits mailing list