OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [testsuite/] [test-utils.sh.in] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
# Define various parameters for use in test runs.
2
# Requires $test to be defined before sourcing.
3
 
4
if [ "${test}" == "" ]
5
then
6
    echo "\$test not defined" >&2
7
    exit 1
8
fi
9
 
10
if [ "${test}" != "driver" ]
11
then
12
    echo "Running ${test} ..."
13
fi
14
 
15
srcdir=@srcdir@
16
 
17
cgendir=${srcdir}/..
18
 
19
GUILE=`if test -f ../../guile/libguile/guile ; then echo ../../guile/libguile/guile; else echo guile ; fi`
20
GUILEFLAGS="-l ${cgendir}/guile.scm -s"
21
 
22
CGENFLAGS=
23
 
24
cgen_output_file=${test}.cgen.out
25
test_output_file=${test}.test.out
26
rm -f ${cgen_output_file} ${test_output_file}
27
 
28
tmp_match=match-${test}.tmp
29
tmp_expr=expr-${test}.tmp
30
rm -f ${tmp_match} ${tmp_expr}
31
 
32
exit_code=0
33
 
34
# Invoke this to run cgen.
35
# Usage: run_cgen [-f] cpu-file-path
36
# -f: cgen is expected to fail (useful for testing error handling)
37
 
38
run_cgen() {
39
    expect_fail=false
40
    [ "$1" == "-f" ] && { expect_fail=true ; shift ; }
41
 
42
    [ $# -ne 1 ] && { echo "missing cpu_file" >&2 ; exit 1 ; }
43
    cpu_file=$1
44
 
45
    if ${GUILE} ${GUILEFLAGS} ${cgendir}/cgen-testsuite.scm \
46
        -s ${cgendir} \
47
        -b ${CGENFLAGS} \
48
        -a ${cpu_file} \
49
        -T ${cgen_output_file} >& ${test_output_file}
50
    then
51
        ${expect_fail} && { fail "${test} run of cgen expected to fail" ; }
52
    else
53
        ${expect_fail} || { fail "${test} run of cgen" ; }
54
    fi
55
}
56
 
57
post_process() {
58
    file=${test_output_file}
59
 
60
    if grep -q FAIL $file
61
    then
62
        fail "In test output:"
63
        grep FAIL $file
64
    fi
65
 
66
    grep "^MATCH: " $file | sed -e 's/^MATCH://' > ${tmp_match}
67
    grep "^EXPR: " $file | sed -e 's/^EXPR://' > ${tmp_expr}
68
 
69
    if ! cmp -s ${tmp_match} ${tmp_expr}
70
    then
71
        fail "Differences from expected output:"
72
        diff ${tmp_match} ${tmp_expr}
73
    fi
74
}
75
 
76
fail() {
77
    echo "FAIL: $*"
78
    exit_code=1
79
}
80
 
81
finish() {
82
    exit ${exit_code}
83
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.