blob: 06c5ebf3bfb1a03c17ba6b148a15a0791fe30446 (
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
#!/bin/bash
#
# aslts - execute ASL test suite
#
# Will build temporary versions of iASL and acpiexec
postfix=`date +%H%M%S`
tmp_iasl=/tmp/iasl-$postfix
tmp_acpiexec=/tmp/acpiexec-$postfix
tmp_acpibin=/tmp/acpibin-$postfix
TEST_CASES=
TEST_MODES=
REBUILD_TOOLS=yes
BINCOMPONLY=no
DATATABLEONLY=no
EXECONLY=no
usage() {
echo "Usage:"
echo "`basename $0` [-c case] [-m mode] [-u]"
echo "Where:"
echo " -c: Specify individual test cases (can be used multiple times)"
echo " -m: Specify individual test modes (can be used multiple times)"
echo " -u: Do not force rebuilding of ACPICA utilities (acpiexec, iasl)"
echo " -e: Perform the execution of aml files and omit binary comparison of regular aml and disassembled aml file."
echo " -b: Only perform binary comparison of regular aml and disasssembled aml file"
echo " -d: Only execute data table compiler/disassembler test"
echo ""
echo "Available test modes:"
echo " n32 32-bit unoptimized code (tests are compiled with iasl -oa -r 1 and other flags)"
echo " n64 64-bit unoptimized code (tests are compiled with iasl -oa -r 2 and other flags)"
echo " o32 32-bit optimized code (tests are compiled with iasl -r 1 and other flags)"
echo " o64 64-bit optimized code (tests are compiled with iasl -r 2 and other flags)"
echo ""
Do 3
exit 1
}
# Setup environment and variables.
# Need a path to ASLTS and iasl,acpiexec generation dir
setup_environment() {
aslts_dir=$1
generation_dir=$2
if [ -z "$generation_dir" ] ; then
echo "missing generation directory argument"
exit
elif [ -z "$aslts_dir" ] ; then
echo "missing aslts directory argument"
exit
elif [ ! -d "$generation_dir" ] ; then
echo $generation_dir is not a dir
exit
elif [ ! -d "$aslts_dir" ] ; then
echo $aslts_dir is not a dir
exit
fi
# Variables required by ASLTS
unset ASL
unset acpiexec
unset ASLTSDIR
export ASL=$tmp_iasl
export acpiexec=$tmp_acpiexec
export acpibin=$tmp_acpibin
export ASLTSDIR=$aslts_dir
export PATH=$ASLTSDIR/bin:$PATH
}
# Generate both iASL and acpiexec from source
build_acpi_tools() {
restore_dir=$PWD
cd ${generation_dir}
rm -f $tmp_iasl $tmp_acpiexec $tmp_acpibin
# Build native-width iASL compiler and acpiexec
if [ ! -e bin/iasl -o ! -e bin/acpiexec ]; then
REBUILD_TOOLS=yes
fi
if [ "x$REBUILD_TOOLS" = "xyes" ]; then
jobs=`nproc`
make clean
make iasl ASLTS=TRUE -j$jobs
make acpibin ASLTS=TRUE -j$jobs
make acpiexec ASLTS=TRUE -j$jobs
fi
if [ -d "bin" ] && [ -f "bin/iasl" ]; then
echo "Installing ACPICA tools"
cp bin/iasl $tmp_iasl
cp bin/acpiexec $tmp_acpiexec
cp bin/acpibin $tmp_acpibin
else
echo "Could not find iASL/acpiexec tools"
exit
fi
# Ensure that the tools are available
if [ ! -f $tmp_iasl ] ; then
echo "iasl compiler not found"
exit
elif [ ! -f $tmp_acpiexec ] ; then
echo "acpiexec utility not found"
exit
elif [ ! -f $tmp_acpibin ] ; then
echo "acpibin utility not found"
exit
fi
cd $restore_dir
}
# Run a simple compiler test.
# This test does the following:
# 1 generate all sample tables in the compiler
# 2 compile all tables (.asl -> .aml)
# 3 disassembles all tables (.aml -> .dsl)
# 4 recompiles all all tables (.dsl -> recomp.aml)
# 5 runs binary comparison between .aml and recomp.aml
run_compiler_template_test()
{
pushd templates
rm -f *.asl *.aml *.dsl
$ASL -T all 2> /dev/null
for filename in *.asl
do
make -s NAME=$(basename "$filename" .asl)
done
rm -f *.asl *.aml *.dsl
popd
}
# Compile and run the ASLTS suite
run_aslts() {
# Remove a previous version of the AML test code
version=`$ASL | grep version | awk '{print $5}'`
rm -rf $ASLTSDIR/tmp/aml/$version
# run templates test
run_compiler_template_test
if [ "x$DATATABLEONLY" = "xyes" ]; then
return 0
fi;
if [ "x$TEST_MODES" = "x" ]; then
TEST_MODES="n32 n64 o32 o64"
fi
Do 0 $TEST_MODES $TEST_CASES $EXECONLY
if [ $? -ne 0 ]; then
echo "ASLTS Compile Failure"
exit 1
fi
# Execute the test suite
if [ "x$BINCOMPONLY" = "xno" ]; then
echo ""
echo "ASL Test Suite Started: `date`"
start_time=$(date)
if [ "x$TEST_MODES" = "x" ]; then
TEST_MODES="n32 n64 o32 o64"
fi
Do 1 $TEST_MODES $TEST_CASES
echo ""
echo "ASL Test Suite Finished: `date`"
echo " Started: $start_time"
rm -f $tmp_iasl $tmp_acpiexec $tmp_acpibin
fi;
}
SRCDIR=`(cd \`dirname $0\`; cd ..; pwd)`
setup_environment $SRCDIR/tests/aslts $SRCDIR/generate/unix
# To use common utilities
. $SRCDIR/tests/aslts/bin/common
. $SRCDIR/tests/aslts/bin/settings
RESET_SETTINGS
INIT_ALL_AVAILABLE_CASES
INIT_ALL_AVAILABLE_MODES
while getopts "c:m:uebd" opt
do
case $opt in
b)
BINCOMPONLY=yes
echo "Running only binary comparisons"
;;
c)
get_collection_opcode "$OPTARG"
if [ $? -eq $COLLS_NUM ]; then
echo "Invalid test case: $OPTARG"
usage
else
TEST_CASES="$OPTARG $TEST_CASES"
fi
;;
d)
DATATABLEONLY=yes
echo "Running only data table test"
;;
e)
EXECONLY=yes
echo "Running tests without binary comparisons"
;;
m)
check_mode_id "$OPTARG"
if [ $? -eq 1 ]; then
echo "Invalid test mode: $OPTARG"
usage
else
TEST_MODES="$OPTARG $TEST_MODES"
fi
;;
u)
REBUILD_TOOLS=no
;;
?)
echo "Invalid argument: $opt"
usage
;;
esac
done
shift $(($OPTIND - 1))
build_acpi_tools
run_aslts
|