summaryrefslogtreecommitdiff
path: root/openembedded/scripts/jtreg-test
blob: 261e1fa34be03bb2d3dca75e6a3e85f1b4268c1f (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
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash

# LAVA wrapper for invoking jtreg(1) and accumulating the results.
#
# 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>
#

# All options before the '--' are for this script. The remaining are
# for jtreg(1).

test_case=unknown
java_vm=-client
product_home=/usr/lib/jvm/java-8-openjdk

while getopts ":j:o:p:t:" opt; do
    case $opt in
	j)
	    java_vm=$OPTARG
	    ;;
	o)
	    output_dir=$OPTARG
	    ;;
	p)
	    product_home=$OPTARG
	    ;;
	t)
	    test_case=$OPTARG
	    ;;
	\?)
	    echo "Invalid option: -$OPTARG" >&2
	    exit 1
	    ;;
	:)
	    echo "Option -$OPTARG requires an argument." >&2
	    exit 1
	    ;;
    esac
done

shift $((OPTIND-1))

output_dir=/tmp/jtreg/$test_case.$$
rm -rf $output_dir

jtreg						\
    -J${java_vm}				\
    -vmoption:${java_vm}			\
    -jdk:"${product_home}"			\
    -w:$output_dir/JTwork			\
    -r:$output_dir/JTreport			\
    "$@"

exit_code=$?

shopt -s globstar
shopt -s nullglob

# By pushd'ing we make the attached filenames in the LAVA dashboard
# much smaller.

mkdir -p $output_dir/JTwork/failed

if [ -d $output_dir/JTreport/text ]; then
    pushd $output_dir/JTreport/text
    for i in *.txt; do
	lava-test-run-attach $i
	if [ $i = "summary.txt" ]; then
	    grep 'Failed\.' $i > failed.txt
	    grep 'Passed\.' $i > success.txt
	    lava-test-run-attach failed.txt
	    lava-test-run-attach success.txt
            while read -r line; do
		tc=$(echo $line | awk '{print $1}')
		y=$(dirname $tc)
		z=$(basename $tc .java)
		lava-test-case $z --result pass
		echo "JTREG-SUCCESS $z"
            done < success.txt
            while read -r line; do
		tc=$(echo $line | awk '{print $1}')
		y=$(dirname $tc)
		z=$(basename $tc .java)
		test_result=$output_dir/JTwork/$y/${z}.jtr
		if [ -e $test_result ]; then
		    pushd $output_dir/JTwork
		    mkdir -p failed-results/$y
		    cp $test_result failed-results/$y/${z}.jtr
		    pushd failed-results
		    lava-test-case $z --result fail
		    lava-test-case-attach $z $y/${z}.jtr text/plain
		    popd
		    echo "JTREG-FAIL $z"
		    popd
		fi
	    done < failed.txt
	fi
    done
    popd
fi

if [ -d $output_dir ]; then
    pushd $output_dir
    # Remove .class files as they are quite large.
    find . -name \*.class -print | xargs rm
    zip --quiet -r RESULTS-BUNDLE.zip *
    lava-test-run-attach RESULTS-BUNDLE.zip
    popd
fi

rm -rf $output_dir

exit $exit_code