From fa77ee8470a52412177adf37f0ef157a937fa45c Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Thu, 20 Feb 2020 23:09:44 -0800 Subject: Generate recovery.img for unittest during build time The unit tests for imgpatch is comparing the compressed bytes. As a result, these unit tests will fail with libz change. Since the recovery image is just a gzipped ramdisk with some wrappings, we can generate with minigzip it during the build time. This matches the usage in the real world, where we generate the patch with the host side libz; and apply the patch with the library on the device. Bug: 149443852 Test: tests pass on Pixel3 Change-Id: I7885765a161c6bf765671bc55a72cfcaa04b4138 --- tests/Android.bp | 19 +++++++++++++++++++ tests/testdata/recovery.img | Bin 529707 -> 0 bytes tests/testdata/recovery_body | Bin 0 -> 1293568 bytes tests/testdata/recovery_head | Bin 0 -> 45056 bytes tests/testdata/recovery_tail | Bin 0 -> 5191 bytes 5 files changed, 19 insertions(+) delete mode 100644 tests/testdata/recovery.img create mode 100644 tests/testdata/recovery_body create mode 100644 tests/testdata/recovery_head create mode 100644 tests/testdata/recovery_tail diff --git a/tests/Android.bp b/tests/Android.bp index bde1bc5f3..3d223907c 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -94,6 +94,24 @@ librecovery_static_libs = [ "libtinyxml2", ] +// recovery image for unittests. +// ======================================================== +genrule { + name: "recovery_image", + cmd: "cat $(location testdata/recovery_head) <(cat $(location testdata/recovery_body) | $(location minigzip)) $(location testdata/recovery_tail) > $(out)", + srcs: [ + "testdata/recovery_head", + "testdata/recovery_body", + "testdata/recovery_tail", + ], + tools: [ + "minigzip", + ], + out: [ + "testdata/recovery.img", + ], +} + cc_test { name: "recovery_unit_test", isolated: true, @@ -127,6 +145,7 @@ cc_test { data: [ "testdata/*", + ":recovery_image", ":res-testdata", ], } diff --git a/tests/testdata/recovery.img b/tests/testdata/recovery.img deleted file mode 100644 index b862e6f0c..000000000 Binary files a/tests/testdata/recovery.img and /dev/null differ diff --git a/tests/testdata/recovery_body b/tests/testdata/recovery_body new file mode 100644 index 000000000..48d7c10a5 Binary files /dev/null and b/tests/testdata/recovery_body differ diff --git a/tests/testdata/recovery_head b/tests/testdata/recovery_head new file mode 100644 index 000000000..7f494d098 Binary files /dev/null and b/tests/testdata/recovery_head differ diff --git a/tests/testdata/recovery_tail b/tests/testdata/recovery_tail new file mode 100644 index 000000000..7fe2c6ce8 Binary files /dev/null and b/tests/testdata/recovery_tail differ -- cgit v1.2.3