Skip to content

Conversation

@rupprecht
Copy link
Collaborator

@rupprecht rupprecht commented Oct 22, 2024

TestUseSourceCache attempts to write to a build artifact copied from the source tree, and asserts the write succeeded. If the source tree is read only, the copy will also be read only, causing it to fail. When producing the build artifact, ensure that it is writable.

TestUseSourceCache attempts to write to a build artifact copied from the source tree, and asserts the write succeeded. If the source tree is read only, the copy will also be read only, causing it to fail. When producing the build artifact, ensure that it is writable.

I use `chmod` as a build step to do this, but I believe that is linuxish-only thing, so I excluded this extra command for Windows.
@llvmbot
Copy link
Member

llvmbot commented Oct 22, 2024

@llvm/pr-subscribers-lldb

Author: Jordan Rupprecht (rupprecht)

Changes

TestUseSourceCache attempts to write to a build artifact copied from the source tree, and asserts the write succeeded. If the source tree is read only, the copy will also be read only, causing it to fail. When producing the build artifact, ensure that it is writable.

I use chmod as a build step to do this, but I believe that is linuxish-only thing, so I excluded this extra command for Windows.


Full diff: https://github.com/llvm/llvm-project/pull/113251.diff

1 Files Affected:

  • (modified) lldb/test/API/commands/settings/use_source_cache/Makefile (+3)
diff --git a/lldb/test/API/commands/settings/use_source_cache/Makefile b/lldb/test/API/commands/settings/use_source_cache/Makefile
index 791cb7d868d87e..0090acf5591daa 100644
--- a/lldb/test/API/commands/settings/use_source_cache/Makefile
+++ b/lldb/test/API/commands/settings/use_source_cache/Makefile
@@ -6,3 +6,6 @@ include Makefile.rules
 # Copy file into the build folder to enable the test to modify it.
 main-copy.cpp: main.cpp
 	cp -f $< $@
+ifneq "$(OS)" "Windows_NT"  # chmod is not available on Windows
+	chmod u+w $@
+endif

@rupprecht
Copy link
Collaborator Author

A more platform-agnostic way to do this would be to do it from Python:

        src = self.getBuildArtifact("main-copy.cpp")
        statinfo = os.stat(src)
        os.chmod(src, statinfo.st_mode | stat.S_IWUSR)

However, I don't understand the test case well enough to say if this would make it less representative. Would that fix be preferred?

Copy link
Collaborator

@igorkudrin igorkudrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@rupprecht rupprecht merged commit 5942be0 into llvm:main Oct 22, 2024
4 checks passed
@rupprecht rupprecht deleted the lldb-test-perms branch August 14, 2025 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants