Merge lp:~fagerstedt-axel/linaro-android-build-tools/build-android-testsuite-restricted into lp:linaro-android-build-tools

Proposed by Axel Fagerstedt
Status: Merged
Approved by: Georgy Redkozubov
Approved revision: 626
Merged at revision: 632
Proposed branch: lp:~fagerstedt-axel/linaro-android-build-tools/build-android-testsuite-restricted
Merge into: lp:linaro-android-build-tools
Diff against target: 216 lines (+195/-1)
3 files modified
build-scripts/build-android-testsuite-restricted (+110/-0)
build-scripts/fetch_prebuilt.py (+83/-0)
node/prepare_build_config.py (+2/-1)
To merge this branch: bzr merge lp:~fagerstedt-axel/linaro-android-build-tools/build-android-testsuite-restricted
Reviewer Review Type Date Requested Status
Georgy Redkozubov Approve
Review via email: mp+167126@code.launchpad.net

Description of the change

Adds a new build type which builds stand alone testsuites and bundles them with prebuilt android images fetched from snapshots.

The build script assumes that the specified repo manifest will contain a directory "build" with a makefile providing the targets build and install. It further assumes that making the two targets will produce a directory "out" containing the directories "data" and "system" with any build output in a android style directory structure.

The changes have been tested with the job: https://android-build.linaro.org/builds/~linaro-android-restricted/test-private-test-suite

To post a comment you must log in.
Revision history for this message
Georgy Redkozubov (gesha) wrote :

In general looks good.

One thing I would like to be tested is that out/ dir exists and 'thw' I guess is a mistype:

74 + # move thw boot tarball
75 + mv boot.tar.bz2 out/.
76 +
77 + # we are assuming that the makefile has given us a out/ structure
78 + # containing data/ and system/ with the test files

626. By Axel Fagerstedt

build-android-testsuite: Verify that out has been created.

Revision history for this message
Axel Fagerstedt (fagerstedt-axel) wrote :

Updated.

