I made it print either "PASS...\nPASS..." for both successful, or nothing otherwise, which was my best guess for what you meant. I also added 2 more cleanups of the testsuite go in 2 prior commits.

Cheers,

John

On 07/29/18 21:03, John Ericson wrote:
I'll get to this is a few hours. What do you want it to say if the checks succeed and idempotency checks fail, or vice versa? (Maybe there should be a 3rd line for overall success?)

John


_______________________________________________
config-patches mailing list
config-patches@gnu.org
https://lists.gnu.org/mailman/listinfo/config-patches

From 5a1abdc6448184ae853dec84bb22f97237588e21 Mon Sep 17 00:00:00 2001
Message-Id: 
<5a1abdc6448184ae853dec84bb22f97237588e21.1532923899.git.John.Ericson@Obsidian.Systems>
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Sun, 29 Jul 2018 22:12:56 -0400
Subject: [PATCH 1/3]     * testsuite/config-*.sh: Reindent with tabs
To: config-patches@gnu.org

---
 ChangeLog                 |  4 +++
 testsuite/config-guess.sh | 54 +++++++++++++++++++--------------------
 testsuite/config-sub.sh   | 28 ++++++++++----------
 3 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f606e2d..1acd48d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-07-30  John Ericson  <john.ericson@obsidian.systems>
+
+       * testsuite/config-*.sh: Reindent with tabs
+
 2018-07-30  Ben Elliston  <b...@gnu.org>
 
        * Makefile (check-guess, check-sub): Run tests under bash.
