]> git.saurik.com Git - apt.git/blobdiff - test/libapt/fileutl_test.cc
promote filesize to a hashstring
[apt.git] / test / libapt / fileutl_test.cc
index c2a43eda7d1db6a395242c1e587e6c96d0578a8b..8d47c5098bdda0f91a19aa018d03225c493d60bc 100644 (file)
@@ -217,14 +217,21 @@ 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("/usr", GetTempDir());
+   EXPECT_EQ("/tmp", GetTempDir());
+
+   // files are no good for tmpdirs, too
+   setenv("TMPDIR", "/dev/null", 1);
+   EXPECT_EQ("/tmp", GetTempDir());
+
+   setenv("TMPDIR", "/var/tmp", 1);
+   EXPECT_EQ("/var/tmp", GetTempDir());
 
    unsetenv("TMPDIR");
    if (old_tmpdir.empty() == false)
       setenv("TMPDIR", old_tmpdir.c_str(), 1);
 }
-
 TEST(FileUtlTest, Popen)
 {
    FileFd Fd;
@@ -272,3 +279,14 @@ TEST(FileUtlTest, Popen)
    Fd.Close();
    ExecWait(Child, "PopenWrite");
 }
+TEST(FileUtlTest, flAbsPath)
+{
+   std::string cwd = SafeGetCWD();
+   int res = chdir("/bin/");
+   EXPECT_EQ(res, 0);
+   std::string p = flAbsPath("ls");
+   EXPECT_EQ(p, "/bin/ls");
+
+   res = chdir(cwd.c_str());
+   EXPECT_EQ(res, 0);
+}