summaryrefslogtreecommitdiffstats
path: root/tests/unit/zip_test.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-12-22 18:38:34 +0100
committerandroid-build-merger <android-build-merger@google.com>2016-12-22 18:38:34 +0100
commitfe3993f31589fb2d9dfe71d4c32cf3ada547a20b (patch)
treec7cd602a1093dc08f03b917ca42d9383207218e9 /tests/unit/zip_test.cpp
parentMerge "tests: Add testcase for ZipUtil." am: aa305e9ce8 am: 6df1c4579e am: 830ab1c482 (diff)
parentMerge "tests: Replace the O_RDONLY in access(2)." am: 3b9645288e am: baf422229d (diff)
downloadandroid_bootable_recovery-fe3993f31589fb2d9dfe71d4c32cf3ada547a20b.tar
android_bootable_recovery-fe3993f31589fb2d9dfe71d4c32cf3ada547a20b.tar.gz
android_bootable_recovery-fe3993f31589fb2d9dfe71d4c32cf3ada547a20b.tar.bz2
android_bootable_recovery-fe3993f31589fb2d9dfe71d4c32cf3ada547a20b.tar.lz
android_bootable_recovery-fe3993f31589fb2d9dfe71d4c32cf3ada547a20b.tar.xz
android_bootable_recovery-fe3993f31589fb2d9dfe71d4c32cf3ada547a20b.tar.zst
android_bootable_recovery-fe3993f31589fb2d9dfe71d4c32cf3ada547a20b.zip
Diffstat (limited to 'tests/unit/zip_test.cpp')
-rw-r--r--tests/unit/zip_test.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/unit/zip_test.cpp b/tests/unit/zip_test.cpp
index ef0ee4c1d..4a1a49b97 100644
--- a/tests/unit/zip_test.cpp
+++ b/tests/unit/zip_test.cpp
@@ -15,7 +15,6 @@
*/
#include <errno.h>
-#include <fcntl.h>
#include <unistd.h>
#include <memory>
@@ -42,10 +41,10 @@ TEST(ZipTest, ExtractPackageRecursive) {
// Make sure all the files are extracted correctly.
std::string path(td.path);
- ASSERT_EQ(0, access((path + "/a.txt").c_str(), O_RDONLY));
- ASSERT_EQ(0, access((path + "/b.txt").c_str(), O_RDONLY));
- ASSERT_EQ(0, access((path + "/b/c.txt").c_str(), O_RDONLY));
- ASSERT_EQ(0, access((path + "/b/d.txt").c_str(), O_RDONLY));
+ ASSERT_EQ(0, access((path + "/a.txt").c_str(), F_OK));
+ ASSERT_EQ(0, access((path + "/b.txt").c_str(), F_OK));
+ ASSERT_EQ(0, access((path + "/b/c.txt").c_str(), F_OK));
+ ASSERT_EQ(0, access((path + "/b/d.txt").c_str(), F_OK));
// The content of the file is the same as expected.
std::string content1;
@@ -54,7 +53,16 @@ TEST(ZipTest, ExtractPackageRecursive) {
std::string content2;
ASSERT_TRUE(android::base::ReadFileToString(path + "/b/d.txt", &content2));
- ASSERT_EQ(kBTxtContents, content2);
+ ASSERT_EQ(kDTxtContents, content2);
+
+ CloseArchive(handle);
+
+ // Clean up.
+ ASSERT_EQ(0, unlink((path + "/a.txt").c_str()));
+ ASSERT_EQ(0, unlink((path + "/b.txt").c_str()));
+ ASSERT_EQ(0, unlink((path + "/b/c.txt").c_str()));
+ ASSERT_EQ(0, unlink((path + "/b/d.txt").c_str()));
+ ASSERT_EQ(0, rmdir((path + "/b").c_str()));
}
TEST(ZipTest, OpenFromMemory) {
@@ -76,6 +84,7 @@ TEST(ZipTest, OpenFromMemory) {
ASSERT_NE(-1, tmp_binary.fd);
ASSERT_EQ(0, ExtractEntryToFile(handle, &binary_entry, tmp_binary.fd));
+ CloseArchive(handle);
sysReleaseMap(&map);
}