From 6dfc6fb4c49bfa6818632a28a5a3a18f139bfb8f Mon Sep 17 00:00:00 2001 From: Fabien Sanglard Date: Thu, 22 Oct 2020 17:58:12 -0700 Subject: [PATCH] Fix zipalign tests with GetExecutableDirectory Test: Self-tested Bug: NA Change-Id: Idc15c0e028b74a2b38c26af0e7d4a51f32210145 --- tools/zipalign/Android.bp | 1 + tools/zipalign/tests/src/align_test.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/zipalign/Android.bp b/tools/zipalign/Android.bp index 3eb660d8ec..6805ef7b98 100644 --- a/tools/zipalign/Android.bp +++ b/tools/zipalign/Android.bp @@ -58,6 +58,7 @@ cc_test_host { "tests/src/*_test.cpp", ], static_libs: [ + "libbase", "libzipalign", "libgmock", ], diff --git a/tools/zipalign/tests/src/align_test.cpp b/tools/zipalign/tests/src/align_test.cpp index b8f2e15768..073a15678f 100644 --- a/tools/zipalign/tests/src/align_test.cpp +++ b/tools/zipalign/tests/src/align_test.cpp @@ -4,12 +4,21 @@ #include "ZipAlign.h" #include +#include + +#include using namespace android; +static std::string GetTestPath(const std::string& filename) { + static std::string test_data_dir = android::base::GetExecutableDirectory() + "/tests/data/"; + return test_data_dir + filename; +} + TEST(Align, Unaligned) { - const char* src = "tests/data/unaligned.zip"; - const char* dst = "tests/data/unaligned_out.zip"; - int result = process(src, dst, 4, true, false, 4096); + const std::string src = GetTestPath("unaligned.zip"); + const std::string dst = GetTestPath("unaligned_out.zip"); + + int result = process(src.c_str(), dst.c_str(), 4, true, false, 4096); ASSERT_EQ(0, result); }