1snapshot\_power\_test 2--------------------- 3 4snapshot\_power\_test is a standalone test to simulate power failures during a snapshot-merge operation. 5 6### Test Setup 7 8Start by creating two large files that will be used as the pre-merge and post-merge state. You can take two different partition images (for example, a product.img from two separate builds), or just create random data: 9 10 dd if=/dev/urandom of=pre-merge count=1024 bs=1048576 11 dd if=/dev/urandom of=post-merge count=1024 bs=1048576 12 13Next, push these files to an unencrypted directory on the device: 14 15 adb push pre-merge /data/local/unencrypted 16 adb push post-merge /data/local/unencrypted 17 18Next, run the test setup: 19 20 adb sync data 21 adb shell /data/nativetest64/snapshot_power_test/snapshot_power_test \ 22 /data/local/unencrypted/pre-merge \ 23 /data/local/unencrypted/post-merge 24 25This will create the necessary fiemap-based images. 26 27### Running 28The actual test can be run via `run_power_test.sh`. Its syntax is: 29 30 run_power_test.sh <POST_MERGE_FILE> 31 32`POST_MERGE_FILE` should be the path on the device of the image to validate the merge against. Example: 33 34 run_power_test.sh /data/local/unencrypted/post-merge 35 36The device will begin the merge with a 5% chance of injecting a kernel crash every 10ms. The device should be capable of rebooting normally without user intervention. Once the merge has completed, the test will run a final check command to validate the contents of the snapshot against the post-merge file. It will error if there are any incorrect blocks. 37 38Two environment variables can be passed to `run_power_test.sh`: 391. `FAIL_RATE` - A fraction between 0 and 100 (inclusive) indicating the probability the device should inject a kernel crash every 10ms. 402. `DEVICE_SERIAL` - If multiple devices are attached to adb, this argument is passed as the serial to select (to `adb -s`). 41