diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/framework | 3 | ||||
-rw-r--r-- | test/libapt/cdrom_test.cc | 7 | ||||
-rw-r--r-- | test/libapt/file-helpers.cc | 7 | ||||
-rw-r--r-- | test/libapt/file-helpers.h | 2 | ||||
-rw-r--r-- | test/libapt/sourcelist_test.cc | 5 |
5 files changed, 13 insertions, 11 deletions
diff --git a/test/integration/framework b/test/integration/framework index 5d949009f..059cba9fb 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -143,6 +143,7 @@ gdb() { aptcache) CMD="apt-cache";; aptmark) CMD="apt-mark";; apthelper) CMD="apt-helper";; + aptftparchive) CMD="apt-ftparchive";; *) CMD="$1";; esac shift @@ -1415,6 +1416,8 @@ testfailure() { if expr match "$1" '^apt.*' >/dev/null; then if grep -q -E ' runtime error: ' "$OUTPUT"; then msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@" + elif grep -q -E '==ERROR' "$OUTPUT"; then + msgfailoutput 'compiler sanitizers reported errors' "$OUTPUT" "$@" elif ! grep -q -E '^E: ' "$OUTPUT"; then msgfailoutput "run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@" else diff --git a/test/libapt/cdrom_test.cc b/test/libapt/cdrom_test.cc index 7257eaf1b..b4c51cdb0 100644 --- a/test/libapt/cdrom_test.cc +++ b/test/libapt/cdrom_test.cc @@ -91,7 +91,7 @@ TEST(CDROMTest,ReduceSourcelist) } TEST(CDROMTest, FindMountPointForDevice) { - char * tempfile = NULL; + std::string tempfile; FileFd fd; createTemporaryFile("mountpoints", fd, &tempfile, "rootfs / rootfs rw 0 0\n" @@ -109,7 +109,6 @@ TEST(CDROMTest, FindMountPointForDevice) EXPECT_EQ("/boot/efi", FindMountPointForDevice("/dev/sda1")); EXPECT_EQ("/tmp", FindMountPointForDevice("tmpfs")); - if (tempfile != NULL) - unlink(tempfile); - free(tempfile); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); } diff --git a/test/libapt/file-helpers.cc b/test/libapt/file-helpers.cc index 5edb9a9fe..387192868 100644 --- a/test/libapt/file-helpers.cc +++ b/test/libapt/file-helpers.cc @@ -53,20 +53,19 @@ void helperCreateLink(std::string const &dir, std::string const &targetname, std link.append(linkname); ASSERT_EQ(0, symlink(target.c_str(), link.c_str())); } -void helperCreateTemporaryFile(std::string const &id, FileFd &fd, char * * const filename, char const * const content) +void helperCreateTemporaryFile(std::string const &id, FileFd &fd, std::string * const filename, char const * const content) { std::string name("apt-test-"); name.append(id).append(".XXXXXXXX"); char * tempfile = strdup(name.c_str()); + ASSERT_STRNE(NULL, tempfile); int tempfile_fd = mkstemp(tempfile); ASSERT_NE(-1, tempfile_fd); if (filename != NULL) *filename = tempfile; else - { unlink(tempfile); - free(tempfile); - } + free(tempfile); EXPECT_TRUE(fd.OpenDescriptor(tempfile_fd, FileFd::ReadWrite)); if (content != NULL) diff --git a/test/libapt/file-helpers.h b/test/libapt/file-helpers.h index e8472d503..f639c1cbc 100644 --- a/test/libapt/file-helpers.h +++ b/test/libapt/file-helpers.h @@ -24,6 +24,6 @@ void helperCreateDirectory(std::string const &dir, std::string const &name); void helperCreateLink(std::string const &dir, std::string const &targetname, std::string const &linkname); #define createTemporaryFile(id, fd, filename, content) \ ASSERT_NO_FATAL_FAILURE(helperCreateTemporaryFile(id, fd, filename, content)) -void helperCreateTemporaryFile(std::string const &id, FileFd &fd, char * * const filename, char const * const content); +void helperCreateTemporaryFile(std::string const &id, FileFd &fd, std::string * const filename, char const * const content); #endif diff --git a/test/libapt/sourcelist_test.cc b/test/libapt/sourcelist_test.cc index 747ab4957..9e6f82213 100644 --- a/test/libapt/sourcelist_test.cc +++ b/test/libapt/sourcelist_test.cc @@ -20,7 +20,7 @@ class SourceList : public pkgSourceList { TEST(SourceListTest,ParseFileDeb822) { FileFd fd; - char * tempfile = NULL; + std::string tempfile; createTemporaryFile("parsefiledeb822", fd, &tempfile, "Types: deb\n" "URIs: http://ftp.debian.org/debian\n" @@ -39,5 +39,6 @@ TEST(SourceListTest,ParseFileDeb822) EXPECT_EQ(2, sources.ParseFileDeb822(tempfile)); EXPECT_EQ(2, sources.size()); - unlink(tempfile); + if (tempfile.empty() == false) + unlink(tempfile.c_str()); } |