diff options
author | Tianjie Xu <xunchang@google.com> | 2017-03-17 02:06:49 +0100 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-17 02:06:49 +0100 |
commit | 92d167513d56a0e34d47e26d8be0f73e9c2730ad (patch) | |
tree | 084696e97211816e9741b70ff581c735503d179e /tests/component/imgdiff_test.cpp | |
parent | Merge "updater: Minor clean up to EnumerateStash()." am: 4fc7659612 am: 8209daeff1 (diff) | |
parent | Merge "More cleanup to imgdiff & imgpatch" am: 3541934ff5 (diff) | |
download | android_bootable_recovery-92d167513d56a0e34d47e26d8be0f73e9c2730ad.tar android_bootable_recovery-92d167513d56a0e34d47e26d8be0f73e9c2730ad.tar.gz android_bootable_recovery-92d167513d56a0e34d47e26d8be0f73e9c2730ad.tar.bz2 android_bootable_recovery-92d167513d56a0e34d47e26d8be0f73e9c2730ad.tar.lz android_bootable_recovery-92d167513d56a0e34d47e26d8be0f73e9c2730ad.tar.xz android_bootable_recovery-92d167513d56a0e34d47e26d8be0f73e9c2730ad.tar.zst android_bootable_recovery-92d167513d56a0e34d47e26d8be0f73e9c2730ad.zip |
Diffstat (limited to 'tests/component/imgdiff_test.cpp')
-rw-r--r-- | tests/component/imgdiff_test.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/component/imgdiff_test.cpp b/tests/component/imgdiff_test.cpp index be2dd385b..2f648501c 100644 --- a/tests/component/imgdiff_test.cpp +++ b/tests/component/imgdiff_test.cpp @@ -18,13 +18,14 @@ #include <vector> #include <android-base/file.h> +#include <android-base/memory.h> #include <android-base/test_utils.h> #include <applypatch/imgdiff.h> #include <applypatch/imgpatch.h> #include <gtest/gtest.h> #include <ziparchive/zip_writer.h> -#include "applypatch/utils.h" +using android::base::get_unaligned; static ssize_t MemorySink(const unsigned char* data, ssize_t len, void* token) { std::string* s = static_cast<std::string*>(token); @@ -41,7 +42,7 @@ static void verify_patch_header(const std::string& patch, size_t* num_normal, si ASSERT_GE(size, 12U); ASSERT_EQ("IMGDIFF2", std::string(data, 8)); - const int num_chunks = Read4(data + 8); + const int num_chunks = get_unaligned<int32_t>(data + 8); ASSERT_GE(num_chunks, 0); size_t normal = 0; @@ -51,7 +52,7 @@ static void verify_patch_header(const std::string& patch, size_t* num_normal, si size_t pos = 12; for (int i = 0; i < num_chunks; ++i) { ASSERT_LE(pos + 4, size); - int type = Read4(data + pos); + int type = get_unaligned<int32_t>(data + pos); pos += 4; if (type == CHUNK_NORMAL) { pos += 24; @@ -59,7 +60,7 @@ static void verify_patch_header(const std::string& patch, size_t* num_normal, si normal++; } else if (type == CHUNK_RAW) { ASSERT_LE(pos + 4, size); - ssize_t data_len = Read4(data + pos); + ssize_t data_len = get_unaligned<int32_t>(data + pos); ASSERT_GT(data_len, 0); pos += 4 + data_len; ASSERT_LE(pos, size); |