diff --git a/testsuite/config-guess.sh b/testsuite/config-guess.sh
index d59d28e..0648c81 100644
--- a/testsuite/config-guess.sh
+++ b/testsuite/config-guess.sh
@@ -13,14 +13,14 @@ PATH=$(pwd):$PATH
 
 run_config_guess()
 {
-    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
+       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
 [ \$# -ne 1 ] && exec sh \$0 -s
 [ \$1 = -m ] && echo "@MACHINE@" && exit 0
@@ -29,29 +29,29 @@ run_config_guess()
 [ \$1 = -v ] && echo "@VERSION@" && exit 0
 [ \$1 = -p ] && echo "@PROCESSOR@" && exit 0
 EOF
-       chmod +x uname
-       output=$(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
+               chmod +x uname
+               output=$(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)"
+       numtests=$(wc -l config-guess.data | cut -d' ' -f1)
+       $verbose || echo "PASS: config.guess checks ($numtests tests)"
 else
-  echo "Unexpected failures."
-  exit 1
+       echo "Unexpected failures."
+       exit 1
 fi
 
 exit 0
diff --git a/testsuite/config-sub.sh b/testsuite/config-sub.sh
index c5b09f6..0b1d232 100644
--- a/testsuite/config-sub.sh
+++ b/testsuite/config-sub.sh
@@ -13,24 +13,24 @@ verbose=false
 
 run_config_sub()
 {
-    rc=0
-    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"
-       fi
-    done < config-sub.data
-    return $rc
+       rc=0
+       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"
+               fi
+       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)"
+       numtests=$(wc -l config-sub.data | cut -d' ' -f1)
+       $verbose || echo "PASS: config.sub checks ($numtests tests)"
 else
-    exit 1
+       exit 1
 fi
 
 exit 0
-- 
2.17.1

From 9051a145bff67a2a8da7b666a95106c78fb4bc5c Mon Sep 17 00:00:00 2001
Message-Id: 
<9051a145bff67a2a8da7b666a95106c78fb4bc5c.1532923899.git.John.Ericson@Obsidian.Systems>
In-Reply-To: 
<5a1abdc6448184ae853dec84bb22f97237588e21.1532923899.git.John.Ericson@Obsidian.Systems>
References: 
<5a1abdc6448184ae853dec84bb22f97237588e21.1532923899.git.John.Ericson@Obsidian.Systems>
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Sun, 29 Jul 2018 22:18:29 -0400
Subject: [PATCH 2/3]     * testsuite/config-*.sh: Use `local rc` for better
 scoping
To: config-patches@gnu.org

---
 ChangeLog                 | 4 ++++
 testsuite/config-guess.sh | 2 +-
 testsuite/config-sub.sh   | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1acd48d..1db8ff9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-07-30  John Ericson  <john.ericson@obsidian.systems>
+
+       * testsuite/config-*.sh: Use `local rc` for better scoping
+
 2018-07-30  John Ericson  <john.ericson@obsidian.systems>
 
        * testsuite/config-*.sh: Reindent with tabs
diff --git a/testsuite/config-guess.sh b/testsuite/config-guess.sh
index 0648c81..0c0ac18 100644
--- a/testsuite/config-guess.sh
+++ b/testsuite/config-guess.sh
@@ -13,7 +13,7 @@ PATH=$(pwd):$PATH
 
 run_config_guess()
 {
-       rc=0
+       local -i rc=0
        while IFS='|' read -r machine release system version processor triplet 
; do
                sed \
                        -e "s,@MACHINE@,$machine," \
diff --git a/testsuite/config-sub.sh b/testsuite/config-sub.sh
index 0b1d232..4d01ee0 100644
--- a/testsuite/config-sub.sh
+++ b/testsuite/config-sub.sh
@@ -13,7 +13,7 @@ verbose=false
 
 run_config_sub()
 {
-       rc=0
+       local -i rc=0
        while read -r alias canonical ; do
                output=$(sh -eu ../config.sub "$alias")
                if test "$output" != "$canonical" ; then
-- 
2.17.1

From fd39cf37a83ead2cc41c1f90c9f417e98c99feb9 Mon Sep 17 00:00:00 2001
Message-Id: 
<fd39cf37a83ead2cc41c1f90c9f417e98c99feb9.1532923899.git.John.Ericson@Obsidian.Systems>
In-Reply-To: 
<9051a145bff67a2a8da7b666a95106c78fb4bc5c.1532923899.git.John.Ericson@Obsidian.Systems>
References: 
<5a1abdc6448184ae853dec84bb22f97237588e21.1532923899.git.John.Ericson@Obsidian.Systems>
        
<9051a145bff67a2a8da7b666a95106c78fb4bc5c.1532923899.git.John.Ericson@Obsidian.Systems>
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Sun, 29 Jul 2018 22:18:29 -0400
Subject: [PATCH 3/3]     * config.sub: Make idemopotent     *
 testsuite/config-sub.sh: Add ideompotency tests
To: config-patches@gnu.org

---
 ChangeLog               |  5 ++++
 config.sub              | 66 ++++++++++++++++++++++++++---------------
 testsuite/config-sub.sh | 41 ++++++++++++++++++++-----
 3 files changed, 81 insertions(+), 31 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1db8ff9..c239b50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-30  John Ericson  <john.ericson@obsidian.systems>
+
+       * config.sub: Make idemopotent
+       * testsuite/config-sub.sh: Add ideompotency tests
+
 2018-07-30  John Ericson  <john.ericson@obsidian.systems>
 
        * testsuite/config-*.sh: Use `local rc` for better scoping
diff --git a/config.sub b/config.sub
index 52eb02e..5f21a5d 100755
--- a/config.sub
+++ b/config.sub
@@ -569,12 +569,14 @@ case $basic_machine in
        1750a | 580 \
        | a29k \
        | aarch64 | aarch64_be \
+       | abacus \
        | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
        | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | 
alpha64pca5[67] \
        | am33_2.0 \
        | arc | arceb \
        | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | 
armv[78][arm] \
        | avr | avr32 \
+       | asmjs \
        | ba \
        | be32 | be64 \
        | bfin \
@@ -654,6 +656,9 @@ case $basic_machine in
        leon|leon[3-9])
                basic_machine=sparc-$basic_machine
                ;;
+       m6811-* | m68hc11-* | m6812-* | m68hc12-* | m68hcs12x-* | nvptx-* | 
picochip-*)
+               os=${os:-none}
+               ;;
        m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
                basic_machine=$basic_machine-unknown
                os=${os:-none}
@@ -664,6 +669,10 @@ case $basic_machine in
                basic_machine=s12z-unknown
                os=${os:-none}
                ;;
+       m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
+               basic_machine=s12z-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               os=${os:-none}
+               ;;
        ms1)
                basic_machine=mt-unknown
                ;;
@@ -674,6 +683,9 @@ case $basic_machine in
                basic_machine=$basic_machine-unknown
                os=${os:-none}
                ;;
+       xgate-*)
+               os=${os:-none}
+               ;;
        xscaleeb)
                basic_machine=armeb-unknown
                ;;
@@ -689,22 +701,26 @@ case $basic_machine in
          basic_machine=$basic_machine-pc
          ;;
        # Recognize the basic CPU types with company name.
-       580-* \
+       1750a-* | 580-* \
        | a29k-* \
        | aarch64-* | aarch64_be-* \
+       | abacus-* \
        | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
        | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
-       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* \
+       | am33_2.0-* \
+       | arc-* | arceb-* \
+       | arm-*  | arm[lb]e-* | arme[lb]-* | armv*-* \
        | avr-* | avr32-* \
+       | asmjs-* \
        | ba-* \
        | be32-* | be64-* \
        | bfin-* | bs2000-* \
        | c[123]* | c30-* | [cjt]90-* | c4x-* \
        | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \
-       | d10v-* | d30v-* | dlx-* \
-       | e2k-* | elxsi-* \
-       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+       | d10v-* | d30v-* | dlx-* | dsp16xx-* \
+       | e2k-* | elxsi-* | epiphany-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | ft32-* \
        | h8300-* | h8500-* \
        | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
        | hexagon-* \
