summaryrefslogtreecommitdiff
path: root/test/libapt/cdrom_test.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-05-18 11:55:54 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-05-18 15:55:36 +0200
commitc470d92366d7c3c239a689f0a10d6d0d9daafbff (patch)
tree955534f65524c3f81f36119012b6cd995a9619d0 /test/libapt/cdrom_test.cc
parent37cc8dcda9e97e0b9420d37bb886081fa629847d (diff)
Allow prefix to be a complete filename for GetTempFile
Our testcases had their own implementation of GetTempFile with the feature of a temporary file with a choosen suffix. Merging this into GetTempFile lets us drop this duplicate and hence test more our code rather than testing our helpers for test implementation. And then hashsums_test had another implementation… and extracttar wasn't even trying to use a real tempfile… one GetTempFile to rule them all! That also ensures that these tempfiles are created in a temporary directory rather than the current directory which is a nice touch and tries a little harder to clean up those tempfiles.
Diffstat (limited to 'test/libapt/cdrom_test.cc')
-rw-r--r--test/libapt/cdrom_test.cc9
1 files changed, 2 insertions, 7 deletions
diff --git a/test/libapt/cdrom_test.cc b/test/libapt/cdrom_test.cc
index b21492cb7..e2ec05ab8 100644
--- a/test/libapt/cdrom_test.cc
+++ b/test/libapt/cdrom_test.cc
@@ -91,16 +91,14 @@ TEST(CDROMTest,ReduceSourcelist)
}
TEST(CDROMTest, FindMountPointForDevice)
{
- std::string tempfile;
- FileFd fd;
- createTemporaryFile("mountpoints", fd, &tempfile,
+ auto const file = createTemporaryFile("mountpoints",
"rootfs / rootfs rw 0 0\n"
"sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0\n"
"sysfs0 /sys0 sysfs rw,nosuid,nodev,noexec,relatime 0 0\n"
"/dev/disk/by-uuid/fadcbc52-6284-4874-aaaa-dcee1f05fe21 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0\n"
"/dev/sda1 /boot/efi vfat rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro,rw,nosuid,nodev,noexec,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=437,iocharset=utf8,shortname=lower,quiet,utf8,errors=remount-ro 0 0\n"
"tmpfs /tmp tmpfs rw,nosuid,nodev,relatime 0 0\n");
- _config->Set("Dir::state::Mountpoints", tempfile);
+ _config->Set("Dir::state::Mountpoints", file.Name());
EXPECT_EQ("/", FindMountPointForDevice("rootfs"));
EXPECT_EQ("/", FindMountPointForDevice("/dev/disk/by-uuid/fadcbc52-6284-4874-aaaa-dcee1f05fe21"));
@@ -108,7 +106,4 @@ TEST(CDROMTest, FindMountPointForDevice)
EXPECT_EQ("/sys0", FindMountPointForDevice("sysfs0"));
EXPECT_EQ("/boot/efi", FindMountPointForDevice("/dev/sda1"));
EXPECT_EQ("/tmp", FindMountPointForDevice("tmpfs"));
-
- if (tempfile.empty() == false)
- unlink(tempfile.c_str());
}