add self test in travis-ci

pull/1/head
cfig 9 years ago
parent ba75f8f6af
commit ea493a7d6d

@ -1,19 +1,11 @@
dist: trusty
language: java language: java
before_install: before_install:
- sudo apt-get -qq update - sudo apt-get -qq update
- sudo apt-get install -y libblkid-dev - sudo apt-get install -y libblkid-dev
compiler: script:
- gcc - ./gradlew check
- clang - ./gradlew _setup
install: - ./gradlew unpack
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi - ./gradlew pack
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- clang

@ -6,3 +6,10 @@ edit boot.img for Nexus Devices
## [usage] ## [usage]
TBD TBD
## test
filename: src/test/resources/boot.img
extracted from Nexus 5x(code: bullhead) factory images from [Google](https://dl.google.com/dl/android/aosp/bullhead-mda89e-factory-29247942.tgz)

@ -9,10 +9,6 @@ import java.util.zip.GZIPOutputStream;
def workdir='build/unzip_boot' def workdir='build/unzip_boot'
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
model { model {
buildTypes { buildTypes {
release release
@ -50,7 +46,11 @@ model {
task unpack_bootimg(type: Exec, dependsOn: 'abootimgExecutable') { task unpack_bootimg(type: Exec, dependsOn: 'abootimgExecutable') {
doFirst { doFirst {
new File(workdir + '/root').mkdirs() def rootdir = new File(workdir)
if (rootdir.exists()) {
rootdir.deleteDir()
}
rootdir.mkdirs()
} }
workingDir '.' workingDir '.'
executable 'build/exe/abootimg/abootimg' executable 'build/exe/abootimg/abootimg'
@ -63,6 +63,13 @@ task unpack_ramdisk_gz << {
unpack_ramdisk_gz.dependsOn(unpack_bootimg) unpack_ramdisk_gz.dependsOn(unpack_bootimg)
task unpack_cpio(type: Exec, dependsOn: unpack_ramdisk_gz) { task unpack_cpio(type: Exec, dependsOn: unpack_ramdisk_gz) {
doFirst {
def rootdir = new File(workdir+ "/root")
if (rootdir.exists()) {
rootdir.deleteDir()
}
rootdir.mkdirs()
}
workingDir workdir + "/root" workingDir workdir + "/root"
executable 'cpio' executable 'cpio'
args = ['-i', '-F', '../ramdisk.img'] args = ['-i', '-F', '../ramdisk.img']
@ -77,9 +84,7 @@ task pack_ramdisk_and_gz { Task task ->
doLast { doLast {
ByteArrayOutputStream mkbootfs_out = new ByteArrayOutputStream() ByteArrayOutputStream mkbootfs_out = new ByteArrayOutputStream()
task.project.exec { task.project.exec {
commandLine = [ commandLine = [ 'build/exe/mkbootfs/mkbootfs', workdir + "/root" ]
'build/exe/mkbootfs/mkbootfs', workdir + "/root"
]
standardOutput = mkbootfs_out standardOutput = mkbootfs_out
} }
def ByteArrayInputStream gzip_in = new ByteArrayInputStream(mkbootfs_out.buf) def ByteArrayInputStream gzip_in = new ByteArrayInputStream(mkbootfs_out.buf)
@ -88,13 +93,20 @@ task pack_ramdisk_and_gz { Task task ->
} }
pack_ramdisk_and_gz.dependsOn('mkbootfsExecutable') pack_ramdisk_and_gz.dependsOn('mkbootfsExecutable')
task pack_clear(type: Exec, dependsOn: [pack_ramdisk_and_gz, 'mkbootimgExecutable']) << { task pack_clear(type: Exec, dependsOn: [pack_ramdisk_and_gz, 'mkbootimgExecutable']) {
commandLine 'build/exe/mkbootimg/mkbootimg', def theCmdLine = getRamdiskConfig(workdir, 'cmdline')
def theBaseAddr = getBaseAddress(workdir)
workingDir '.'
executable 'build/exe/mkbootimg/mkbootimg'
args = [
'--kernel', workdir + "/kernel", '--kernel', workdir + "/kernel",
'--ramdisk', workdir + "/ramdisk.img.gz", '--ramdisk', workdir + "/ramdisk.img.gz",
'--cmdline', getRamdiskConfig(workdir, 'cmdline'), '--cmdline', theCmdLine,
'--base', getBaseAddress(workdir), '--base', theBaseAddr,
'--output', 'boot.img.clear' '--output', 'boot.img.clear']
}
if (!new File(workdir + "/bootimg.cfg").exists()) {
pack_clear.enabled = false;
} }
void unGnuzipFile(String compressedFile, String decompressedFile) throws IOException { void unGnuzipFile(String compressedFile, String decompressedFile) throws IOException {
@ -154,12 +166,20 @@ void gnuZipFile(String compressedFile, String decompressedFile) throws IOExcepti
} }
String getBaseAddress(String inWorkdir) { String getBaseAddress(String inWorkdir) {
Long ret = Long.parseLong(getRamdiskConfig(inWorkdir, "kerneladdr").substring(2), 16) - 0x8000L; Long ret;
try {
ret = Long.parseLong(getRamdiskConfig(inWorkdir, "kerneladdr").substring(2), 16) - 0x8000L;
} catch (NumberFormatException e) {
throw new RuntimeException("NumberFormatException: invalid kerneladdr value")
}
return Long.toHexString(ret); return Long.toHexString(ret);
} }
String getRamdiskConfig(String inWorkdir, String inKey) { String getRamdiskConfig(String inWorkdir, String inKey) {
String ret; String ret;
if (!new File(inWorkdir+ "/bootimg.cfg").exists()) {
return "0x0";
}
try { try {
Properties prop = new Properties(); Properties prop = new Properties();
InputStream fis = new FileInputStream(inWorkdir+ "/bootimg.cfg") InputStream fis = new FileInputStream(inWorkdir+ "/bootimg.cfg")
@ -169,16 +189,20 @@ String getRamdiskConfig(String inWorkdir, String inKey) {
fis.close(); fis.close();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); throw new RuntimeException("IOException");
throw e;
} }
return ret; return ret;
} }
task pack(type: JavaExec, dependsOn: pack_clear) { task pack(type: JavaExec, dependsOn: [pack_clear, 'boot_signer:jar']) {
main = 'com.android.verity.BootSignature' main = 'com.android.verity.BootSignature'
classpath = files("boot_signer/build/libs/boot_signer.jar") classpath = files("boot_signer/build/libs/boot_signer.jar")
maxHeapSize '512m' maxHeapSize '512m'
args '/boot','boot.img.clear', 'security/verity.pk8', 'security/verity.x509.pem', 'boot.img.signed' args '/boot','boot.img.clear', 'security/verity.pk8', 'security/verity.x509.pem', 'boot.img.signed'
} }
pack.dependsOn('boot_signer:jar')
task _setup(type: Copy) {
from 'src/test/resources/boot.img'
into '.'
}

Binary file not shown.
Loading…
Cancel
Save