3 # This file is part of the coreboot project.
5 # Copyright 2016 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; version 2 of the License.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
17 # These tests are currently known to be broken and should not result in a
36 # ------------------------------------------------------------------- #
38 BASEDIR
="$(dirname "$0")"
39 BUILDDIR
="$BASEDIR/build"
40 LOGDIR
="$BUILDDIR/logs"
45 echo "Usage: test.sh [--nocolor] CLASS"
47 echo "CLASS selects a group of tests to run. It must be one of the following:"
48 echo " all - all tests"
49 echo " simple - simple tests"
50 echo " linux - linux programs whose output is checked against a reference"
52 echo "--nocolor disables colors."
57 if [ "$1" = "--nocolor" ]; then
63 if [ -t 1 -a "$COLORS" -eq 1 ]; then
64 red
() { printf "\033[1;31m%s\033[0m" "$*"; }
65 green
() { printf "\033[1;32m%s\033[0m" "$*"; }
66 blue
() { printf "\033[1;34m%s\033[0m" "$*"; }
68 red
() { printf "%s" "$*"; }
69 green
() { printf "%s" "$*"; }
70 blue
() { printf "%s" "$*"; }
74 NUM_TOTAL
=0 # Number of tests that were run
75 NUM_FAIL
=0 # Number of tests that failed unexpectedly
76 NUM_BROKEN
=0 # Number of tests that failed expectedly
77 NUM_PASS
=0 # Number of tests that passed expectedly
78 NUM_FIXED
=0 # Number of tests that passed unexpectedly
82 ROMCC
="$BUILDDIR/romcc"
83 if [ ! -f "$ROMCC" ]; then
84 echo "romcc not found! Please run \"make\"."
95 printf "passed: %s\t(%s newly fixed)\n" $NUM_PASS $NUM_FIXED
96 printf "failed: %s\t(%s known broken)\n" $NUM_FAIL $NUM_BROKEN
97 printf "total: %s\n" $NUM_TOTAL
102 for t
in $XFAIL_TESTS; do
103 if [ "$t" = "$1" ]; then
111 NUM_TOTAL
=$
((NUM_TOTAL
+ 1))
112 NUM_PASS
=$
((NUM_PASS
+ 1))
115 if is_xfail
"$(basename "$1")"; then
117 NUM_FIXED
=$
((NUM_FIXED
+ 1))
123 NUM_TOTAL
=$
((NUM_TOTAL
+ 1))
124 NUM_FAIL
=$
((NUM_FAIL
+ 1))
127 if is_xfail
"$(basename "$1")"; then
128 blue
" (known broken)"
129 NUM_BROKEN
=$
((NUM_BROKEN
+ 1))
135 # TODO: "timeout" is not POSIX compliant. Use something that is.
136 timeout
60 "$ROMCC" $1 "$2" -o "$BUILDDIR/dummy.S"
140 echo "Running simple tests..."
143 for t
in $
(find "$BASEDIR/tests" -name 'simple_test*.c'); do
144 printf "%s" "$(basename "$t")"
147 local logfile
="$LOGDIR/$(basename "$t").log"
148 rm "$logfile" >/dev
/null
2>&1
149 for opt
in "" "-O" "-O2" "-mmmx" "-msse" "-mmmx -msse" \
150 "-O -mmmx" "-O -msse" "-O -mmmx -msse" \
151 "-O2 -mmmx" "-O2 -msse" "-O2 -mmmx -msse"; do
152 if run_simple_test
"$opt" "$t" \
153 >> "$logfile" 2>&1; then
168 local base
="$(basename "$1")"
170 # TODO: "timeout" is not POSIX compliant. Use something that is.
172 timeout
60 "$ROMCC" "$1" -o "$BUILDDIR/$base.S" ||
return 1
173 as
--32 "$BUILDDIR/$base.S" -o "$BUILDDIR/$base.o" ||
return 1
174 ld
-m elf_i386
-T "$BASEDIR/tests/ldscript.ld" \
175 "$BUILDDIR/$base.o" -o "$BUILDDIR/$base.elf" ||
return 1
176 timeout
60 "$BUILDDIR/$base.elf" > "$BUILDDIR/$base.out" ||
return 1
178 diff -u "$BASEDIR/results/${base%.c}.out" "$BUILDDIR/$base.out"
182 echo "Running linux tests..."
185 for t
in $
(find "$BASEDIR/tests" -name 'linux_test*.c'); do
186 printf "%s... " "$(basename "$t")"
188 local logfile
="$LOGDIR/$(basename "$t").log"
189 if run_linux_test
"$t" > "$logfile" 2>&1; then
200 if [ $# -ne 1 ]; then
224 echo "Invalid test class $CLASS"
230 if [ $NUM_FAIL -ne $NUM_BROKEN ]; then