lenary created this revision. Herald added subscribers: pmatos, asb, ormris, steven_wu, delcypher, hiraditya, sbc100, emaste. Herald added a reviewer: alexander-shaposhnikov. Herald added a reviewer: jhenderson. Herald added projects: lld-macho, All. Herald added a reviewer: lld-macho. lenary requested review of this revision. Herald added subscribers: llvm-commits, cfe-commits, MaskRay, aheejin. Herald added projects: clang, LLVM.
I was seeing flaky tests in my builds due to another process (in my case, antivirus) modifying the access time of files during the tests, so those tests using `touch -a` were failing. This change modifies how we check if a system has consistent atime. Instead of a list of platforms where we know things might not work, we instead perform a check similar to the ones used in the tests, but on a temporary file. If the check is successful, then you get a `consistent-atime` feature which you can make your test REQUIRE. This updates all existing tests which mention atime or use `touch -a` to `REQUIRE: consistent-atime`, fixing their flakiness. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144638 Files: clang/test/Modules/prune.m lld/test/COFF/lto-cache.ll lld/test/ELF/lto/cache.ll lld/test/MachO/lto-cache.ll lld/test/wasm/lto/cache.ll llvm/test/ThinLTO/X86/cache.ll llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test llvm/utils/lit/lit/llvm/config.py
Index: llvm/utils/lit/lit/llvm/config.py =================================================================== --- llvm/utils/lit/lit/llvm/config.py +++ llvm/utils/lit/lit/llvm/config.py @@ -5,6 +5,7 @@ import subprocess import sys import errno +import tempfile import lit.util from lit.llvm.subst import FindTool @@ -155,6 +156,30 @@ self.with_environment( 'DYLD_INSERT_LIBRARIES', gmalloc_path_str) + if self._has_consistent_atime(): + features.add('consistent-atime') + + # - NetBSD: noatime mounts currently inhibit 'touch -a' updates. + # - Windows: the last access time is disabled by default in the OS. + # + # This check hopefully detects both cases, and disables tests that require + # consistent atime. + def _has_consistent_atime(self): + with tempfile.NamedTemporaryFile() as f: + # Specific date in the past on purpose, based on what is attempted + # in the tests that do the same thing. + (_, try_touch_err) = self.get_process_output(["touch", "-a", "-t", "199505050555.55", f.name]) + if try_touch_err != "": + return False + + (touch_res_out, touch_res_err) = self.get_process_output(["ls", "-lu", f.name]) + if touch_res_err != "": + return False + if "1995" not in touch_res_out: + return False + + return True + def _find_git_windows_unix_tools(self, tools_needed): assert(sys.platform == 'win32') if sys.version_info.major >= 3: Index: llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test =================================================================== --- llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test +++ llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test @@ -1,7 +1,5 @@ # Note: ls -lu prints the accessed timestamp -# NetBSD: noatime mounts currently inhibit 'touch -a' updates -# Windows: the last access time is disabled by default in the OS -# UNSUPPORTED: system-netbsd, system-windows +# REQUIRES: consistent-atime # Preserve dates when stripping to an output file. # RUN: yaml2obj %s -o %t.1.o Index: llvm/test/ThinLTO/X86/cache.ll =================================================================== --- llvm/test/ThinLTO/X86/cache.ll +++ llvm/test/ThinLTO/X86/cache.ll @@ -1,5 +1,4 @@ -; NetBSD: noatime mounts currently inhibit 'touch -a' updates -; UNSUPPORTED: system-netbsd +; REQUIRES: consistent-atime ; The .noindex suffix for output dir is to prevent Spotlight on macOS from ; indexing it. Index: lld/test/wasm/lto/cache.ll =================================================================== --- lld/test/wasm/lto/cache.ll +++ lld/test/wasm/lto/cache.ll @@ -1,8 +1,6 @@ ; RUN: opt -module-hash -module-summary %s -o %t.o ; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o -; NetBSD: noatime mounts currently inhibit 'touch' from updating atime -; Windows: no 'touch' command. -; UNSUPPORTED: system-netbsd, system-windows +; REQUIRES: consistent-atime ; RUN: rm -Rf %t.cache && mkdir %t.cache ; Create two files that would be removed by cache pruning due to age. Index: lld/test/MachO/lto-cache.ll =================================================================== --- lld/test/MachO/lto-cache.ll +++ lld/test/MachO/lto-cache.ll @@ -1,6 +1,5 @@ ; REQUIRES: x86 -; NetBSD: noatime mounts currently inhibit 'touch' from updating atime -; UNSUPPORTED: system-netbsd +; REQUIRES: consistent-atime ; RUN: rm -rf %t; split-file %s %t ; RUN: opt -module-hash -module-summary %t/foo.ll -o %t/foo.o Index: lld/test/ELF/lto/cache.ll =================================================================== --- lld/test/ELF/lto/cache.ll +++ lld/test/ELF/lto/cache.ll @@ -1,6 +1,5 @@ ; REQUIRES: x86 -; NetBSD: noatime mounts currently inhibit 'touch' from updating atime -; UNSUPPORTED: system-netbsd +; REQUIRES: consistent-atime ; RUN: opt -module-hash -module-summary %s -o %t.o ; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o Index: lld/test/COFF/lto-cache.ll =================================================================== --- lld/test/COFF/lto-cache.ll +++ lld/test/COFF/lto-cache.ll @@ -1,6 +1,5 @@ ; REQUIRES: x86 -; NetBSD: noatime mounts currently inhibit 'touch' from updating atime -; UNSUPPORTED: system-netbsd +; REQUIRES: consistent-atime ; RUN: opt -module-hash -module-summary %s -o %t.o ; RUN: opt -module-hash -module-summary %p/Inputs/lto-cache.ll -o %t2.o Index: clang/test/Modules/prune.m =================================================================== --- clang/test/Modules/prune.m +++ clang/test/Modules/prune.m @@ -1,5 +1,4 @@ -// NetBSD: noatime mounts currently inhibit 'touch -a' updates -// UNSUPPORTED: system-netbsd +// REQUIRES: consistent-atime // Test the automatic pruning of module cache entries. #ifdef IMPORT_DEPENDS_ON_MODULE
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits