public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc-patches@gcc.gnu.org>, <libstdc++@gcc.gnu.org>
Subject: [PATCH 08/16] Immediate feedback with -v
Date: Wed, 27 Jan 2021 21:42:23 +0100	[thread overview]
Message-ID: <37658268.xCRyjBS7g1@excalibur> (raw)
In-Reply-To: <4667217.5jz8CO7rxU@excalibur>

[-- Attachment #1: Type: text/plain, Size: 1232 bytes --]

From: Matthias Kretz <kretz@kde.org>

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.
---
 .../testsuite/experimental/simd/driver.sh     | 194 +++++++++++-------
 1 file changed, 116 insertions(+), 78 deletions(-)


--
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 std::experimental::simd              https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────

[-- Attachment #2: 0008-Immediate-feedback-with-v.patch --]
[-- Type: text/x-patch, Size: 5566 bytes --]

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

  parent reply	other threads:[~2021-01-27 20:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 20:36 [PATCH 00/16] stdx::simd fixes and testsuite improvements Matthias Kretz
2021-01-27 20:41 ` [PATCH 02/16] Fix NEON intrinsic types usage Matthias Kretz
2021-01-27 20:42 ` [PATCH 03/16] Support -mlong-double-64 on PPC Matthias Kretz
2021-01-27 20:42 ` [PATCH 04/16] Fix simd_mask<double> on POWER w/o POWER8 Matthias Kretz
2021-01-27 20:42 ` [PATCH 05/16] Fix several check-simd interaction issues Matthias Kretz
2021-01-27 20:42 ` [PATCH 06/16] Fix DRIVEROPTS and TESTFLAGS processing Matthias Kretz
2021-01-27 20:42 ` [PATCH 07/16] Fix incorrect display of old test summaries Matthias Kretz
2021-01-27 20:42 ` Matthias Kretz [this message]
2021-01-27 20:42 ` [PATCH 09/16] Fix mask reduction of simd_mask<double> on POWER7 Matthias Kretz
2021-01-27 20:42 ` [PATCH 10/16] Skip testing hypot3 for long double on PPC Matthias Kretz
2021-01-27 20:42 ` [PATCH 11/16] Abort test after 1000 lines of output Matthias Kretz
2021-01-27 20:42 ` [PATCH 12/16] Support timeout and timeout-factor options Matthias Kretz
2021-01-27 20:42 ` [PATCH 13/16] Improve test codegen for interpreting assembly Matthias Kretz
2021-02-02 15:02   ` Jonathan Wakely
2021-01-27 20:42 ` [PATCH 14/16] Implement hmin and hmax Matthias Kretz
2021-02-01 10:23   ` Matthias Kretz
2021-01-27 20:42 ` [PATCH 15/16] Work around test failures using -mno-tree-vrp Matthias Kretz
2021-01-27 20:42 ` [PATCH 16/16] Improve "find_first/last_set" for NEON Matthias Kretz
2021-02-03 15:52 ` [PATCH 00/16] stdx::simd fixes and testsuite improvements Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37658268.xCRyjBS7g1@excalibur \
    --to=m.kretz@gsi.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).