summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2019-11-29 15:21:47 +0300
committerIgor Pashev <pashev.igor@gmail.com>2019-11-29 15:21:47 +0300
commit43acc0c05839e000a95709a7317d689c1bf9e0a6 (patch)
tree36a32fbee00449431874eeeecb06fc65efd731b5 /test
parentd988e2f485539e9db48a9866414b9399438d76ab (diff)
downloadapt-43acc0c05839e000a95709a7317d689c1bf9e0a6.tar.gz
Do not rely on external file in tests
Diffstat (limited to 'test')
-rw-r--r--test/libapt/hashsums_test.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc
index eede213cd..25f4e456f 100644
--- a/test/libapt/hashsums_test.cc
+++ b/test/libapt/hashsums_test.cc
@@ -119,7 +119,7 @@ static void getSummationString(char const * const type, std::string &sum)
FileFd fd;
ASSERT_TRUE(fd.Open(tempfile, FileFd::WriteOnly | FileFd::Empty, compress));
ASSERT_TRUE(fd.IsOpen());
- FileFd input("/etc/os-release", FileFd::ReadOnly);
+ FileFd input(__FILE__, FileFd::ReadOnly);
ASSERT_TRUE(input.IsOpen());
ASSERT_NE(0u, input.FileSize());
ASSERT_TRUE(CopyFile(input, fd));
@@ -161,7 +161,7 @@ TEST(HashSumsTest, FileBased)
SHA512SumValue sha512(summation);
EXPECT_EQ(sha512.Value(), summation);
- FileFd fd("/etc/os-release", FileFd::ReadOnly);
+ FileFd fd(__FILE__, FileFd::ReadOnly);
EXPECT_TRUE(fd.IsOpen());
std::string FileSize;
strprintf(FileSize, "%llu", fd.FileSize());
@@ -243,18 +243,18 @@ TEST(HashSumsTest, FileBased)
fd.Close();
HashString sha2file("SHA512", sha512.Value());
- EXPECT_TRUE(sha2file.VerifyFile("/etc/os-release"));
+ EXPECT_TRUE(sha2file.VerifyFile(__FILE__));
HashString sha2wrong("SHA512", "00000000000");
- EXPECT_FALSE(sha2wrong.VerifyFile("/etc/os-release"));
+ EXPECT_FALSE(sha2wrong.VerifyFile(__FILE__));
EXPECT_EQ(sha2file, sha2file);
EXPECT_TRUE(sha2file == sha2file);
EXPECT_NE(sha2file, sha2wrong);
EXPECT_TRUE(sha2file != sha2wrong);
HashString sha2big("SHA256", sha256.Value());
- EXPECT_TRUE(sha2big.VerifyFile("/etc/os-release"));
+ EXPECT_TRUE(sha2big.VerifyFile(__FILE__));
HashString sha2small("sha256:" + sha256.Value());
- EXPECT_TRUE(sha2small.VerifyFile("/etc/os-release"));
+ EXPECT_TRUE(sha2small.VerifyFile(__FILE__));
EXPECT_EQ(sha2big, sha2small);
EXPECT_TRUE(sha2big == sha2small);
EXPECT_FALSE(sha2big != sha2small);
@@ -283,7 +283,7 @@ TEST(HashSumsTest, FileBased)
EXPECT_EQ(2u, hashes.size());
EXPECT_FALSE(hashes.push_back(sha2wrong));
EXPECT_EQ(2u, hashes.size());
- EXPECT_TRUE(hashes.VerifyFile("/etc/os-release"));
+ EXPECT_TRUE(hashes.VerifyFile(__FILE__));
EXPECT_EQ(similar, hashes);
EXPECT_TRUE(similar == hashes);