From f680adcc05774fd8a0f82a36de7f1de7bc97c222 Mon Sep 17 00:00:00 2001 From: cfig Date: Tue, 20 Aug 2019 09:28:30 +0800 Subject: [PATCH] update integrationTest and gradle 'check' --- .gitmodules | 2 +- .travis.yml | 6 ++---- README.md | 1 + short.md => doc/short.md | 0 integrationTest.py | 35 ++++++++++++++++++++++------------- src/integrationTest/resources | 2 +- 6 files changed, 27 insertions(+), 19 deletions(-) rename short.md => doc/short.md (100%) diff --git a/.gitmodules b/.gitmodules index 3ec7b5c..5cbf9d7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src/integrationTest/resources"] path = src/integrationTest/resources - url = https://github.com/cfig/boot_image_res.git + url = https://github.com/cfig/android_image_res diff --git a/.travis.yml b/.travis.yml index 662e954..368be30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,7 @@ language: java before_install: - sudo apt -qq update - sudo apt install -y libblkid-dev liblz4-tool - script: - ./gradlew check - - ./gradlew _setup - - ./gradlew unpack - - ./gradlew pack + - ./gradlew clean + - ./integrationTest.py diff --git a/README.md b/README.md index 0c5a4fe..9e7d9c4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[中文](doc/short.md) # Android_boot_image_editor [![Build Status](https://travis-ci.org/cfig/Android_boot_image_editor.svg?branch=master)](https://travis-ci.org/cfig/Android_boot_image_editor) [![License](http://img.shields.io/:license-apache-blue.svg?style=flat-square)](http://www.apache.org/licenses/LICENSE-2.0.html) diff --git a/short.md b/doc/short.md similarity index 100% rename from short.md rename to doc/short.md diff --git a/integrationTest.py b/integrationTest.py index 0b4d7a3..81776ce 100755 --- a/integrationTest.py +++ b/integrationTest.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import shutil, os.path, json, subprocess, hashlib, glob -import unittest, logging, sys +import unittest, logging, sys, lzma successLogo = """ +----------------------------------+ @@ -41,13 +41,20 @@ def cleanUp(): deleteIfExists("vbmeta.img") deleteIfExists("vbmeta.img.signed") -def verifySingleJson(inResourceDir, inImageDir, jsonFile): +def verifySingleJson(jsonFile): log.info(jsonFile) - resDir = inResourceDir - imgDir = inImageDir + imgDir = os.path.dirname(jsonFile) verifyItems = json.load(open(jsonFile)) for k, v in verifyItems["copy"].items(): - shutil.copyfile(os.path.join(resDir, imgDir, k), v) + it = os.path.join(imgDir, k) + if (os.path.isfile(it)): + log.info("copy file: %s -> %s" % (os.path.join(imgDir, k), v)) + shutil.copyfile(it, v) + elif (os.path.isfile(it + ".xz")): + log.info("extract file: %s -> %s" % (it + ".xz", v)) + decompressXZ(it + ".xz", v) + else: + raise subprocess.check_call("gradle unpack", shell = True) subprocess.check_call("gradle pack", shell = True) for k, v in verifyItems["hash"].items(): @@ -61,9 +68,15 @@ def verifySingleDir(inResourceDir, inImageDir): jsonFiles = glob.glob(os.path.join(resDir, imgDir) + "/*.json") for jsonFile in jsonFiles: cleanUp() - verifySingleJson(inResourceDir, inImageDir, jsonFile) + verifySingleJson(jsonFile) cleanUp() +def decompressXZ(inFile, outFile): + with lzma.open(inFile) as f: + file_content = f.read() + with open(outFile, "wb") as f2: + f2.write(file_content) + def main(): # 5.0 verifySingleDir(resDir, "5.0_fugu_lrx21m") @@ -72,19 +85,15 @@ def main(): # 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) + verifySingleJson("%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) + verifySingleJson("%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) + verifySingleDir(resDir, "9.0.0_blueline_pq1a.181105.017.a1") # Q preview verifySingleDir(resDir, "Q_preview_blueline_qpp2.190228.023") diff --git a/src/integrationTest/resources b/src/integrationTest/resources index 42ceedb..9c8f314 160000 --- a/src/integrationTest/resources +++ b/src/integrationTest/resources @@ -1 +1 @@ -Subproject commit 42ceedb9271b5ebd3cefd0815719ee5ddcd5f130 +Subproject commit 9c8f314279c08d9d06720b5be86b5894f872682c