Simulator: add the argument to keep the updated images

Add the command line option to select the work directory and save the
updated image files. Because some people might have interested in
getting updated images from an ota file.

Also, fix a minor issue that the destination of package_extract_file
needs to be updated if it's a block device. Otherwise, an unintended
file may be extracted in the callers' directory.

Test: run simulation, run unit tests

Change-Id: Ic6a7db0580bc1748d6e080102e4654da4e41fd8c
This commit is contained in:
Tianjie Xu
2019-07-30 17:11:35 -07:00
parent 5d9f963e4e
commit 60b242cfd5
5 changed files with 40 additions and 7 deletions
+2 -2
View File
@@ -93,7 +93,7 @@ static void RunSimulation(std::string_view src_tf, std::string_view ota_package,
// Run the update simulation and check the result.
TemporaryDir work_dir;
BuildInfo build_info(work_dir.path);
BuildInfo build_info(work_dir.path, false);
ASSERT_TRUE(build_info.ParseTargetFile(src_tf, false));
Updater updater(std::make_unique<SimulatorRuntime>(&build_info));
ASSERT_TRUE(updater.Init(cmd_pipe.release(), ota_package, false));
@@ -211,7 +211,7 @@ TEST_F(UpdateSimulatorTest, BuildInfo_ParseTargetFile) {
AddZipEntries(zip_file.release(), entries);
TemporaryDir temp_dir;
BuildInfo build_info(temp_dir.path);
BuildInfo build_info(temp_dir.path, false);
ASSERT_TRUE(build_info.ParseTargetFile(zip_file.path, false));
std::map<string, string> expected_result = {