From 6e09722b27ed4d48dfc668b0efc2aed88d701ebf Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 3 Sep 2020 11:20:29 -0700 Subject: [PATCH] [test] Use %t instead of %T to remove race conditions between config-file3.c and target-override.c Both tests operate on `%T/testbin`. If the two tests run concurrently, one may fail. This is likely the root cause of flaky failures reported by https://lists.llvm.org/pipermail/llvm-dev/2020-September/144781.html https://llvm.org/docs/CommandGuide/lit.html says: `%T parent directory of %t (not unique, deprecated, do not use)` Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D87103 --- clang/test/Driver/config-file3.c | 62 ++++++++++++++--------------- clang/test/Driver/target-override.c | 9 ++--- 2 files changed, 34 insertions(+), 37 deletions(-) diff --git a/clang/test/Driver/config-file3.c b/clang/test/Driver/config-file3.c index 148646c2ebbf..fc5c286553ad 100644 --- a/clang/test/Driver/config-file3.c +++ b/clang/test/Driver/config-file3.c @@ -1,14 +1,15 @@ // REQUIRES: shell // REQUIRES: x86-registered-target +// RUN: rm -rf %t && mkdir %t + //--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by that path. + +// RUN: mkdir -p %t/workdir/subdir +// RUN: echo "@subdir/cfg-s2" > %t/workdir/cfg-1 +// RUN: echo "-Wundefined-var-template" > %t/workdir/subdir/cfg-s2 // -// RUN: mkdir -p %T/workdir -// RUN: echo "@subdir/cfg-s2" > %T/workdir/cfg-1 -// RUN: mkdir -p %T/workdir/subdir -// RUN: echo "-Wundefined-var-template" > %T/workdir/subdir/cfg-s2 -// -// RUN: ( cd %T && %clang --config workdir/cfg-1 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-REL ) +// RUN: ( cd %t && %clang --config workdir/cfg-1 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-REL ) // // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1 // CHECK-REL: -Wundefined-var-template @@ -16,12 +17,11 @@ //--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first. // -// RUN: rm -rf %T/testdmode -// RUN: mkdir -p %T/testdmode -// RUN: ln -s %clang %T/testdmode/qqq-clang-g++ -// RUN: echo "-Wundefined-func-template" > %T/testdmode/qqq-clang-g++.cfg -// RUN: echo "-Werror" > %T/testdmode/qqq.cfg -// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix FULL-NAME +// RUN: mkdir %t/testdmode +// RUN: ln -s %clang %t/testdmode/qqq-clang-g++ +// RUN: echo "-Wundefined-func-template" > %t/testdmode/qqq-clang-g++.cfg +// RUN: echo "-Werror" > %t/testdmode/qqq.cfg +// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix FULL-NAME // // FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg // FULL-NAME: -Wundefined-func-template @@ -31,20 +31,20 @@ // (As the clang executable and symlink are in different directories, this // requires specifying the path via --config-*-dir= though.) // -// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%T/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix SYMLINK +// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%t/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix SYMLINK // // SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg // //--- File specified by --config overrides config inferred from clang executable. // -// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT +// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT // // CHECK-EXPLICIT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg // //--- Invocation qqq-clang-g++ tries to find config file qqq.cfg if qqq-clang-g++.cfg is not found. // -// RUN: rm %T/testdmode/qqq-clang-g++.cfg -// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix SHORT-NAME +// RUN: rm %t/testdmode/qqq-clang-g++.cfg +// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix SHORT-NAME // // SHORT-NAME: Configuration file: {{.*}}/testdmode/qqq.cfg // SHORT-NAME: -Werror @@ -53,11 +53,10 @@ //--- Config files are searched for in binary directory as well. // -// RUN: rm -rf %T/testbin -// RUN: mkdir -p %T/testbin -// RUN: ln -s %clang %T/testbin/clang -// RUN: echo "-Werror" > %T/testbin/aaa.cfg -// RUN: %T/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN +// RUN: mkdir %t/testbin +// RUN: ln -s %clang %t/testbin/clang +// RUN: echo "-Werror" > %t/testbin/aaa.cfg +// RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN // // CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg // CHECK-BIN: -Werror @@ -68,12 +67,11 @@ //--- When reloading config file, x86_64-clang-g++ tries to find config i386-clang-g++.cfg first. // -// RUN: rm -rf %T/testreload -// RUN: mkdir -p %T/testreload -// RUN: ln -s %clang %T/testreload/x86_64-clang-g++ -// RUN: echo "-Wundefined-func-template" > %T/testreload/i386-clang-g++.cfg -// RUN: echo "-Werror" > %T/testreload/i386.cfg -// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD +// RUN: mkdir %t/testreload +// RUN: ln -s %clang %t/testreload/x86_64-clang-g++ +// RUN: echo "-Wundefined-func-template" > %t/testreload/i386-clang-g++.cfg +// RUN: echo "-Werror" > %t/testreload/i386.cfg +// RUN: %t/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD // // CHECK-RELOAD: Configuration file: {{.*}}/testreload/i386-clang-g++.cfg // CHECK-RELOAD: -Wundefined-func-template @@ -81,24 +79,24 @@ //--- If config file is specified by --config and its name does not start with architecture, it is used without reloading. // -// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1a +// RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1a // // CHECK-RELOAD1a: Configuration file: {{.*}}/Inputs/config-3.cfg // -// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -target i386 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1b +// RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -target i386 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1b // // CHECK-RELOAD1b: Configuration file: {{.*}}/Inputs/config-3.cfg //--- If config file is specified by --config and its name starts with architecture, it is reloaded. // -// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1c +// RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1c // // CHECK-RELOAD1c: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg //--- x86_64-clang-g++ tries to find config i386.cfg if i386-clang-g++.cfg is not found. // -// RUN: rm %T/testreload/i386-clang-g++.cfg -// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1d +// RUN: rm %t/testreload/i386-clang-g++.cfg +// RUN: %t/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1d // // CHECK-RELOAD1d: Configuration file: {{.*}}/testreload/i386.cfg // CHECK-RELOAD1d: -Werror diff --git a/clang/test/Driver/target-override.c b/clang/test/Driver/target-override.c index b4dbd2da1df6..ddda8aaad85a 100644 --- a/clang/test/Driver/target-override.c +++ b/clang/test/Driver/target-override.c @@ -1,16 +1,15 @@ // REQUIRES: shell // REQUIRES: x86-registered-target -// RUN: rm -rf %T/testbin -// RUN: mkdir -p %T/testbin -// RUN: ln -s %clang %T/testbin/i386-clang +// RUN: rm -rf %t && mkdir %t +// RUN: ln -s %clang %t/i386-clang // Check if invocation of "foo-clang" adds option "-target foo". // -// RUN: %T/testbin/i386-clang -c -no-canonical-prefixes %s -### 2>&1 | FileCheck -check-prefix CHECK-TG1 %s +// RUN: %t/i386-clang -c -no-canonical-prefixes %s -### 2>&1 | FileCheck -check-prefix CHECK-TG1 %s // CHECK-TG1: Target: i386 // Check if invocation of "foo-clang -target bar" overrides option "-target foo". // -// RUN: %T/testbin/i386-clang -c -no-canonical-prefixes -target x86_64 %s -### 2>&1 | FileCheck -check-prefix CHECK-TG2 %s +// RUN: %t/i386-clang -c -no-canonical-prefixes -target x86_64 %s -### 2>&1 | FileCheck -check-prefix CHECK-TG2 %s // CHECK-TG2: Target: x86_64