All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: Martin Doucha <martin.doucha@suse.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS
Date: Tue, 31 May 2022 14:25:07 +0200	[thread overview]
Message-ID: <YpYJI7khXNJOjU4/@yuki> (raw)
In-Reply-To: <20220512194557.30911-7-pvorel@suse.cz>

Hi!
> +_prepare_device()
> +{
> +	if [ "$TST_FORMAT_DEVICE" = 1 ]; then
> +		tst_clear_device $TST_DEVICE
> +		tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS
> +	fi
> +
> +	if [ "$TST_MOUNT_DEVICE" = 1 ]; then
> +		tst_mount
> +		TST_MOUNT_FLAG=1
> +	fi
> +}
> +
> +_tst_run_tcases_per_fs()
> +{
> +	for _tst_fs in $(tst_supported_fs); do
> +		tst_res TINFO "Testing on $_tst_fs"
> +		TST_FS_TYPE="$_tst_fs"
> +		_prepare_device
> +		_tst_run_iterations
> +	done
> +}
> +
>  tst_run()
>  {
>  	local _tst_i
>  	local _tst_data
> +	local _tst_fs
>  	local _tst_max
>  	local _tst_name
>  
>  	if [ -n "$TST_TEST_PATH" ]; then
>  		for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`'"'"'].*//'); do
>  			case "$_tst_i" in
> -			DISABLE_APPARMOR|DISABLE_SELINUX);;
> +			ALL_FILESYSTEMS|DISABLE_APPARMOR|DISABLE_SELINUX);;
>  			SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
>  			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
>  			NEEDS_ROOT|NEEDS_TMPDIR|TMPDIR|NEEDS_DEVICE|DEVICE);;
> @@ -668,12 +679,23 @@ tst_run()
>  			tst_brk TCONF "test requires kernel $TST_MIN_KVER+"
>  	fi
>  
> -	_tst_setup_timer
> +	[ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE"
>  
> +	[ "$TST_ALL_FILESYSTEMS" = 1 ] && TST_MOUNT_DEVICE=1
>  	[ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
>  	[ "$TST_FORMAT_DEVICE" = 1 ] && TST_NEEDS_DEVICE=1
>  	[ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1
>  
> +	if [ "$TST_NEEDS_DEVICE" = 1 -a -z "$TST_MOUNT_FLAG" ]; then

I do not get the TST_MOUNT_FLAG, what do we need it for? The tst_run()
should be called exactly once in the test and at this point the
TST_MOUNT_FLAG cannot be set.

> +		TST_DEVICE=$(tst_device acquire)
> +
> +		if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then
> +			unset TST_DEVICE
> +			tst_brk TBROK "Failed to acquire device"
> +		fi
> +		TST_DEVICE_FLAG=1
> +	fi
>
>  	if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
>  		if [ -z "$TMPDIR" ]; then
>  			export TMPDIR="/tmp"
> @@ -684,35 +706,30 @@ tst_run()
>  		chmod 777 "$TST_TMPDIR"
>  
>  		TST_STARTWD=$(pwd)
> -
>  		cd "$TST_TMPDIR"
>  	fi
>  
> -	TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}"
> -	if [ "$TST_NEEDS_DEVICE" = 1 ]; then
> -
> -		TST_DEVICE=$(tst_device acquire)
> +	[ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
>  
> -		if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then
> -			unset TST_DEVICE
> -			tst_brk TBROK "Failed to acquire device"
> -		fi
> +	TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}"
> +	[ -z "$TST_ALL_FILESYSTEMS" ] && _prepare_device
>  
> -		TST_DEVICE_FLAG=1
> +	if [ -n "$TST_ALL_FILESYSTEMS" ]; then
> +		_tst_run_tcases_per_fs
> +	else
> +		_tst_run_iterations
>  	fi
>  
> -	[ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE"
> +	_tst_do_exit
> +}
>  
> -	if [ "$TST_FORMAT_DEVICE" = 1 ]; then
> -		tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS
> -	fi
> +_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_DEVICE" = 1 -a "$TST_MOUNT_FLAG" = 1 ]; then
> +		tst_umount
> +	fi
> +
> +	_tst_cleanup_timer
>  }
>  
>  _tst_run_tests()
> -- 
> 2.36.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-05-31 12:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 19:45 [LTP] [PATCH 0/8] shell: $TST_ALL_FILESYSTEMS (.all_filesystems) Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 1/8] tst_test.sh: Add $TST_MOUNT_DEVICE Petr Vorel
2022-05-30 14:04   ` Cyril Hrubis
2022-06-01  6:38     ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 2/8] df01.sh: Use TST_MOUNT_DEVICE=1 Petr Vorel
2022-05-30 14:13   ` Cyril Hrubis
2022-05-12 19:45 ` [LTP] [PATCH 3/8] tst_test.sh: Improve pattern for allowed variables Petr Vorel
2022-05-30 14:21   ` Cyril Hrubis
2022-06-03 12:24     ` Petr Vorel
2022-06-03 13:23       ` Cyril Hrubis
2022-06-03 18:44         ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 4/8] shell: Add test for TST_MOUNT_DEVICE=1 Petr Vorel
2022-05-30 15:05   ` Cyril Hrubis
2022-05-12 19:45 ` [LTP] [PATCH 5/8] shell: Add tst_clear_device Petr Vorel
2022-05-30 15:12   ` Cyril Hrubis
2022-06-01 10:34     ` Petr Vorel
2022-06-01 11:22       ` Cyril Hrubis
2022-06-01 13:17         ` Petr Vorel
2022-06-01 10:37   ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 6/8] tst_test.sh: Add $TST_ALL_FILESYSTEMS Petr Vorel
2022-05-31 12:25   ` Cyril Hrubis [this message]
2022-06-01  8:41     ` Petr Vorel
2022-05-12 19:45 ` [LTP] [PATCH 7/8] shell: Add test for TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-05-13  8:17   ` Petr Vorel
2022-05-31 12:43   ` Cyril Hrubis
2022-05-12 19:45 ` [LTP] [PATCH 8/8] nfs07.sh: Use TST_ALL_FILESYSTEMS=1 Petr Vorel
2022-05-13  9: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=YpYJI7khXNJOjU4/@yuki \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=martin.doucha@suse.com \
    --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.