summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/integration/test-apt-acquire-additional-files4
-rw-r--r--test/libapt/fileutl_test.cc30
2 files changed, 34 insertions, 0 deletions
diff --git a/test/integration/test-apt-acquire-additional-files b/test/integration/test-apt-acquire-additional-files
index 552499ea2..0a9653ce6 100755
--- a/test/integration/test-apt-acquire-additional-files
+++ b/test/integration/test-apt-acquire-additional-files
@@ -31,6 +31,7 @@ Reading package lists..." aptget update
testempty find rootdir/var/lib/apt/lists -name '*Contents*'
+msgmsg "Normal Contents file"
cat > rootdir/etc/apt/apt.conf.d/content-target.conf <<EOF
Acquire::IndexTargets::deb::Contents {
MetaKey "\$(COMPONENT)/Contents-\$(ARCHITECTURE)";
@@ -78,6 +79,7 @@ rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Cont
testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
# if we asked for keeping it compressed, keep it
+msgmsg "Normal Contents file with KeepCompressed"
echo 'Acquire::IndexTargets::deb::Contents::KeepCompressed "true";' >> rootdir/etc/apt/apt.conf.d/content-target.conf
testsuccessequal "Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
Get:2 http://localhost:${APTHTTPPORT} unstable/main amd64 Contents [$(stat -c%s aptarchive/dists/unstable/main/Contents-amd64.gz) B]
@@ -94,6 +96,7 @@ rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Cont
rm ./rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.gz
testempty aptget indextargets --format '$(FILENAME)' 'Created-By: Contents'
+msgmsg "Compressed Contents file"
# and no automatic uncompress based on the name please,
# only if we downloaded a compressed file, but target was uncompressed
cat > rootdir/etc/apt/apt.conf.d/content-target.conf <<EOF
@@ -125,6 +128,7 @@ testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstab
testsuccess cmp "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_dists_unstable_main_Contents-all.gz" 'aptarchive/dists/unstable/main/Contents-all.gz'
rm -f rootdir/etc/apt/apt.conf.d/content-target.conf
+msgmsg "No Contents file"
testequal "'http://localhost:${APTHTTPPORT}/dists/unstable/InRelease' localhost:${APTHTTPPORT}_dists_unstable_InRelease 0
'http://localhost:${APTHTTPPORT}/dists/unstable/main/source/Sources.xz' localhost:${APTHTTPPORT}_dists_unstable_main_source_Sources 0
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc
index b42261716..2bd090e5e 100644
--- a/test/libapt/fileutl_test.cc
+++ b/test/libapt/fileutl_test.cc
@@ -298,3 +298,33 @@ TEST(FileUtlTest, flAbsPath)
res = chdir(cwd.c_str());
EXPECT_EQ(res, 0);
}
+
+static void TestDevNullFileFd(unsigned int const filemode)
+{
+ FileFd f("/dev/null", filemode);
+ EXPECT_FALSE(f.Failed());
+ EXPECT_TRUE(f.IsOpen());
+ EXPECT_TRUE(f.IsOpen());
+
+ std::string test = "This is a test!\n";
+ EXPECT_TRUE(f.Write(test.c_str(), test.size()));
+ EXPECT_TRUE(f.IsOpen());
+ EXPECT_FALSE(f.Failed());
+
+ f.Close();
+ EXPECT_FALSE(f.IsOpen());
+ EXPECT_FALSE(f.Failed());
+}
+TEST(FileUtlTest, WorkingWithDevNull)
+{
+ TestDevNullFileFd(FileFd::WriteOnly | FileFd::Create);
+ TestDevNullFileFd(FileFd::WriteOnly | FileFd::Create | FileFd::Empty);
+ TestDevNullFileFd(FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive);
+ TestDevNullFileFd(FileFd::WriteOnly | FileFd::Atomic);
+ TestDevNullFileFd(FileFd::WriteOnly | FileFd::Create | FileFd::Atomic);
+ // short-hands for ReadWrite with these modes
+ TestDevNullFileFd(FileFd::WriteEmpty);
+ TestDevNullFileFd(FileFd::WriteAny);
+ TestDevNullFileFd(FileFd::WriteTemp);
+ TestDevNullFileFd(FileFd::WriteAtomic);
+}