diff --git a/llvm/test/tools/llvm-ar/error-opening-permission.test b/llvm/test/tools/llvm-ar/error-opening-permission.test index 4107bdfc044fe24af578ad86f963fad796e7c145..b42f95329a3c711590c64dad6d6b369548261c49 100644 --- a/llvm/test/tools/llvm-ar/error-opening-permission.test +++ b/llvm/test/tools/llvm-ar/error-opening-permission.test @@ -1,6 +1,7 @@ ## Unsupported on windows as marking files "unreadable" ## is non-trivial on windows. # UNSUPPORTED: system-windows +# REQUIRES: non-root-user # RUN: rm -rf %t && mkdir -p %t # RUN: echo file1 > %t/1.txt diff --git a/llvm/test/tools/llvm-dwarfdump/X86/output.s b/llvm/test/tools/llvm-dwarfdump/X86/output.s index 37132eb55ca559b20502ddc15853b3da71f724a6..e7c9234ed74cf82aa7725c2e02286dd601f590fc 100644 --- a/llvm/test/tools/llvm-dwarfdump/X86/output.s +++ b/llvm/test/tools/llvm-dwarfdump/X86/output.s @@ -1,3 +1,4 @@ +# REQUIRES: non-root-user # RUN: rm -f %t1.txt %t2.txt %t3.txt # RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o %t.o diff --git a/llvm/test/tools/llvm-ifs/fail-file-write.test b/llvm/test/tools/llvm-ifs/fail-file-write.test index d5232070c1d03a95ca51ae89fc253dd968b330e8..f13500f22620593e4eaf25fb140f6e5a51dead73 100644 --- a/llvm/test/tools/llvm-ifs/fail-file-write.test +++ b/llvm/test/tools/llvm-ifs/fail-file-write.test @@ -1,6 +1,7 @@ ## Test failing to write output file on non-windows platforms. # UNSUPPORTED: system-windows +# REQUIRES: non-root-user # RUN: rm -rf %t.TestDir # RUN: mkdir %t.TestDir # RUN: touch %t.TestDir/Output.TestFile diff --git a/llvm/test/tools/llvm-ranlib/error-opening-permission.test b/llvm/test/tools/llvm-ranlib/error-opening-permission.test index 1b1bb0def78d78b91f43c4c1ec9db1753c6b152a..be56962112e6b63ed9b62cb59238a48d6cee1ac2 100644 --- a/llvm/test/tools/llvm-ranlib/error-opening-permission.test +++ b/llvm/test/tools/llvm-ranlib/error-opening-permission.test @@ -1,5 +1,6 @@ ## Unsupported on windows as marking files "unreadable" is non-trivial on windows. # UNSUPPORTED: system-windows +# REQUIRES: non-root-user # RUN: rm -rf %t && split-file %s %t && cd %t # RUN: yaml2obj 1.yaml -o 1.o diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py index 69ede49dadc5bfdd8780ddd9674e2ded3c7a99aa..6a2ba104403d37df4c22d9eac22a35b38928abb3 100644 --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -13,6 +13,17 @@ from lit.llvm.subst import ToolSubst lit_path_displayed = False +def user_is_root(): + # os.getuid() is not available on all platforms + try: + if os.getuid() == 0: + return True + except: + pass + + return False + + class LLVMConfig(object): def __init__(self, lit_config, config): self.lit_config = lit_config @@ -153,6 +164,9 @@ class LLVMConfig(object): if re.match(r'^ppc64le.*-linux', target_triple): features.add('target=powerpc64le-linux') + if not user_is_root(): + features.add("non-root-user") + use_gmalloc = lit_config.params.get("use_gmalloc", None) if lit.util.pythonize_bool(use_gmalloc): # Allow use of an explicit path for gmalloc library.