libsnapshot used to assume CoW images are always mapped
with device mapper, and call GetDeviceString directly.
However, in tests, it is possible that it is mapped as loop
devices. Fix the incorrect assumption and calls
IImageManager::GetMappedImageDevice instead.
Test: libsnapshot_fuzzer with corpus
Bug: 154633114
Change-Id: I1ec39744480e514ae7a7902643ed863e0ca0a340
When merging in recovery, the "imminent data wipe" code was used, which
made the assumption the /metadata and /data state would be zapped. This
caused future OTAs to error because the old snapshots were detected.
This CL allows OTAs to proceed even if unexpected snapshots are present.
It also forces the state to "MergeCompleted" after a merge in recovery,
so that the next normal boot can perform cleanup.
Bug: 155339165
Test: fastboot snapshot-update merge, then take another OTA
vts_libsnapshot_test
Change-Id: Ief6dea3ba76323044e61307272dda320a4494aea
* changes:
Enable automatic libsnapshot fuzzer runs
Also log corpus when aborted through libbase.
libsnapshot_fuzzer: Fuzz MapUpdateSnapshot.
libsnapshot_fuzzer: construct valid super partition metadata.
libsnapshot_fuzzer: Fuzz CreateUpdateSnapshots
libsnapshot_fuzzer: add additional tests for more APIs
libsnapshot_fuzzer: use protobuf
libsnapshot_fuzzer: map super image
This won't happen in practice because device size is never
zero. Hypothetically, if it is, PartitionCowCreator still
suggests that a CoW size of 8192 bytes needs to be created. In
reality, it is not necessary.
Test: libsnapshot_fuzzer
Bug: 155484992
Change-Id: I6c69f54820522d50c699384eec90c474ca3a9402
If a CHECK or LOG(FATAL) is hit, also attempt to log the current
corpus.
Test: pass
Bug: 154633114
Change-Id: Id0f376021011924f5d64eb5b591b5ebab6dc7dbc
libcrypto_utils is not available as 32 bit library in 64 bit devices.
Import the library as static.
Bug: 148878078
Test: nativetest/fiemap_image_test
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I2b8cd69d06607f4216e4e2220dd8561e6eff323c
Use protobuf because it already has all the fuzzing implemenetations.
Delete fuzz_utils.
Pros:
- Fuzzing protobuf is faster; it is easy to achieve 4K exec/s
- It is more guided; protobufs are fuzzed using mutators, and mutators
should have better knowledge of the structure of the fuzz data
- No more hand-written parsing code of the fuzz data. That code in
fuzz_utils.h is deleted.
- Corpus data can be reused even after adding new fields in the protobuf
- Corpus data is human-readable and easily manually written (it is
the text format of the protobuf)
Cons:
- The "actions" are "declared" in protobuf definition and "defined" in
C++, so there's more boilerplate to write. Adding a new "Action"
requires changes in both.
Test: run libsnapshot_fuzzer
Bug: 154633114
Change-Id: Idc2a6b2c087e370e4cfef53142a244b9b275389e
Operations on (unsigned long) f_bsize and f_bfree are correctly handled
on 64 bit architectures, but when switching to 32 bit, the
multiplication between the two could result in an overflow, causing the
test to crash.
Fix by using a uint64_t operand, hinting the compiler to handle the
whole multiplication with 64 bit operands.
Bug: 154355449
Bug: 148889015
Test: vts_libsnapshot_test (32 bit)
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: Ief5c03ff7954c4a3e8597ef6e7df467f59428877
These shared_libs are missing from /system/lib/ on 64-bit devices.
Test: Build, install, and run 32bit vts_libsnapshot_test.
Bug: 154115505
Change-Id: Iaf2014748546a055d35e4fe0e24969eef13db7fa
The test is guaranteed to fail because userdata is itself a fiemap-backed device.
Bug: 154447105
Test: fiemap_writer_test on DSU
Change-Id: Ied35da0eb7aba3daca7ed430f006bf1e90e21dca
This code is complex and alignment_offset is not useful for
optimization. Remove it, and add another test that misaligned extents do
not cause overlapping partitions.
Bug: 154646936
Test: liblp_test gtests
Change-Id: I563122282e940e07a7ece97ed1a9846ad1f3253c
The "OwnsSector" tests did not work if one range fit completely inside
another range. The new OverlapsWith() methods address this case.
Bug: 154277287
Bug: 154646936
Test: liblp_test gtests
Change-Id: I1a59069db4ffe4f13c45963c4847cff7b3dd3dfc
loop_control.h already provides loop device management APIs that we need
here. In addition, this change fixes a subtle race condition between
uevented creating a loop device node in userspace and
PrepareZramBackingDevice accessing it without waiting for it to be
created.
Test: device boots
Test: adb reboot userspace
Bug: 154500256
Change-Id: If80f18c8c337210030a6caf2aec6f7a47472b6fb
Merged-In: If80f18c8c337210030a6caf2aec6f7a47472b6fb
(cherry picked from commit c8313adf88)
In vts_libsnapshot_test, liblp was explicitly imported as static
library, but due to the importing of libsnapshot_defaults, it also
inherited the shared importing.
The import in libsnapshot_default, is not required, drop it.
Test: manual inspection with ldd
Bug: 148889015
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I12ba0516a482dc917848b5f34cccc659a60a4803
libsnapshot* uses update_metadata-protos. This
used to be optimized out, but now that SnapshotManager is
virtual, CreateUpdateSnapshots can no longer be optimized out.
Bug: 148956645
Test: compiles
Change-Id: Ib67cafd156308bf5a477996ec32eb786f8e896db
This is preferred over SnapshotMergeStats::GetInstance because
the latter needs a concrete SnapshotManager, not the ISnapshotManager
interface.
SnapshotManagerStub::GetSnapshotMergeStatsInstance returns
a SnapshotMergeStatsStub instance.
Test: vts_libsnapshot_test
Bug: 148956645
Change-Id: Ife0ad6d3ce85333cbf395d07f74dedc9ca3fe675
Avoid crashes in update_engine. When SnapshotManager
should not be used (e.g. Virtual A/B is not enabled),
use the stub instead.
Bug: 148956645
Test: update_engine_unittests
Change-Id: Id524a1dfe5d085d439fc5492d4b7f72ee583c17e
This is the public interface of SnapshotManager.
SnapshotManager then inherits from it.
Test: compiles
Test: vts_libsnapshot_test
Test: update_engine_unittests
Bug: 148956645
Bug: 153555889
Change-Id: Ib19c038f9bb41dd8d27f72ff6a24c231cd4c5a76
ImageManagerTest had been temporarily disabled because flaky.
This test looks stable now, re-enable it.
Bug: 148889015
Test: atest vts_libsnapshot_test [-- --abi x86]
Signed-off-by: Alessio Balsini <balsini@google.com>
Change-Id: I858661fed7f58d1e2857ed88f5d8e0f5220bf8c2
This test is pretty straight forward: create two large files, then merge
one into the other while injecting kernel crashes. At the end,
block-by-block validation is performed against both the snapshot-merge target
and the file written to disk.
Bug: 139092356
Test: instructions in PowerTest.md
Change-Id: I28cc88160cf824039966abff4e61382090a354c5
Some of the test cases in CtsInitTestCases and CtsFsMgrTestCases require
root. This CL makes it possible to run such tests cases on userdebug
builds, which in turn means that they will be run on presubmit.
New option was implemented in
https://android-review.googlesource.com/c/platform/tools/tradefederation/+/1283834
Test: atest CtsInitTestCases
Test: atest CtsFsMgrTestCases
Change-Id: I3d29789ddd7ac549e40ac193c58d986670c49285