[llvm] 3d595ec - [Debuginfod] Fix debuginfod unit test when $HOME is not writable.
Noah Shutty via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 15 14:21:03 PST 2021
Author: Noah Shutty
Date: 2021-12-15T22:13:13Z
New Revision: 3d595eccc7d5b20d9f202492bf48394ac7c078c6
URL: https://github.com/llvm/llvm-project/commit/3d595eccc7d5b20d9f202492bf48394ac7c078c6
DIFF: https://github.com/llvm/llvm-project/commit/3d595eccc7d5b20d9f202492bf48394ac7c078c6.diff
LOG: [Debuginfod] Fix debuginfod unit test when $HOME is not writable.
The directory returned from `cache_directory` may not be writable if the unit tests are run with limited permissions (e.g. if $HOME is not writable).
This fixes a unit test of the debuginfod client to set the cache path to the system temporary directory to avoid this issue.
Reviewed By: estewart08
Differential Revision: https://reviews.llvm.org/D115813
Added:
Modified:
llvm/unittests/Debuginfod/DebuginfodTests.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Debuginfod/DebuginfodTests.cpp b/llvm/unittests/Debuginfod/DebuginfodTests.cpp
index 4a69fcc8039f8..fc5eb705969e7 100644
--- a/llvm/unittests/Debuginfod/DebuginfodTests.cpp
+++ b/llvm/unittests/Debuginfod/DebuginfodTests.cpp
@@ -40,6 +40,12 @@ TEST(DebuginfodClient, CacheHit) {
// Check that the Debuginfod client returns an Error when it fails to find an
// artifact.
TEST(DebuginfodClient, CacheMiss) {
+ // Set the cache path to a temp directory to avoid permissions issues if $HOME
+ // is not writable.
+ SmallString<32> TempDir;
+ sys::path::system_temp_directory(true, TempDir);
+ setenv("DEBUGINFOD_CACHE_PATH", TempDir.c_str(),
+ /*replace=*/1);
// Ensure there are no urls to guarantee a cache miss.
setenv("DEBUGINFOD_URLS", "", /*replace=*/1);
HTTPClient::initialize();
More information about the llvm-commits
mailing list