summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
authorPino Toscano <pino@debian.org>2015-12-19 12:09:18 +0100
committerJulian Andres Klode <jak@debian.org>2015-12-19 12:51:10 +0100
commitdbbe1e6393dab381db0f48b2a645babdddb14eca (patch)
treea7fa6a42dc93be4c1479200183c3fc3212d6fc84 /test/libapt
parent493e032a9dcccb19dca87c542a067d759213f566 (diff)
Fix FileUtlTest.GetTempDir failure when run as root
Testing /usr as TMPDIR assumes that GetTempDir() cannot use it because it cannot write to it; this is true for non-root users, but not so much for root. Since root can access everything, perform this particular test case only when not running as root. Closes: #808383
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/fileutl_test.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc
index 2bd090e5e..7d1368f7a 100644
--- a/test/libapt/fileutl_test.cc
+++ b/test/libapt/fileutl_test.cc
@@ -222,9 +222,13 @@ TEST(FileUtlTest, GetTempDir)
setenv("TMPDIR", "/not-there-no-really-not", 1);
EXPECT_EQ("/tmp", GetTempDir());
- // here but not accessible for non-roots
- setenv("TMPDIR", "/usr", 1);
- EXPECT_EQ("/tmp", GetTempDir());
+ // root can access everything, so /usr will be accepted
+ if (geteuid() != 0)
+ {
+ // here but not accessible for non-roots
+ setenv("TMPDIR", "/usr", 1);
+ EXPECT_EQ("/tmp", GetTempDir());
+ }
// files are no good for tmpdirs, too
setenv("TMPDIR", "/dev/null", 1);