config/testsuite/config-guess.sh
Issam E. Maghni 0b5188819b * config.guess: Replace "if [ EXPR ]" with "if test EXPR".
* config.sub: Likewise.
	* testsuite/config-guess.sh: Likewise.
	* testsuite/config-sub.sh: Likewise.

Signed-off-by: Ben Elliston <bje@gnu.org>
2020-08-17 13:36:41 +10:00

58 lines
1.5 KiB
Bash

#!/bin/bash
#
# Copyright 2004, 2005, 2009, 2012, 2015, 2018 Free Software
# Foundation, Inc.
# Contributed by Ben Elliston <bje@gnu.org>.
#
# This test reads 5-tuples from config-guess.data: the components of
# the simulated uname(1) output and the expected GNU system triplet.
set -eu
verbose=false
PATH=$(pwd):$PATH
run_config_guess()
{
local -i rc=0
while IFS='|' read -r machine release system version processor triplet ; do
sed \
-e "s,@MACHINE@,$machine," \
-e "s,@RELEASE@,$release," \
-e "s,@SYSTEM@,$system," \
-e "s,@VERSION@,$version," \
-e "s,@PROCESSOR@,$processor," > ./uname << EOF
#!/bin/sh
test \$# -ne 1 && exec sh \$0 -s
test \$1 = -m && echo "@MACHINE@" && exit 0
test \$1 = -r && echo "@RELEASE@" && exit 0
test \$1 = -s && echo "@SYSTEM@" && exit 0
test \$1 = -v && echo "@VERSION@" && exit 0
test \$1 = -p && echo "@PROCESSOR@" && exit 0
EOF
chmod +x uname
output=$(CC_FOR_BUILD=no_compiler_found sh -eu ../config.guess 2>/dev/null)
if test $? != 0 ; then
echo "FAIL: unable to guess $machine:$release:$system:$version"
rc=1
continue
fi
if test "$output" != "$triplet" ; then
echo "FAIL: $output (expected $triplet)"
rc=1
continue
fi
$verbose && echo "PASS: $triplet"
done
return $rc
}
if sed 's, | ,|,g' < config-guess.data | run_config_guess ; then
numtests=$(wc -l config-guess.data | cut -d' ' -f1)
$verbose || echo "PASS: config.guess checks ($numtests tests)"
else
echo "Unexpected failures."
exit 1
fi
exit 0