From: David Disseldorp <ddiss@suse.de>
To: fstests@vger.kernel.org
Cc: David Disseldorp <ddiss@suse.de>
Subject: [PATCH 5/6] check: use arrays instead of separate n_ counters
Date: Mon, 20 Jun 2022 21:29:33 +0200 [thread overview]
Message-ID: <20220620192934.21694-6-ddiss@suse.de> (raw)
In-Reply-To: <20220620192934.21694-1-ddiss@suse.de>
The separate n_try, n_bad and n_notrun counters are unnecessary when
the corresponding lists are switched to bash arrays.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
check | 72 ++++++++++++++++++++++++++---------------------------------
1 file changed, 32 insertions(+), 40 deletions(-)
diff --git a/check b/check
index a5183d3a..8423d7a1 100755
--- a/check
+++ b/check
@@ -8,13 +8,10 @@ tmp=/tmp/$$
status=0
needwrap=true
needsum=true
-n_try=0
-try=""
-n_bad=0
+try=()
sum_bad=0
-bad=""
-n_notrun=0
-notrun=""
+bad=()
+notrun=()
interrupt=true
diff="diff -u"
showme=false
@@ -412,10 +409,9 @@ fi
_wipe_counters()
{
- n_try="0"
- n_bad="0"
- n_notrun="0"
- unset try notrun bad
+ try=()
+ notrun=()
+ bad=()
}
_global_log() {
@@ -433,7 +429,7 @@ _wrapup()
if $showme && $needwrap; then
if $do_report; then
# $showme = all selected tests are notrun (no tries)
- _make_section_report "$n_notrun" "0" "$n_notrun"
+ _make_section_report "${#notrun[*]}" "0" "${#notrun[*]}"
fi
needwrap=false
elif $needwrap; then
@@ -458,12 +454,12 @@ _wrapup()
echo "SECTION -- $section" >>$tmp.summary
echo "=========================" >>$tmp.summary
- if [ ! -z "$n_try" -a $n_try != 0 ]; then
+ if ((${#try[*]} > 0)); then
if [ $brief_test_summary == "false" ]; then
- echo "Ran:$try"
- echo "Ran:$try" >>$tmp.summary
+ echo "Ran: ${try[*]}"
+ echo "Ran: ${try[*]}" >>$tmp.summary
fi
- _global_log "Ran:$try"
+ _global_log "Ran: ${try[*]}"
fi
$interrupt && echo "Interrupted!" | tee -a $check.log
@@ -472,34 +468,34 @@ _wrapup()
${REPORT_DIR}/check.log
fi
- if [ ! -z "$notrun" ]; then
+ if ((${#notrun[*]} > 0)); then
if [ $brief_test_summary == "false" ]; then
- echo "Not run:$notrun"
- echo "Not run:$notrun" >>$tmp.summary
+ echo "Not run: ${notrun[*]}"
+ echo "Not run: ${notrun[*]}" >>$tmp.summary
fi
- _global_log "Not run:$notrun"
+ _global_log "Not run: ${notrun[*]}"
fi
- if [ ! -z "$n_bad" -a $n_bad != 0 ]; then
- echo "Failures:$bad"
- echo "Failed $n_bad of $n_try tests"
- _global_log "Failures:$bad"
- _global_log "Failed $n_bad of $n_try tests"
- echo "Failures:$bad" >>$tmp.summary
- echo "Failed $n_bad of $n_try tests" >>$tmp.summary
+ if ((${#bad[*]} > 0)); then
+ echo "Failures: ${bad[*]}"
+ echo "Failed ${#bad[*]} of ${#try[*]} tests"
+ _global_log "Failures: ${bad[*]}"
+ _global_log "Failed ${#bad[*]} of ${#try[*]} tests"
+ echo "Failures: ${bad[*]}" >>$tmp.summary
+ echo "Failed ${#bad[*]} of ${#try[*]} tests" >>$tmp.summary
else
- echo "Passed all $n_try tests"
- _global_log "Passed all $n_try tests"
- echo "Passed all $n_try tests" >>$tmp.summary
+ echo "Passed all ${#try[*]} tests"
+ _global_log "Passed all ${#try[*]} tests"
+ echo "Passed all ${#try[*]} tests" >>$tmp.summary
fi
echo "" >>$tmp.summary
if $do_report; then
- _make_section_report "$n_try" "$n_bad" "$n_notrun"
+ _make_section_report "${#try[*]}" "${#bad[*]}" "${#notrun[*]}"
fi
needwrap=false
fi
- sum_bad=`expr $sum_bad + $n_bad`
+ sum_bad=`expr $sum_bad + ${#bad[*]}`
_wipe_counters
rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
if ! $OPTIONS_HAVE_SECTIONS; then
@@ -735,8 +731,7 @@ function run_section()
for seq in $list ; do
# Run report for previous test!
if $err ; then
- bad="$bad $seqnum"
- n_bad=`expr $n_bad + 1`
+ bad+=("$seqnum")
tc_status="fail"
fi
if $do_report && ! $first_test ; then
@@ -794,7 +789,7 @@ function run_section()
start=0
stop=0
tc_status="list"
- n_notrun=`expr $n_notrun + 1`
+ notrun+=("$seqnum")
continue
fi
@@ -815,8 +810,7 @@ function run_section()
fi
# record that we really tried to run this test.
- try="$try $seqnum"
- n_try=`expr $n_try + 1`
+ try+=("$seqnum")
awk 'BEGIN {lasttime=" "} \
$1 == "'$seqnum'" {lasttime=" " $2 "s ... "; exit} \
@@ -861,8 +855,7 @@ function run_section()
$timestamp && echo " [not run]" && \
echo -n " $seqnum -- "
cat $seqres.notrun
- notrun="$notrun $seqnum"
- n_notrun=`expr $n_notrun + 1`
+ notrun+=("$seqnum")
tc_status="notrun"
# Unmount the scratch fs so that we can wipe the scratch
@@ -947,8 +940,7 @@ function run_section()
# make sure we record the status of the last test we ran.
if $err ; then
- bad="$bad $seqnum"
- n_bad=`expr $n_bad + 1`
+ bad+=("$seqnum")
tc_status="fail"
fi
if $do_report && ! $first_test ; then
--
2.35.3
next prev parent reply other threads:[~2022-06-20 19:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 19:29 [PATCH 0/6] check: minor cleanups and xunit report fix David Disseldorp
2022-06-20 19:29 ` [PATCH 1/6] check: avoid FSTYP=<fstyp parameter> repetition David Disseldorp
2022-06-22 4:27 ` Zorro Lang
2022-06-20 19:29 ` [PATCH 2/6] check: simplify check.time parsing David Disseldorp
2022-06-22 4:31 ` Zorro Lang
2022-06-20 19:29 ` [PATCH 3/6] report: drop unused _xunit_make_section_report parameter David Disseldorp
2022-06-22 4:37 ` Zorro Lang
2022-06-20 19:29 ` [PATCH 4/6] report: fix xunit tests count David Disseldorp
2022-06-22 5:03 ` Zorro Lang
2022-06-20 19:29 ` David Disseldorp [this message]
2022-06-22 5:11 ` [PATCH 5/6] check: use arrays instead of separate n_ counters Zorro Lang
2022-06-20 19:29 ` [PATCH 6/6] check: remove err and first_test variables David Disseldorp
2022-06-22 5:15 ` Zorro Lang
2022-06-22 5:21 ` [PATCH 0/6] check: minor cleanups and xunit report fix Zorro Lang
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=20220620192934.21694-6-ddiss@suse.de \
--to=ddiss@suse.de \
--cc=fstests@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.