libsnapshot_fuzzer: also create snapshots dir

/metadata/ota/snapshots is created by init.rc at boot time.
Conditionally create it in the fuzz test

Test: run it
Bug: 154633114

Change-Id: Ice5e340b554ffd59861c4b21d9c4eb652ca60c55
This commit is contained in:
Yifan Hong 2020-05-04 13:59:52 -07:00
parent 7134ae064e
commit 933d341b6a
2 changed files with 7 additions and 1 deletions

View file

@ -97,7 +97,10 @@ message SnapshotFuzzData {
bool is_super_metadata_valid = 3;
chromeos_update_engine.DeltaArchiveManifest super_data = 4;
// Whether the directory that mocks /metadata/ota/snapshot is created.
bool has_metadata_snapshots_dir = 5;
// More data used to prep the test before running actions.
reserved 5 to 9999;
reserved 6 to 9999;
repeated SnapshotManagerActionProto actions = 10000;
}

View file

@ -258,6 +258,9 @@ std::unique_ptr<ISnapshotManager> SnapshotFuzzEnv::CheckCreateSnapshotManager(
CheckWriteSuperMetadata(data, *partition_opener);
auto metadata_dir = fake_root_->tmp_path() + "/snapshot_metadata";
PCHECK(Mkdir(metadata_dir));
if (data.has_metadata_snapshots_dir()) {
PCHECK(Mkdir(metadata_dir + "/snapshots"));
}
auto device_info = new SnapshotFuzzDeviceInfo(data.device_info_data(),
std::move(partition_opener), metadata_dir);