* testsuiteb/config-sub.sh (run_config_sub_idempotent): New.

* config.sub: Fixes to pass the testsuite.

Signed-off-by: Ben Elliston <bje@gnu.org>
This commit is contained in:
John Ericson
2018-08-08 11:45:12 +10:00
committed by Ben Elliston
parent dbe15d73a8
commit 08ede0dcc1
3 changed files with 70 additions and 20 deletions

View File

@ -9,28 +9,54 @@
# the alias expands to the expected canonical triplet.
set -eu
shopt -s lastpipe
verbose=false
run_config_sub()
{
local -i rc=0
numtests=0
name="checks"
while read -r alias canonical ; do
output=$(sh -eu ../config.sub "$alias")
if test "$output" != "$canonical" ; then
echo "FAIL: $alias -> $output, but expected $canonical"
rc=1
else
$verbose && echo "PASS: $alias"
$verbose && echo "PASS: $alias -> $canonical"
fi
numtests+=1
done < config-sub.data
return $rc
}
if run_config_sub ; then
numtests=$(wc -l config-sub.data | cut -d' ' -f1)
$verbose || echo "PASS: config.sub checks ($numtests tests)"
else
exit 1
fi
run_config_sub_idempotent()
{
local -i rc=0
numtests=0
name="idempotency checks"
sed -r 's/\t+/\t/g' < config-sub.data | cut -f 2 | uniq | while read -r canonical ; do
output=$(sh -eu ../config.sub "$canonical")
if test "$output" != "$canonical" ; then
echo "FAIL: $canonical -> $output, but $canonical should map to itself"
rc=1
else
$verbose && echo "PASS: $canonical -> $canonical"
fi
numtests+=1
done
return $rc
}
exit 0
declare -i rc=0 numtests
declare name
for testsuite in run_config_sub run_config_sub_idempotent ; do
if $testsuite; then
$verbose || echo "PASS: config.sub $name ($numtests tests)"
else
rc=1
fi
done
exit $rc