summaryrefslogtreecommitdiff
path: root/openembedded/scripts/jtreg-test
blob: 1d62ee6e0498e223a66917173c6a7503e08b58c1 (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
111
112
113
114
115
116
117
#!/bin/bash

# JTREG LAVA test harness.
#
# Copyright (C) 2013, Linaro Limited.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
# Author: Andrew McDermott <andrew.mcdermott@linaro.org>
#

if [ $# -lt 2 ]; then
    echo "usage: $0: <test-dir> <test>" >&2
    exit 1
fi

if [ -z "$PRODUCT_HOME" ]; then
    echo "error: PRODUCT_HOME not set!" >&2
    exit 1
fi

if [ -z "$JT_HOME" ]; then
    echo "error: JT_HOME not set!" >&2
    exit 1
fi

if [ -z "$JTREG" ]; then
    JTREG=$JT_HOME/linux/bin/jtreg-lava
fi

set -x

uniq_pathname() {
    local name=$1
    name=${name#$to/}
    name=${name////-}
    echo $to/$name
}

test_dir=$1
test_to_run=$2

t=/tmp/jtreg/$test_to_run.$$
rm -rf $t
mkdir -p $t
to=$t/testoutput

# Accommodate differences between jdk tests and hotspot tests.
#
# The hotspot tests need to be invoked with TESTDIRS set and they also
# put the output one directory deeper and the output content (and
# location) is different to the jdk tests.
#
if [ -n "$TESTDIRS" ]; then
    lava-test-case $test_to_run \
        --shell \
        make -C $test_dir PRODUCT_HOME=$PRODUCT_HOME JTREG=$JTREG JT_HOME=$JT_HOME ALT_OUTPUTDIR=$t TESTDIRS=$TESTDIRS

    exit_code=$?
    to=`ls -1d $t/*/testoutput`
    zip --quiet -d $to/ARCHIVE_BUNDLE.zip 'JTwork/classes/*'
    mv $to/ARCHIVE_BUNDLE.zip $to/${test_to_run}-ARCHIVE_BUNDLE.zip
    lava-test-case-attach $test_to_run $to/${test_to_run}-ARCHIVE_BUNDLE.zip
    shopt -s nullglob
    for i in $to/JTwork/scratch/hs*.log; do
        lava-test-case-attach $test_to_run $i
    done
else
    lava-test-case $test_to_run \
        --shell \
        make -C $test_dir PRODUCT_HOME=$PRODUCT_HOME JTREG=$JTREG JT_HOME=$JT_HOME ALT_OUTPUTDIR=$t $test_to_run

    exit_code=$?

    shopt -s nullglob

    for i in $to/${test_to_run}*/*.txt; do
        name=$(uniq_pathname $i)
        cp $i $name
        if [ -s $name ]; then
            lava-test-case-attach $test_to_run $name
        fi
    done

    for i in $to/${test_to_run}*/JTwork/scratch/hs*.log; do
        lava-test-case-attach $test_to_run $i
    done

    for i in $to/${test_to_run}*/ARCHIVE_BUNDLE.zip; do
        zip --quiet -d $i 'JTwork/classes/*'
        name=$(uniq_pathname $i)
        cp $i $name
        if [ -s $name ]; then
            lava-test-case-attach $test_to_run $name
        fi
    done

    for i in $to/${test_to_run}*/Stats.txt; do
        cat $i
    done
fi

rm -rf $t

exit $exit_code