From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 0DFDF39B8C9E; Wed, 3 Feb 2021 15:50:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DFDF39B8C9E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-7075] libstdc++: Immediate feedback with -v X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/master X-Git-Oldrev: 0a8bc61fe0222245dcdc1d8967554167099cf2a5 X-Git-Newrev: 71f9b9bd0acc7d0749e159efb1b9b4c57197a77d Message-Id: <20210203155044.0DFDF39B8C9E@sourceware.org> Date: Wed, 3 Feb 2021 15:50:44 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2021 15:50:44 -0000 https://gcc.gnu.org/g:71f9b9bd0acc7d0749e159efb1b9b4c57197a77d commit r11-7075-g71f9b9bd0acc7d0749e159efb1b9b4c57197a77d Author: Matthias Kretz Date: Wed Feb 3 15:49:29 2021 +0000 libstdc++: Immediate feedback with -v libstdc++-v3/ChangeLog: * testsuite/experimental/simd/driver.sh: Remove executable on SIGINT. Process compiler and test executable output: In verbose mode print messages immediately, limited to 1000 lines and breaking long lines to below $COLUMNS (or 1024 if not set). Communicating the exit status of the compiler / test with the necessary pipe is done via a message through stdout/-in. Diff: --- libstdc++-v3/testsuite/experimental/simd/driver.sh | 194 ++++++++++++--------- 1 file changed, 116 insertions(+), 78 deletions(-) diff --git a/libstdc++-v3/testsuite/experimental/simd/driver.sh b/libstdc++-v3/testsuite/experimental/simd/driver.sh index cf07ff9ad85..314c6a16f86 100755 --- a/libstdc++-v3/testsuite/experimental/simd/driver.sh +++ b/libstdc++-v3/testsuite/experimental/simd/driver.sh @@ -172,81 +172,14 @@ unsupported() { echo "UNSUPPORTED: $src $type $abiflag ($*)" >> "$log" } -verify_compilation() { - failed=$1 - if [ $failed -eq 0 ]; then - warnings=$(grep -ic 'warning:' "$log") - if [ $warnings -gt 0 ]; then - fail "excess warnings:" $warnings - if $verbose; then - cat "$log" - elif ! $quiet; then - grep -i 'warning:' "$log" | head -n5 - fi - elif [ "$xfail" = "compile" ]; then - xpass "test for excess errors" - else - pass "test for excess errors" - fi - else - if [ $failed -eq 124 ]; then - fail "timeout: test for excess errors" - else - errors=$(grep -ic 'error:' "$log") - if [ "$xfail" = "compile" ]; then - xfail "excess errors:" $errors - exit 0 - else - fail "excess errors:" $errors - fi - fi - if $verbose; then - cat "$log" - elif ! $quiet; then - grep -i 'error:' "$log" | head -n5 - fi - exit 0 - fi -} - -verify_test() { - failed=$1 - if [ $failed -eq 0 ]; then - rm "$exe" - if [ "$xfail" = "run" ]; then - xpass "execution test" - else - pass "execution test" - fi - else - $keep_failed || rm "$exe" - if [ $failed -eq 124 ]; then - fail "timeout: execution test" - elif [ "$xfail" = "run" ]; then - xfail "execution test" - else - fail "execution test" - fi - if $verbose; then - lines=$(wc -l < "$log") - lines=$((lines-3)) - if [ $lines -gt 1000 ]; then - echo "[...]" - tail -n1000 "$log" - else - tail -n$lines "$log" - fi - elif ! $quiet; then - grep -i fail "$log" | head -n5 - fi - exit 0 - fi -} - write_log_and_verbose() { echo "$*" >> "$log" if $verbose; then - echo "$*" + if [ -z "$COLUMNS" ] || ! type fmt>/dev/null; then + echo "$*" + else + echo "$*" | fmt -w $COLUMNS -s - || cat + fi fi } @@ -277,7 +210,7 @@ test_selector() { return 1 } -trap "rm -f '$log' '$sum'; exit" INT +trap "rm -f '$log' '$sum' $exe; exit" INT rm -f "$log" "$sum" touch "$log" "$sum" @@ -317,17 +250,122 @@ if [ -n "$xfail" ]; then fi fi +log_output() { + if $verbose; then + maxcol=${1:-1024} + awk " +BEGIN { count = 0 } +/^###exitstatus### [0-9]+$/ { exit \$2 } +{ + print >> \"$log\" + if (count >= 1000) next + ++count + if (length(\$0) > $maxcol) { + i = 1 + while (i + $maxcol <= length(\$0)) { + len = $maxcol + line = substr(\$0, i, len) + len = match(line, / [^ ]*$/) + if (len <= 0) { + len = match(substr(\$0, i), / [^ ]/) + if (len <= 0) len = $maxcol + } + print substr(\$0, i, len) + i += len + } + print substr(\$0, i) + } else { + print + } +} +END { close(\"$log\") } +" + else + awk " +/^###exitstatus### [0-9]+$/ { exit \$2 } +{ print >> \"$log\" } +END { close(\"$log\") } +" + fi +} + +verify_compilation() { + log_output $COLUMNS + exitstatus=$? + if [ $exitstatus -eq 0 ]; then + warnings=$(grep -ic 'warning:' "$log") + if [ $warnings -gt 0 ]; then + fail "excess warnings:" $warnings + if ! $verbose && ! $quiet; then + grep -i 'warning:' "$log" | head -n5 + fi + elif [ "$xfail" = "compile" ]; then + xpass "test for excess errors" + else + pass "test for excess errors" + fi + return 0 + else + if [ $exitstatus -eq 124 ]; then + fail "timeout: test for excess errors" + else + errors=$(grep -ic 'error:' "$log") + if [ "$xfail" = "compile" ]; then + xfail "excess errors:" $errors + exit 0 + else + fail "excess errors:" $errors + fi + fi + if ! $verbose && ! $quiet; then + grep -i 'error:' "$log" | head -n5 + fi + return 1 + fi +} + +verify_test() { + log_output $COLUMNS + exitstatus=$? + if [ $exitstatus -eq 0 ]; then + if [ "$xfail" = "run" ]; then + $keep_failed || rm "$exe" + xpass "execution test" + else + rm "$exe" + pass "execution test" + fi + return 0 + else + $keep_failed || rm "$exe" + if ! $verbose && ! $quiet; then + grep -i fail "$log" | head -n5 + fi + if [ $exitstatus -eq 124 ]; then + fail "timeout: execution test" + elif [ "$xfail" = "run" ]; then + xfail "execution test" + else + fail "execution test" + fi + return 1 + fi +} + write_log_and_verbose "$CXX $src $@ -D_GLIBCXX_SIMD_TESTTYPE=$type $abiflag -o $exe" -timeout --foreground $timeout "$CXX" "$src" "$@" "-D_GLIBCXX_SIMD_TESTTYPE=$type" $abiflag -o "$exe" >> "$log" 2>&1 -verify_compilation $? +{ + timeout --foreground $timeout "$CXX" "$src" "$@" "-D_GLIBCXX_SIMD_TESTTYPE=$type" $abiflag -o "$exe" 2>&1 <&- + printf "###exitstatus### %d\n" $? +} | verify_compilation || exit 0 if [ -n "$sim" ]; then write_log_and_verbose "$sim ./$exe" - timeout --foreground $timeout $sim "./$exe" >> "$log" 2>&1 <&- else write_log_and_verbose "./$exe" timeout=$(awk "BEGIN { print int($timeout / 2) }") - timeout --foreground $timeout "./$exe" >> "$log" 2>&1 <&- fi -verify_test $? +{ + timeout --foreground $timeout $sim "./$exe" 2>&1 <&- + printf "###exitstatus### %d\n" $? +} | verify_test || exit 0 # vim: sw=2 et cc=81 si