Make update_engine_unittests depend on bsdiff.
Added build artifacts path to PATH for unittests.
Test: mma; ./update_engine_unittests
Bug: 26955860
Change-Id: I09401cb883be5210887d7c789fdaec4145626fa0
diff --git a/Android.mk b/Android.mk
index 6b63931..77bb420 100644
--- a/Android.mk
+++ b/Android.mk
@@ -790,6 +790,21 @@
test_http_server.cc
include $(BUILD_EXECUTABLE)
+# bsdiff (type: executable)
+# ========================================================
+# We need bsdiff in the update_engine_unittests directory, so we build it here.
+include $(CLEAR_VARS)
+LOCAL_MODULE := ue_unittest_bsdiff
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS)/update_engine_unittests
+LOCAL_MODULE_STEM := bsdiff
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_SRC_FILES := ../../external/bsdiff/bsdiff_main.cc
+LOCAL_CFLAGS := $(bsdiff_common_cflags)
+LOCAL_STATIC_LIBRARIES := \
+ libbsdiff \
+ $(bsdiff_static_libs)
+include $(BUILD_EXECUTABLE)
+
# update_engine_unittests (type: executable)
# ========================================================
# Main unittest file.
@@ -799,6 +814,7 @@
LOCAL_MODULE_TAGS := eng
endif
LOCAL_REQUIRED_MODULES := \
+ ue_unittest_bsdiff \
ue_unittest_delta_generator \
ue_unittest_disk_ext2_1k.img \
ue_unittest_disk_ext2_4k.img \
diff --git a/payload_generator/delta_diff_utils.cc b/payload_generator/delta_diff_utils.cc
index 7199f7e..f7b69f5 100644
--- a/payload_generator/delta_diff_utils.cc
+++ b/payload_generator/delta_diff_utils.cc
@@ -664,7 +664,6 @@
cmd.push_back(patch_file_path);
int rc = 1;
- brillo::Blob patch_file;
string stdout;
TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &rc, &stdout));
if (rc != 0) {
diff --git a/testrunner.cc b/testrunner.cc
index 635e120..934ea91 100644
--- a/testrunner.cc
+++ b/testrunner.cc
@@ -16,14 +16,18 @@
// based on pam_google_testrunner.cc
+#include <string>
+
#include <xz.h>
#include <base/at_exit.h>
#include <base/command_line.h>
+#include <base/environment.h>
#include <brillo/test_helpers.h>
#include <gtest/gtest.h>
#include "update_engine/common/terminator.h"
+#include "update_engine/common/test_utils.h"
#include "update_engine/payload_generator/xz.h"
int main(int argc, char **argv) {
@@ -40,6 +44,15 @@
// the default exit status of 1. Corresponding reverts are necessary in
// terminator_unittest.cc.
chromeos_update_engine::Terminator::Init(2);
+ // In Android bsdiff is located in update_engine_unittests, add it to PATH.
+#ifdef __ANDROID__
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ std::string path_env;
+ CHECK(env->GetVar("PATH", &path_env));
+ path_env +=
+ ":" + chromeos_update_engine::test_utils::GetBuildArtifactsPath().value();
+ CHECK(env->SetVar("PATH", path_env));
+#endif
LOG(INFO) << "parsing command line arguments";
base::CommandLine::Init(argc, argv);
LOG(INFO) << "initializing gtest";