From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it, linux-nfs@vger.kernel.org
Subject: Re: [LTP] [PATCH v2 5/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS
Date: Fri, 17 Jun 2022 15:52:52 +0200 [thread overview]
Message-ID: <YqyHNFkJdC0q2Vxs@yuki> (raw)
In-Reply-To: <20220609214223.4608-6-pvorel@suse.cz>
Hi!
> +_tst_run_iterations()
> +{
> + local _tst_i=$TST_ITERATIONS
>
> - if [ "$TST_MOUNT_DEVICE" = 1 ]; then
> - tst_mount
> - TST_MOUNT_FLAG=1
> - fi
> + [ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR"
>
> - [ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
> + _tst_setup_timer
>
> if [ -n "$TST_SETUP" ]; then
> if command -v $TST_SETUP >/dev/null 2>/dev/null; then
> @@ -724,7 +741,7 @@ tst_run()
> fi
>
> #TODO check that test reports some results for each test function call
> - while [ $TST_ITERATIONS -gt 0 ]; do
> + while [ $_tst_i -gt 0 ]; do
> if [ -n "$TST_TEST_DATA" ]; then
> tst_require_cmds cut tr wc
> _tst_max=$(( $(echo $TST_TEST_DATA | tr -cd "$TST_TEST_DATA_IFS" | wc -c) +1))
> @@ -735,9 +752,22 @@ tst_run()
> else
> _tst_run_tests
> fi
> - TST_ITERATIONS=$((TST_ITERATIONS-1))
> + _tst_i=$((_tst_i-1))
> done
> - _tst_do_exit
> +
> + if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
> + if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then
> + $TST_CLEANUP
> + else
> + tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
> + fi
> + fi
> +
> + if [ "$TST_MOUNT_FLAG" = 1 ]; then
> + tst_umount
> + fi
> +
> + _tst_cleanup_timer
Generally the code looks good, there is still a minor difference between
C API and this changes though. As we do call the _tst_cleanup_timer at
the end of this function the script runs without a timeout for a short
while (which includes tst_mkfs call).
I guess that instead of stopping the timer at the end of the
_tst_run_iterations() we can simply reset it (on the top of this patch):
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index d96ce3448..f5af4c214 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -50,6 +50,8 @@ _tst_do_exit()
rm $LTP_IPC_PATH
fi
+ _tst_cleanup_timer
+
if [ $TST_FAIL -gt 0 ]; then
ret=$((ret|1))
fi
@@ -552,6 +554,12 @@ _tst_setup_timer()
done
}
+_tst_reset_timer()
+{
+ _tst_cleanup_timer
+ _tst_setup_timer
+}
+
tst_require_root()
{
if [ "$(id -ru)" != 0 ]; then
@@ -665,6 +673,8 @@ tst_run()
tst_brk TBROK "Number of iterations (-i) must be >= 0"
fi
+ _tst_setup_timer
+
[ "$TST_NEEDS_ROOT" = 1 ] && tst_require_root
[ "$TST_DISABLE_APPARMOR" = 1 ] && tst_disable_apparmor
@@ -729,8 +739,6 @@ _tst_run_iterations()
[ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR"
- _tst_setup_timer
-
if [ -n "$TST_SETUP" ]; then
if command -v $TST_SETUP >/dev/null 2>/dev/null; then
TST_DO_CLEANUP=1
@@ -767,7 +775,7 @@ _tst_run_iterations()
tst_umount
fi
- _tst_cleanup_timer
+ _tst_reset_timer
}
--
Cyril Hrubis
chrubis@suse.cz
WARNING: multiple messages have this Message-ID (diff)
From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: linux-nfs@vger.kernel.org, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 5/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS
Date: Fri, 17 Jun 2022 15:52:52 +0200 [thread overview]
Message-ID: <YqyHNFkJdC0q2Vxs@yuki> (raw)
In-Reply-To: <20220609214223.4608-6-pvorel@suse.cz>
Hi!
> +_tst_run_iterations()
> +{
> + local _tst_i=$TST_ITERATIONS
>
> - if [ "$TST_MOUNT_DEVICE" = 1 ]; then
> - tst_mount
> - TST_MOUNT_FLAG=1
> - fi
> + [ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR"
>
> - [ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
> + _tst_setup_timer
>
> if [ -n "$TST_SETUP" ]; then
> if command -v $TST_SETUP >/dev/null 2>/dev/null; then
> @@ -724,7 +741,7 @@ tst_run()
> fi
>
> #TODO check that test reports some results for each test function call
> - while [ $TST_ITERATIONS -gt 0 ]; do
> + while [ $_tst_i -gt 0 ]; do
> if [ -n "$TST_TEST_DATA" ]; then
> tst_require_cmds cut tr wc
> _tst_max=$(( $(echo $TST_TEST_DATA | tr -cd "$TST_TEST_DATA_IFS" | wc -c) +1))
> @@ -735,9 +752,22 @@ tst_run()
> else
> _tst_run_tests
> fi
> - TST_ITERATIONS=$((TST_ITERATIONS-1))
> + _tst_i=$((_tst_i-1))
> done
> - _tst_do_exit
> +
> + if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
> + if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then
> + $TST_CLEANUP
> + else
> + tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)"
> + fi
> + fi
> +
> + if [ "$TST_MOUNT_FLAG" = 1 ]; then
> + tst_umount
> + fi
> +
> + _tst_cleanup_timer
Generally the code looks good, there is still a minor difference between
C API and this changes though. As we do call the _tst_cleanup_timer at
the end of this function the script runs without a timeout for a short
while (which includes tst_mkfs call).
I guess that instead of stopping the timer at the end of the
_tst_run_iterations() we can simply reset it (on the top of this patch):
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index d96ce3448..f5af4c214 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -50,6 +50,8 @@ _tst_do_exit()
rm $LTP_IPC_PATH
fi
+ _tst_cleanup_timer
+
if [ $TST_FAIL -gt 0 ]; then
ret=$((ret|1))
fi
@@ -552,6 +554,12 @@ _tst_setup_timer()
done
}
+_tst_reset_timer()
+{
+ _tst_cleanup_timer
+ _tst_setup_timer
+}
+
tst_require_root()
{
if [ "$(id -ru)" != 0 ]; then
@@ -665,6 +673,8 @@ tst_run()
tst_brk TBROK "Number of iterations (-i) must be >= 0"
fi
+ _tst_setup_timer
+
[ "$TST_NEEDS_ROOT" = 1 ] && tst_require_root
[ "$TST_DISABLE_APPARMOR" = 1 ] && tst_disable_apparmor
@@ -729,8 +739,6 @@ _tst_run_iterations()
[ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR"
- _tst_setup_timer
-
if [ -n "$TST_SETUP" ]; then
if command -v $TST_SETUP >/dev/null 2>/dev/null; then
TST_DO_CLEANUP=1
@@ -767,7 +775,7 @@ _tst_run_iterations()
tst_umount
fi
- _tst_cleanup_timer
+ _tst_reset_timer
}
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2022-06-17 13:51 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 21:42 [PATCH 0/9] shell: nfs: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-09 21:42 ` [PATCH v2 1/9] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-09 21:42 ` [PATCH v2 2/9] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-09 21:42 ` [PATCH v2 3/9] tst_test.sh: allow ' in pattern for allowed variables Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-17 11:59 ` Cyril Hrubis
2022-06-17 11:59 ` Cyril Hrubis
2022-06-09 21:42 ` [PATCH v2 4/9] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-07-11 15:02 ` Petr Vorel
2022-07-11 15:02 ` [LTP] " Petr Vorel
2022-06-09 21:42 ` [PATCH v2 5/9] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-17 13:52 ` Cyril Hrubis [this message]
2022-06-17 13:52 ` Cyril Hrubis
2022-06-17 14:07 ` Petr Vorel
2022-06-17 14:07 ` Petr Vorel
2022-08-04 7:07 ` Petr Vorel
2022-08-04 7:07 ` [LTP] " Petr Vorel
2022-06-09 21:42 ` [PATCH v2 6/9] tst_device: Remove unnecessary braces Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-17 13:57 ` Cyril Hrubis
2022-06-17 13:57 ` Cyril Hrubis
2022-06-09 21:42 ` [PATCH v2 7/9] tst_device: Add clear command Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-17 14:02 ` Cyril Hrubis
2022-06-17 14:02 ` Cyril Hrubis
2022-06-09 21:42 ` [PATCH v2 8/9] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-16 5:59 ` Li Wang
2022-06-09 21:42 ` [RFC][PATCH v2 9/9] nfs: Use TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-06-09 21:42 ` [LTP] " Petr Vorel
2022-06-16 6:11 ` Li Wang
2022-06-16 6:51 ` Petr Vorel
2022-06-16 6:51 ` Petr Vorel
2022-06-17 14:51 ` Cyril Hrubis
2022-06-17 14:51 ` Cyril Hrubis
2022-07-11 15:08 ` Petr Vorel
2022-07-11 15:08 ` Petr Vorel
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=YqyHNFkJdC0q2Vxs@yuki \
--to=chrubis@suse.cz \
--cc=linux-nfs@vger.kernel.org \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/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.