[llvm] [lit] Ignore src permissions when copying lit_test_times (PR #121377)

Angus Lees via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 30 22:11:45 PST 2024


https://github.com/anguslees created https://github.com/llvm/llvm-project/pull/121377

`cp` will attempt to re-produce the source permissions on the
destination file.

When the input files are read-only (0444) - eg when building in a bazel
sandbox - this means the .lit_test_times.txt tmpfile is also 0444.
When `TestTimes.py` is run a second time, it fails (permission denied)
to write to this read-only file.

Rather than attempt to navigate portable `cp` command line options to
disable this, just copy using a naive `cat src > dst` instead.

For posterity, the failure appeared as:
```
Command Output (stdout):
--
cp Inputs/reorder/lit_test_times Inputs/reorder/.lit_test_times.txt
not env -u FILECHECK_OPTS "/var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/python_3_12_x86_64-unknown-linux-gnu/bin/python3" /var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/__main__/external/llvm-project/llvm/utils/lit/lit.py -j1 Inputs/reorder > /var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/__main__/external/llvm-project/llvm/utils/lit/tests/Output/reorder.py.tmp.out
FileCheck --check-prefix=TIMES < Inputs/reorder/.lit_test_times.txt /var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/__main__/external/llvm-project/llvm/utils/lit/tests/reorder.py
--
```

>From 3045c1bd6f5bec814ec28a6915eba0bb01e7645b Mon Sep 17 00:00:00 2001
From: Angus Lees <gus at inodes.org>
Date: Tue, 31 Dec 2024 17:11:17 +1100
Subject: [PATCH] [lit] Ignore src permissions when copying lit_test_times

`cp` will attempt to re-produce the source permissions on the
destination file.

When the input files are read-only (0444) - eg when building in a bazel
sandbox - this means the .lit_test_times.txt tmpfile is also 0444.
When `TestTimes.py` is run a second time, it fails (permission denied)
to write to this read-only file.

Rather than attempt to navigate portable `cp` command line options to
disable this, just copy using a naive `cat src > dst` instead.

For posterity, the failure appeared as:
```
Command Output (stdout):
--
cp Inputs/reorder/lit_test_times Inputs/reorder/.lit_test_times.txt
not env -u FILECHECK_OPTS "/var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/python_3_12_x86_64-unknown-linux-gnu/bin/python3" /var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/__main__/external/llvm-project/llvm/utils/lit/lit.py -j1 Inputs/reorder > /var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/__main__/external/llvm-project/llvm/utils/lit/tests/Output/reorder.py.tmp.out
FileCheck --check-prefix=TIMES < Inputs/reorder/.lit_test_times.txt /var/lib/engflow/worker/work/27/exec/bazel-out/k8-fastbuild/bin/external/llvm-project/llvm/utils/lit/tests/reorder.py.test.runfiles/__main__/external/llvm-project/llvm/utils/lit/tests/reorder.py
--
```
---
 llvm/utils/lit/tests/reorder.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/lit/tests/reorder.py b/llvm/utils/lit/tests/reorder.py
index 8ebeac393d5575..633ed808a2454c 100644
--- a/llvm/utils/lit/tests/reorder.py
+++ b/llvm/utils/lit/tests/reorder.py
@@ -1,6 +1,6 @@
 ## Check that we can reorder test runs.
 
-# RUN: cp %{inputs}/reorder/lit_test_times %{inputs}/reorder/.lit_test_times.txt
+# RUN: cat %{inputs}/reorder/lit_test_times > %{inputs}/reorder/.lit_test_times.txt
 # RUN: not %{lit-no-order-opt} %{inputs}/reorder > %t.out
 # RUN: FileCheck --check-prefix=TIMES < %{inputs}/reorder/.lit_test_times.txt %s
 # RUN: FileCheck < %t.out %s



More information about the llvm-commits mailing list