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
---
 .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 7d9147977..932926579 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
-- 
2.45.1

Reply via email to