aboutsummaryrefslogtreecommitdiff
path: root/build-scripts/build-android-testsuite-restricted
blob: 76f2e9d1e5011e8f6ce689f180a1e59e2f4e714f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
###############################################################################
# Copyright (c) 2013 Linaro
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
###############################################################################

export GIT_SSH=/usr/local/bin/ssh-linaro

source "${BUILD_SCRIPT_ROOT}"/helpers

trap infrastructure_error ERR

# get the source
if [ -n "$REPO_SEED_URL" ]; then
    repo-sync-from-seed "${1}"
else
    repo-sync-from-mirror "${1}"
fi

# get toolchain
if test -n "$TOOLCHAIN_URL"; then
    wget -nv --no-check-certificate $TOOLCHAIN_URL
    toolchain_filename=`echo $TOOLCHAIN_URL | sed -e 's/.*\/\([^/]*\)$/\1/'`
    mkdir toolchain
    tar -C toolchain --strip-components 1 -xf $toolchain_filename
    rm -rf $toolchain_filename
    export PATH=`pwd`/toolchain/bin:$PATH
    if test -z "$TOOLCHAIN_TRIPLET"; then
        #assume arm-linux-gnueabihf-
	echo "WARNING: assuming arm.linux-gnueabihf toolchain"
        CROSS_COMPILE="CROSS_COMPILE=arm-linux-gnueabihf-"
    else
        CROSS_COMPILE="CROSS_COMPILE=$TOOLCHAIN_TRIPLET"
    fi
else
    echo "ERROR: TOOLCHAIN_URL is not optional."
    exit 1
fi

# build the tests
trap - ERR
if test -e "build/Makefile"; then
   make $CROSS_COMPILE -C build/ build
   make $CROSS_COMPILE -C build/ install
else
    echo "ERROR: Could not locate build tools, expecting a Makefile in build/ with targets build and install"
    exit 1
fi

trap infrastructure_error ERR

# Verify that the build has produced out/
if [ ! -d out ]; then
   echo "ERROR: out directory not found."
   exit 1
fi

# Combine output with prebuilt android images
if test -n "$ANDROID_PREBUILT_URL"; then
    #get prebuilt android
    ${BUILD_SCRIPT_ROOT}/fetch_prebuilt.py $ANDROID_PREBUILT_URL

    if [ ! -e boot.tar.bz2 ]; then
       echo "ERROR: boot.tar.bz2 not downloaded"
       exit 1
    elif [ ! -e system.tar.bz2 ]; then
       echo "ERROR: system.tar.bz2 not downloaded"
       exit 1
    elif [ ! -e userdata.tar.bz2 ]; then
       echo "ERROR: userdata.tar.bz2 not downloaded"
       exit 1
    fi

    # move the boot tarball
    mv boot.tar.bz2 out/.

    # we are assuming that the makefile has given us a out/ structure
    # containing data/ and system/ with the test files

    # uncompress the archives so we can update them
    bunzip2 --keep userdata.tar.bz2
    bunzip2 --keep system.tar.bz2
    mv userdata.tar out/.
    mv system.tar out/.

    # update the archives with the tests
    cd out
    tar -uvpf userdata.tar data
    tar -uvpf system.tar system

    # compress them again
    bzip2 userdata.tar
    bzip2 system.tar

    # create tarballs with just the tests
    tar -pcjf tests_userdata.tar.bz2 data
    tar -pcjf tests_system.tar.bz2 system

    #clean up
    rm -rf data
    rm -rf system
    cd ..
    rm -rf system.tar.bz2
    rm -rf userdata.tar.bz2
else
    echo "ERROR: Could not locate prebuilt android image, please set ANDROID_PREBUILT_URL"
fi