@@ -714,8 +730,8 @@ case $basic_machine in
        | le32-* | le64-* \
        | lm32-* \
        | m32c-* | m32r-* | m32rle-* \
-       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+       | m5200-* | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* | 
v70-* | w65-* \
+       | m88110-* | m88k-* | maxq-* | mb-* | mcore-* | mep-* | metag-* \
        | microblaze-* | microblazeel-* \
        | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
        | mips16-* \
@@ -738,7 +754,7 @@ case $basic_machine in
        | mipsisa64sr71k-* | mipsisa64sr71kel-* \
        | mipsr5900-* | mipsr5900el-* \
        | mipstx39-* | mipstx39el-* \
-       | mmix-* \
+       | mn10200-* | mn10300-* \
        | moxie-* \
        | mt-* \
        | msp430-* \
@@ -748,31 +764,33 @@ case $basic_machine in
        | none-* | np1-* | ns16k-* | ns32k-* \
        | open8-* \
        | or1k*-* \
+       | or32-* \
        | orion-* \
        | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
        | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
        | pru-* \
        | pyramid-* \
        | riscv-* | riscv32-* | riscv64-* \
-       | rl78-* | romp-* | rs6000-* | rx-* \
-       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* 
| sheb-* | shbe-* \
-       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | rl78-* | rs6000-* | rx-* \
+       | score-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]ae[lb]-* | sh[23]e-* | 
she[lb]-* | sh[lb]e-* \
+       | sh[1234]e[lb]-* |  sh[12345][lb]e-* | sh3ele-* | sh64-* | sh64le-* \
        | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | 
sparclet-* \
        | sparclite-* \
        | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
+       | spu-* \
        | tahoe-* \
        | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
-       | tile*-* \
        | tron-* \
        | ubicom32-* \
        | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
        | vax-* \
        | visium-* \
        | wasm32-* \
-       | we32k-* \
-       | x86-* | x86_64-* | xc16x-* | xps100-* \
+       | x86-* | x86_64-* | xc16x-* \
        | xstormy16-* | xtensa*-* \
        | ymp-* \
+       | we32k-* \
        | z8k-* | z80-*)
                ;;
        # Recognize the basic CPU types without company name, with glob match.
@@ -787,10 +805,7 @@ case $basic_machine in
        3b*)
                basic_machine=we32k-att
                ;;
-       abacus)
-               basic_machine=abacus-unknown
-               ;;
-       alliant | fx80)
+       alliant | fx80 | fx80-alliant)
                basic_machine=fx80-alliant
                ;;
        altos | altos3068)
@@ -805,9 +820,6 @@ case $basic_machine in
        amiga | amiga-*)
                basic_machine=m68k-unknown
                ;;
-       asmjs)
-               basic_machine=asmjs-unknown
-               ;;
        blackfin-*)
                basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                os=linux
@@ -1154,6 +1166,9 @@ case $basic_machine in
        sh5el)
                basic_machine=sh5le-unknown
                ;;
+       sh5el-*)
+               basic_machine=sh5le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               ;;
        simso-wrs)
                basic_machine=sparclite-wrs
                os=vxworks
@@ -1179,6 +1194,9 @@ case $basic_machine in
        sun386 | sun386i | roadrunner)
                basic_machine=i386-sun
                ;;
+       tile*-*)
+               os=linux-gnu
+               ;;
        tile*)
                basic_machine=$basic_machine-unknown
                os=linux-gnu
@@ -1231,7 +1249,7 @@ case $basic_machine in
        romp)
                basic_machine=romp-ibm
                ;;
-       mmix)
+       mmix | mmix-knuth)
                basic_machine=mmix-knuth
                ;;
        rs6000)
@@ -1354,7 +1372,7 @@ case $os in
             | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
             | aos* | aros* | cloudabi* | sortix* \
             | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
-            | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \
+            | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
             | knetbsd* | mirbsd* | netbsd* \
             | bitrig* | openbsd* | solidbsd* | libertybsd* \
             | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
diff --git a/testsuite/config-sub.sh b/testsuite/config-sub.sh
index 4d01ee0..2f5ffc7 100644
--- a/testsuite/config-sub.sh
+++ b/testsuite/config-sub.sh
@@ -9,28 +9,55 @@
 # 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
+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
+}
+
+declare -i rc=0 numtests=0
+declare -a msgs=()
+
+for testsuite in run_config_sub run_config_sub_idempotent ; do
+       $testsuite || rc=1
+       msgs+=("PASS: config.sub $name ($numtests tests)")
+done
+
+if (( rc == 0 )); then
+       $verbose || printf '%s\n' "${msgs[@]}"
 fi
 
-exit 0
+exit $rc
-- 
2.17.1

_______________________________________________
config-patches mailing list
config-patches@gnu.org
https://lists.gnu.org/mailman/listinfo/config-patches

Reply via email to