From 3dd9f1e68556d53a248f6ed0817e39ac733df313 Mon Sep 17 00:00:00 2001 From: cfig Date: Tue, 30 Apr 2019 10:53:31 +0800 Subject: [PATCH] update integrationTest for android Q preview --- README.md | 3 +- doc/additional_tricks.md | 4 ++ integrationTest.py | 95 +++++++++++++++++++++-------------- src/integrationTest/resources | 2 +- 4 files changed, 64 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 656a91a..ed8dd00 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Supported images: (2) These utilities are known to work for Nexus/Pixel boot.img for the following Android releases: - AOSP master - - Lollipop (5.0) - Pie (9) + - Lollipop (5.0) - Q preview ## 2. Usage Put your boot.img to current directory, then start gradle 'unpack' task: @@ -72,6 +72,7 @@ We now support both VB 1.0 and AVB 2.0 layouts. | Device Model | Manufacturer | Compatible | Android Version | Note | |--------------------------------|--------------|----------------------|--------------------------|------| +| Pixel 3 (blueline) | Google | Y | Q preview (qpp2.190228.023,
2019)| [more ...](doc/additional_tricks.md#pixel-3-blueline) | | Pixel XL (marlin) | HTC | Y | 9.0.0 (PPR2.180905.006,
Sep 2018)| [more ...](doc/additional_tricks.md#pixel-xl-marlin) | | Z18(NX606J) | ZTE | Y | 8.1.0 | [more...](doc/additional_tricks.md#nx606j) | | Nexus 9 (volantis/flounder) | HTC | Y(with some tricks) | 7.1.1 (N9F27M, Oct 2017) | [tricks](doc/additional_tricks.md#tricks-for-nexus-9volantis)| diff --git a/doc/additional_tricks.md b/doc/additional_tricks.md index 36f76aa..2df6eaa 100644 --- a/doc/additional_tricks.md +++ b/doc/additional_tricks.md @@ -37,6 +37,10 @@ Now we can work with 'raw\_boot' Due to the configuration "BOARD_BUILD_SYSTEM_ROOT_IMAGE := true", the embeded ramdisk in boot.img is actually used in recovery mode. +## Pixel 3 (blueline) + +Fickle Google removed "BOARD_BUILD_SYSTEM_ROOT_IMAGE" and added "ro.boot.dynamic_partitions=true", which means normal mode ramdisk is back. Besides, it also packed DTB inside boot.img. + ## NX606J Thanks to the work by [CallMESuper], ZTE NX606J boot.img is also verified to be compatible with this toolkit. diff --git a/integrationTest.py b/integrationTest.py index e74f78f..8bf57a4 100755 --- a/integrationTest.py +++ b/integrationTest.py @@ -1,13 +1,20 @@ #!/usr/bin/env python3 import shutil, os.path, json, subprocess, hashlib, glob -import unittest +import unittest, logging, sys successLogo = """ +----------------------------------+ | All test cases have PASSED | +----------------------------------+ """ +resDir = "src/integrationTest/resources" +log = logging.getLogger('TEST') +log.setLevel(logging.DEBUG) +consoleHandler = logging.StreamHandler(sys.stdout) +consoleHandler.setFormatter(logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(name)s - %(message)s', + datefmt='%Y-%m-%d %H:%M:%S')) +log.addHandler(consoleHandler) def hashFile(fileName): hasher = hashlib.md5() @@ -20,22 +27,9 @@ def deleteIfExists(inFile): if os.path.isfile(inFile): os.remove(inFile) -def verifySingleJson(inResourceDir, inImageDir, jsonFile): - print(jsonFile) - resDir = inResourceDir - imgDir = inImageDir - verifyItems = json.load(open(jsonFile)) - for k, v in verifyItems["copy"].items(): - shutil.copyfile(os.path.join(resDir, imgDir, k), v) - - subprocess.check_call("gradle unpack", shell = True) - subprocess.check_call("gradle pack", shell = True) - - for k, v in verifyItems["hash"].items(): - print("%s : %s" % (k, v)) - unittest.TestCase().assertEqual(hashFile(k), v) - - shutil.rmtree("build") +def cleanUp(): + log.info("clean up ...") + shutil.rmtree("build", ignore_errors = True) deleteIfExists("boot.img") deleteIfExists("boot.img.clear") deleteIfExists("boot.img.google") @@ -47,33 +41,58 @@ def verifySingleJson(inResourceDir, inImageDir, jsonFile): deleteIfExists("vbmeta.img") deleteIfExists("vbmeta.img.signed") +def verifySingleJson(inResourceDir, inImageDir, jsonFile): + log.info(jsonFile) + resDir = inResourceDir + imgDir = inImageDir + verifyItems = json.load(open(jsonFile)) + for k, v in verifyItems["copy"].items(): + shutil.copyfile(os.path.join(resDir, imgDir, k), v) + subprocess.check_call("gradle unpack", shell = True) + subprocess.check_call("gradle pack", shell = True) + for k, v in verifyItems["hash"].items(): + log.info("%s : %s" % (k, v)) + unittest.TestCase().assertEqual(hashFile(k), v) + def verifySingleDir(inResourceDir, inImageDir): resDir = inResourceDir imgDir = inImageDir - print("enter %s ..." % os.path.join(resDir, imgDir)) + log.info("Enter %s ..." % os.path.join(resDir, imgDir)) jsonFiles = glob.glob(os.path.join(resDir, imgDir) + "/*.json") for jsonFile in jsonFiles: + cleanUp() verifySingleJson(inResourceDir, inImageDir, jsonFile) + cleanUp() -resDir = "src/integrationTest/resources" -# 5.0 -verifySingleDir(resDir, "5.0_fugu_lrx21m") -# 6.0 -verifySingleDir(resDir, "6.0.0_bullhead_mda89e") -# 7.0 special boot -subprocess.check_call("dd if=%s/7.1.1_volantis_n9f27m/boot.img of=boot.img bs=256 skip=1" % resDir, shell = True) -verifySingleJson(resDir, "7.1.1_volantis_n9f27m", "%s/7.1.1_volantis_n9f27m/boot.json" % resDir) -# 7.0 special recovery -subprocess.check_call("dd if=%s/7.1.1_volantis_n9f27m/recovery.img of=recovery.img bs=256 skip=1" % resDir, shell = True) -verifySingleJson(resDir, "7.1.1_volantis_n9f27m", "%s/7.1.1_volantis_n9f27m/recovery.json" % resDir) -# 8.0 -verifySingleDir(resDir, "8.0.0_fugu_opr2.170623.027") -# 9.0 + avb -subprocess.check_call("tar xf %s/9.0.0_blueline_pq1a.181105.017.a1/boot.img.tar.gz" % resDir, shell = True) -verifySingleJson(resDir, "9.0.0_blueline_pq1a.181105.017.a1", "%s/9.0.0_blueline_pq1a.181105.017.a1/boot.json" % resDir) -verifySingleJson(resDir, "9.0.0_blueline_pq1a.181105.017.a1", "%s/9.0.0_blueline_pq1a.181105.017.a1/vbmeta.json" % resDir) +def main(): + # 5.0 + verifySingleDir(resDir, "5.0_fugu_lrx21m") + # 6.0 + verifySingleDir(resDir, "6.0.0_bullhead_mda89e") + # 7.0 special boot + cleanUp() + subprocess.check_call("dd if=%s/7.1.1_volantis_n9f27m/boot.img of=boot.img bs=256 skip=1" % resDir, shell = True) + verifySingleJson(resDir, "7.1.1_volantis_n9f27m", "%s/7.1.1_volantis_n9f27m/boot.json" % resDir) + # 7.0 special recovery + cleanUp() + subprocess.check_call("dd if=%s/7.1.1_volantis_n9f27m/recovery.img of=recovery.img bs=256 skip=1" % resDir, shell = True) + verifySingleJson(resDir, "7.1.1_volantis_n9f27m", "%s/7.1.1_volantis_n9f27m/recovery.json" % resDir) + # 8.0 + verifySingleDir(resDir, "8.0.0_fugu_opr2.170623.027") + # 9.0 + avb + cleanUp() + subprocess.check_call("tar xf %s/9.0.0_blueline_pq1a.181105.017.a1/boot.img.tar.gz" % resDir, shell = True) + verifySingleJson(resDir, "9.0.0_blueline_pq1a.181105.017.a1", "%s/9.0.0_blueline_pq1a.181105.017.a1/boot.json" % resDir) + cleanUp() + verifySingleJson(resDir, "9.0.0_blueline_pq1a.181105.017.a1", "%s/9.0.0_blueline_pq1a.181105.017.a1/vbmeta.json" % resDir) + # Q preview + verifySingleDir(resDir, "Q_preview_blueline_qpp2.190228.023") + + # from volunteers + verifySingleDir(resDir, "recovery_image_from_s-trace") -# from volunteers -verifySingleDir(resDir, "recovery_image_from_s-trace") + log.info(successLogo) -print(successLogo) +if __name__ == "__main__": + # execute only if run as a script + main() diff --git a/src/integrationTest/resources b/src/integrationTest/resources index c595bc0..3cddd25 160000 --- a/src/integrationTest/resources +++ b/src/integrationTest/resources @@ -1 +1 @@ -Subproject commit c595bc039cb618e505b579bab04e58970910f99c +Subproject commit 3cddd2559cb7965abf96f2bbd6b3469a959abf63