Revision history for this message
Georgy Redkozubov (gesha) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'build-scripts/build-android-testsuite-restricted'
2--- build-scripts/build-android-testsuite-restricted 1970-01-01 00:00:00 +0000
3+++ build-scripts/build-android-testsuite-restricted 2013-06-18 21:51:24 +0000
4@@ -0,0 +1,110 @@
5+###############################################################################
6+# Copyright (c) 2013 Linaro
7+# All rights reserved. This program and the accompanying materials
8+# are made available under the terms of the Eclipse Public License v1.0
9+# which accompanies this distribution, and is available at
10+# http://www.eclipse.org/legal/epl-v10.html
11+###############################################################################
12+
13+export GIT_SSH=/var/run/lava/ssh
14+
15+source "${BUILD_SCRIPT_ROOT}"/helpers
16+
17+trap infrastructure_error ERR
18+
19+# get the source
20+if [ -n "$REPO_SEED_URL" ]; then
21+ repo-sync-from-seed "${1}"
22+else
23+ repo-sync-from-mirror "${1}"
24+fi
25+
26+# get toolchain
27+if test -n "$TOOLCHAIN_URL"; then
28+ wget -nv --no-check-certificate $TOOLCHAIN_URL
29+ toolchain_filename=`echo $TOOLCHAIN_URL | sed -e 's/.*\/\([^/]*\)$/\1/'`
30+ mkdir toolchain
31+ tar -C toolchain --strip-components 1 -xf $toolchain_filename
32+ rm -rf $toolchain_filename
33+ export PATH=`pwd`/toolchain/bin:$PATH
34+ if test -z "$TOOLCHAIN_TRIPLET"; then
35+ #assume arm-linux-gnueabihf-
36+ echo "WARNING: assuming arm.linux-gnueabihf toolchain"
37+ CROSS_COMPILE="CROSS_COMPILE=arm-linux-gnueabihf-"
38+ else
39+ CROSS_COMPILE="CROSS_COMPILE=$TOOLCHAIN_TRIPLET"
40+ fi
41+else
42+ echo "ERROR: TOOLCHAIN_URL is not optional."
43+ exit 1
44+fi
45+
46+# build the tests
47+trap - ERR
48+if test -e "build/Makefile"; then
49+ make $CROSS_COMPILE -C build/ build
50+ make $CROSS_COMPILE -C build/ install
51+else
52+ echo "ERROR: Could not locate build tools, expecting a Makefile in build/ with targets build and install"
53+ exit 1
54+fi
55+
56+trap infrastructure_error ERR
57+
58+# Verify that the build has produced out/
59+if [ ! -d out ]; then
60+ echo "ERROR: out directory not found."
61+ exit 1
62+fi
63+
64+# Combine output with prebuilt android images
65+if test -n "$ANDROID_PREBUILT_URL"; then
66+ #get prebuilt android
67+ ${BUILD_SCRIPT_ROOT}/fetch_prebuilt.py $ANDROID_PREBUILT_URL
68+
69+ if [ ! -e boot.tar.bz2 ]; then
70+ echo "ERROR: boot.tar.bz2 not downloaded"
71+ exit 1
72+ elif [ ! -e system.tar.bz2 ]; then
73+ echo "ERROR: system.tar.bz2 not downloaded"
74+ exit 1
75+ elif [ ! -e userdata.tar.bz2 ]; then
76+ echo "ERROR: userdata.tar.bz2 not downloaded"
77+ exit 1
78+ fi
79+
80+ # move the boot tarball
81+ mv boot.tar.bz2 out/.
82+
83+ # we are assuming that the makefile has given us a out/ structure
84+ # containing data/ and system/ with the test files
85+
86+ # uncompress the archives so we can update them
87+ bunzip2 --keep userdata.tar.bz2
88+ bunzip2 --keep system.tar.bz2
89+ mv userdata.tar out/.
90+ mv system.tar out/.
91+
92+ # update the archives with the tests
93+ cd out
94+ tar -uvpf userdata.tar data
95+ tar -uvpf system.tar system
96+
97+ # compress them again
98+ bzip2 userdata.tar
99+ bzip2 system.tar
100+
101+ # create tarballs with just the tests
102+ tar -pcjf tests_userdata.tar.bz2 data
103+ tar -pcjf tests_system.tar.bz2 system
104+
105+ #clean up
106+ rm -rf data
107+ rm -rf system
108+ cd ..
109+ rm -rf system.tar.bz2
110+ rm -rf userdata.tar.bz2
111+else
112+ echo "ERROR: Could not locate prebuilt android image, please set ANDROID_PREBUILT_URL"
113+fi
114+
115
116=== added file 'build-scripts/fetch_prebuilt.py'
117--- build-scripts/fetch_prebuilt.py 1970-01-01 00:00:00 +0000
118+++ build-scripts/fetch_prebuilt.py 2013-06-18 21:51:24 +0000
119@@ -0,0 +1,83 @@
120+#!/usr/bin/python
121+
122+import json
123+import urlparse
124+import shutil
125+import urllib2
126+import os
127+import sys
128+
129+
130+def download(api_urls, files_to_get):
131+ """Example of how to use the API to download a/all files in a directory."""
132+
133+ # Get listing for file(s) pointed to by URL we were given
134+ request = urllib2.urlopen(api_urls.ls())
135+ listing = json.loads(request.read())["files"]
136+
137+ for file_info in listing:
138+
139+ if file_info["type"] == "folder":
140+ # Skip folders...
141+ continue
142+ elif not file_info["name"] in files_to_get:
143+ # only grab the specified files
144+ continue
145+
146+ # Get the licenses. They are returned as a JSON document in the form:
147+ # {"licenses":
148+ # [{"text": "<license text>", "digest": "<digest of license>"},
149+ # {"text": "<license text>", "digest": "<digest of license>"},
150+ # ...
151+ # ]}
152+ # Each license has a digest associated with it.
153+ request = urllib2.urlopen(api_urls.license(file_info["url"]))
154+ licenses = json.loads(request.read())["licenses"]
155+
156+ if licenses[0] == "Open":
157+ headers = {}
158+ else:
159+ # Dont download any licensed files
160+ continue
161+
162+ # Once the header has been generated, just download the file.
163+ req = urllib2.urlopen(urllib2.Request(api_urls.file(file_info["url"]),
164+ headers=headers))
165+ with open(os.path.basename(file_info["url"]), 'wb') as fp:
166+ shutil.copyfileobj(req, fp)
167+
168+
169+class ApiUrls():
170+ """Since we want to manipulate URLS, but urlsplit returns an immutable
171+ object this is a convenience object to perform the manipulations for us"""
172+ def __init__(self, input_url):
173+ self.parsed_url = [c for c in urlparse.urlsplit(input_url)]
174+ self.path = self.parsed_url[2]
175+
176+ def ls(self, path=None):
177+ if not path:
178+ path = self.path
179+ self.parsed_url[2] = "/api/ls" + path
180+ return urlparse.urlunsplit(self.parsed_url)
181+
182+ def license(self, path):
183+ self.parsed_url[2] = "/api/license" + path
184+ return urlparse.urlunsplit(self.parsed_url)
185+
186+ def file(self, path):
187+ self.parsed_url[2] = path
188+ return urlparse.urlunsplit(self.parsed_url)
189+
190+
191+if __name__ == '__main__':
192+ if len(sys.argv) != 2:
193+ # Check that a URL has been supplied.
194+ print >> sys.stderr, "Usage: fetch_prebuilt.py <URL>"
195+ exit(1)
196+
197+ api_urls = ApiUrls(sys.argv[1])
198+
199+ # we are only interested in the fs images
200+ files_to_get = "boot.tar.bz2", "system.tar.bz2", "userdata.tar.bz2"
201+
202+ download(api_urls, files_to_get)
203
204=== modified file 'node/prepare_build_config.py'
205--- node/prepare_build_config.py 2013-05-10 10:34:40 +0000
206+++ node/prepare_build_config.py 2013-06-18 21:51:24 +0000
207@@ -60,7 +60,8 @@
208
209 if config.get("BUILD_TYPE", "build-android") in ["build-android-private",
210 "build-android-restricted",
211- "build-android-toolchain-linaro-restricted"]:
212+ "build-android-toolchain-linaro-restricted",
213+ "build-android-testsuite-restricted"]:
214 build_type_cat = "restricted"
215 else:
216 build_type_cat = "normal"

Subscribers

People subscribed via source and target branches