tsan: ignore some errors in the clone_setns test
authorDmitry Vyukov <dvyukov@google.com>
Fri, 12 Nov 2021 13:07:23 +0000 (14:07 +0100)
committerDmitry Vyukov <dvyukov@google.com>
Fri, 12 Nov 2021 13:12:36 +0000 (14:12 +0100)
Some bots failed with:
unshare failed: 1
https://lab.llvm.org/buildbot/#/builders/70/builds/14101

Look only for the target EINVAL error.

Differential Revision: https://reviews.llvm.org/D113759

compiler-rt/test/tsan/Linux/clone_setns.cpp

index 25e3034..88acb69 100644 (file)
 #include <sys/wait.h>
 
 static int cloned(void *arg) {
-  if (unshare(CLONE_NEWUSER)) {
+  // Unshare can fail for other reasons, e.g. no permissions,
+  // so check only the error we are interested in:
+  // if the process is multi-threaded unshare must return EINVAL.
+  if (unshare(CLONE_NEWUSER) && errno == EINVAL) {
     fprintf(stderr, "unshare failed: %d\n", errno);
     exit(1);
   }