[newlib-cygwin/main] Cygwin: CI: Make stress test terser

Jon Turney via Cygwin-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=aa514fa55ea743fbe79d5da12cd076c00926503b

commit aa514fa55ea743fbe79d5da12cd076c00926503b
Author: Jon Turney <[email protected]>
Date:   Thu Apr 10 21:44:30 2025 +0100

    Cygwin: CI: Make stress test terser
    
    v2:
    Only echo the command in dryrun mode
    Capture stress-ng stderr and stdout to a file
    Normally only show the test output if it fails
    Capture all test output in an artifact

Diff:
---
 .github/workflows/cygwin.yml      | 10 ++++++++++
 winsup/testsuite/stress/cygstress | 16 +++++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml
index f8960e225..fa00834ce 100644
--- a/.github/workflows/cygwin.yml
+++ b/.github/workflows/cygwin.yml
@@ -247,5 +247,15 @@ jobs:
       run: |
         export PATH=/usr/bin:$(cygpath ${SYSTEMROOT})/system32
         uname -a
+        export LOGDIR=$(cygpath -a logs)
         winsup/testsuite/stress/cygstress CI
       shell: bash --noprofile --norc -o igncr -eo pipefail '{0}'
+
+    # upload logs artifact
+    - name: Capture logs artifact
+      uses: actions/upload-artifact@v4
+      with:
+        name: stress-logs-${{ matrix.pkgarch }}
+        path: |
+          logs
+      if: ${{ !cancelled() }}
diff --git a/winsup/testsuite/stress/cygstress b/winsup/testsuite/stress/cygstress
index 21e4cb1a6..5a3b955cc 100755
--- a/winsup/testsuite/stress/cygstress
+++ b/winsup/testsuite/stress/cygstress
@@ -477,6 +477,9 @@ command -V taskkill >/dev/null || exit 1
 
 stress_ng_name=${stress_ng##*/}
 tempdir=${TMP:-/tmp}
+logdir=${LOGDIR:-/tmp/logdir}
+
+mkdir -p ${logdir}
 
 find_stress()
 {
@@ -501,12 +504,15 @@ stress()
   shift || return 1
 
   local td="$tempdir/stress-ng.$$.$total.d"
+  local logfile="$logdir/$name"
   local cmd=("$stress_ng" -v -M --oomable --timestamp --verify --temp-path "$td" -t "$timeout")
   test -z "$taskset" || cmd+=(--taskset "$taskset")
   cmd+=(--"$name" "$workers" "$@")
 
-  echo '$' "${cmd[@]}"
-  ! $dryrun || return 0
+  if $dryrun; then
+    echo '$' "${cmd[@]}"
+    return 0
+  fi
 
   (
     t=$(date +%s); : $((t += timeout + 30)); sleep 1
@@ -519,7 +525,7 @@ stress()
 
   mkdir "$td"
   local rc=0
-  "${cmd[@]}" || rc=$?
+  "${cmd[@]}" >$logfile 2>&1 || rc=$?
 
   kill $watchdog 2>/dev/null ||:
   trap - SIGINT SIGTERM
@@ -546,14 +552,14 @@ stress()
   fi
 
   if ! $ok; then
-    echo
     return 1
   fi
   if [ $rc != 0 ]; then
+    cat ${logfile}
     echo ">>> FAILURE: $name" "$@" "(exit status $rc)"; echo
     return 1
   fi
-  echo ">>> SUCCESS: $name" "$@" ""; echo
+  echo ">>> SUCCESS: $name" "$@" ""
 }
 
 if p=$(find_stress); then
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.