* [LTP] [PATCH 1/4] shell: Add tst_mount() helper
@ 2019-02-20 16:20 Petr Vorel
2019-02-20 16:20 ` [LTP] [PATCH 2/4] ima, commands/{df,mkfs}: Use tst_mount Petr Vorel
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Petr Vorel @ 2019-02-20 16:20 UTC (permalink / raw)
To: ltp
and TST_MOUNT, TST_MOUNT_PARAMS} variables.
+ document changes.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/test-writing-guidelines.txt | 12 ++++++++----
testcases/lib/tst_test.sh | 22 +++++++++++++++++++++-
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index f2f72c4d6..5aa7e0279 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -2006,12 +2006,16 @@ The 'tst_mkfs' helper will format device with the filesystem.
tst_mkfs ext2 $TST_DEVICE
-------------------------------------------------------------------------------
-Umounting filesystems
-+++++++++++++++++++++
+Mounting and unmounting filesystems
++++++++++++++++++++++++++++++++++++
+
+The 'tst_mount' and 'tst_umount' helpers are a safe way to mount/umount a filesystem.
-The 'tst_umount' helper is a safe way to umount a filesystem.
+The 'tst_mount' mounts '$TST_DEVICE' to '$TST_MOUNT', using optional '$TST_MOUNT_PARAMS'.
+It creates before mounting the '$TST_MOUNT' directory if not exists and fails
+if mounting was unsuccessful.
-If the path passed to the function is not mounted (present in '/proc/mounts')
+If the path passed to the 'tst_umount' is not mounted (present in '/proc/mounts')
it's noop.
Otherwise it retries to umount the filesystem a few times on a failure, which
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 3d2f5afde..4abea6665 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -235,6 +235,25 @@ TST_RTNL_CHK()
tst_brk TBROK "$@ failed: $output"
}
+tst_mount()
+{
+ if [ -z "$FS_TYPE" ]; then
+ tst_brk TBROK "Missing FS_TYPE variable"
+ fi
+
+ ROD_SILENT mkdir -p $TST_MOUNT
+ mount -t $FS_TYPE $TST_DEVICE $TST_MOUNT $TST_MOUNT_PARAMS
+ local ret=$?
+
+ if [ $ret -eq 32 ]; then
+ tst_brk TCONF "Cannot mount $FS_TYPE, missing driver?"
+ fi
+
+ if [ $ret -ne 0 ]; then
+ tst_brk TBROK "Failed to mount device: mount exit = $ret"
+ fi
+}
+
tst_umount()
{
local device="$1"
@@ -401,7 +420,7 @@ tst_run()
OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
NEEDS_ROOT|NEEDS_TMPDIR|TMPDIR|NEEDS_DEVICE|DEVICE);;
NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);;
- NEEDS_DRIVERS);;
+ NEEDS_DRIVERS|MOUNT|MOUNT_PARAMS);;
IPV6|IPVER|TEST_DATA|TEST_DATA_IFS);;
RETRY_FUNC|RETRY_FN_EXP_BACKOFF);;
*) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
@@ -461,6 +480,7 @@ tst_run()
cd "$TST_TMPDIR"
fi
+ TST_MOUNT="${TST_MOUNT:-mntpoint}"
if [ "$TST_NEEDS_DEVICE" = 1 ]; then
if [ -z ${TST_TMPDIR} ]; then
tst_brk TBROK "Use TST_NEEDS_TMPDIR must be set for TST_NEEDS_DEVICE"
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/4] ima, commands/{df,mkfs}: Use tst_mount
2019-02-20 16:20 [LTP] [PATCH 1/4] shell: Add tst_mount() helper Petr Vorel
@ 2019-02-20 16:20 ` Petr Vorel
2019-02-20 16:20 ` [LTP] [PATCH 3/4] shell: Move mkfs.foo into tst_mkfs() Petr Vorel
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2019-02-20 16:20 UTC (permalink / raw)
To: ltp
to reduce duplicity.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/commands/df/df01.sh | 18 +++---------------
testcases/commands/mkfs/mkfs01.sh | 15 +--------------
.../security/integrity/ima/tests/ima_setup.sh | 9 ++-------
3 files changed, 6 insertions(+), 36 deletions(-)
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index ecd66fbd6..4f77500b8 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -55,26 +55,14 @@ setup()
tst_test_cmds mkfs.${FS_TYPE}
fi
- tst_mkfs ${FS_TYPE} ${TST_DEVICE}
-
- ROD_SILENT mkdir -p mntpoint
-
- mount ${TST_DEVICE} mntpoint
- ret=$?
- if [ $ret -eq 32 ]; then
- tst_brk TCONF "Cannot mount ${FS_TYPE}, missing driver?"
- fi
-
- if [ $ret -ne 0 ]; then
- tst_brk TBROK "Failed to mount device: mount exit = $ret"
- fi
-
+ tst_mkfs $FS_TYPE $TST_DEVICE
+ tst_mount
DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk '{print $5}')
}
cleanup()
{
- tst_umount ${TST_DEVICE}
+ tst_umount $TST_DEVICE
}
df_test()
diff --git a/testcases/commands/mkfs/mkfs01.sh b/testcases/commands/mkfs/mkfs01.sh
index 68d40830a..25d185a05 100755
--- a/testcases/commands/mkfs/mkfs01.sh
+++ b/testcases/commands/mkfs/mkfs01.sh
@@ -54,19 +54,6 @@ setup()
ROD_SILENT mkdir -p mntpoint
}
-mkfs_mount()
-{
- mount ${TST_DEVICE} mntpoint
- local ret=$?
- if [ $ret -eq 32 ]; then
- tst_brk TCONF "Cannot mount ${FS_TYPE}, missing driver?"
- fi
-
- if [ $ret -ne 0 ]; then
- tst_brk TBROK "Failed to mount device: mount exit = $ret"
- fi
-}
-
mkfs_verify_type()
{
if [ -z "$1" ]; then
@@ -82,7 +69,7 @@ mkfs_verify_type()
mkfs_verify_size()
{
- mkfs_mount
+ tst_mount
local blocknum=`df -P -B 1k mntpoint | tail -n1 | awk '{print $2}'`
tst_umount "$TST_DEVICE"
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index fe6098135..e51d3d70b 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -55,13 +55,8 @@ mount_loop_device()
tst_test_cmds mkfs.$FS_TYPE
tst_mkfs $FS_TYPE $TST_DEVICE
- ROD_SILENT mkdir -p mntpoint
- mount ${TST_DEVICE} mntpoint
- ret=$?
- if [ $ret -ne 0 ]; then
- tst_brk TBROK "failed to mount device (mount exit = $ret)"
- fi
- cd mntpoint
+ tst_mount
+ cd $TST_MOUNT
}
print_ima_config()
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/4] shell: Move mkfs.foo into tst_mkfs()
2019-02-20 16:20 [LTP] [PATCH 1/4] shell: Add tst_mount() helper Petr Vorel
2019-02-20 16:20 ` [LTP] [PATCH 2/4] ima, commands/{df,mkfs}: Use tst_mount Petr Vorel
@ 2019-02-20 16:20 ` Petr Vorel
2019-03-13 14:01 ` Cyril Hrubis
2019-02-20 16:20 ` [LTP] [PATCH 4/4] shell: Use $FS_TYPE and $TST_DEVICE as default params in tst_mkfs() Petr Vorel
2019-03-13 13:58 ` [LTP] [PATCH 1/4] shell: Add tst_mount() helper Cyril Hrubis
3 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2019-02-20 16:20 UTC (permalink / raw)
To: ltp
+ remove unused local ret
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/commands/df/df01.sh | 6 ------
testcases/kernel/security/integrity/ima/tests/ima_setup.sh | 1 -
testcases/lib/tst_test.sh | 3 ++-
3 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index 4f77500b8..b93fb7ad7 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -49,12 +49,6 @@ parse_args()
setup()
{
- local ret
-
- if [ -n "$FS_TYPE" ]; then
- tst_test_cmds mkfs.${FS_TYPE}
- fi
-
tst_mkfs $FS_TYPE $TST_DEVICE
tst_mount
DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk '{print $5}')
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index e51d3d70b..e000390e4 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -53,7 +53,6 @@ mount_loop_device()
{
local ret
- tst_test_cmds mkfs.$FS_TYPE
tst_mkfs $FS_TYPE $TST_DEVICE
tst_mount
cd $TST_MOUNT
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 4abea6665..9ac45e04a 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -296,8 +296,9 @@ tst_mkfs()
tst_brk TBROK "No device specified"
fi
- tst_res TINFO "Formatting $device with $fs_type extra opts='$fs_opts'"
+ tst_test_cmds mkfs.$fs_type
+ tst_res TINFO "Formatting $device with $fs_type extra opts='$fs_opts'"
ROD_SILENT mkfs.$fs_type $fs_opts $device
}
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 4/4] shell: Use $FS_TYPE and $TST_DEVICE as default params in tst_mkfs()
2019-02-20 16:20 [LTP] [PATCH 1/4] shell: Add tst_mount() helper Petr Vorel
2019-02-20 16:20 ` [LTP] [PATCH 2/4] ima, commands/{df,mkfs}: Use tst_mount Petr Vorel
2019-02-20 16:20 ` [LTP] [PATCH 3/4] shell: Move mkfs.foo into tst_mkfs() Petr Vorel
@ 2019-02-20 16:20 ` Petr Vorel
2019-03-13 14:03 ` Cyril Hrubis
2019-03-13 13:58 ` [LTP] [PATCH 1/4] shell: Add tst_mount() helper Cyril Hrubis
3 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2019-02-20 16:20 UTC (permalink / raw)
To: ltp
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
doc/test-writing-guidelines.txt | 4 ++++
testcases/commands/df/df01.sh | 2 +-
testcases/kernel/security/integrity/ima/tests/ima_setup.sh | 2 +-
testcases/lib/tst_test.sh | 4 ++--
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 5aa7e0279..81fa3b0bc 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -2004,6 +2004,10 @@ The 'tst_mkfs' helper will format device with the filesystem.
-------------------------------------------------------------------------------
# format test device with ext2
tst_mkfs ext2 $TST_DEVICE
+# default params are $FS_TYPE $TST_DEVICE
+tst_mkfs
+# optional parameters
+tst_mkfs ext4 /dev/device -T largefile
-------------------------------------------------------------------------------
Mounting and unmounting filesystems
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index b93fb7ad7..426ba7560 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -49,7 +49,7 @@ parse_args()
setup()
{
- tst_mkfs $FS_TYPE $TST_DEVICE
+ tst_mkfs
tst_mount
DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk '{print $5}')
}
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index e000390e4..100813b4d 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -53,7 +53,7 @@ mount_loop_device()
{
local ret
- tst_mkfs $FS_TYPE $TST_DEVICE
+ tst_mkfs
tst_mount
cd $TST_MOUNT
}
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 9ac45e04a..055eecbd6 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -283,8 +283,8 @@ tst_umount()
tst_mkfs()
{
- local fs_type=$1
- local device=$2
+ local fs_type=${1:-$FS_TYPE}
+ local device=${2:-$TST_DEVICE}
shift 2
local fs_opts="$@"
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/4] shell: Add tst_mount() helper
2019-02-20 16:20 [LTP] [PATCH 1/4] shell: Add tst_mount() helper Petr Vorel
` (2 preceding siblings ...)
2019-02-20 16:20 ` [LTP] [PATCH 4/4] shell: Use $FS_TYPE and $TST_DEVICE as default params in tst_mkfs() Petr Vorel
@ 2019-03-13 13:58 ` Cyril Hrubis
3 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2019-03-13 13:58 UTC (permalink / raw)
To: ltp
Hi!
> and TST_MOUNT, TST_MOUNT_PARAMS} variables.
^
This should probably named TST_MNTPOINT and TST_MNT_PARAMS
Also we seem to use $FS_TYPE inside of the library which is not
documented anywhere in the change to the documentation, I see that it
will error out when users fails to set it but I do not like it at all.
Ideally we should either introduce TST_FS_TYPE or pass the fs type as an
agrument to the tst_mount function.
> + document changes.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> doc/test-writing-guidelines.txt | 12 ++++++++----
> testcases/lib/tst_test.sh | 22 +++++++++++++++++++++-
> 2 files changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
> index f2f72c4d6..5aa7e0279 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -2006,12 +2006,16 @@ The 'tst_mkfs' helper will format device with the filesystem.
> tst_mkfs ext2 $TST_DEVICE
> -------------------------------------------------------------------------------
>
> -Umounting filesystems
> -+++++++++++++++++++++
> +Mounting and unmounting filesystems
> ++++++++++++++++++++++++++++++++++++
> +
> +The 'tst_mount' and 'tst_umount' helpers are a safe way to mount/umount a filesystem.
>
> -The 'tst_umount' helper is a safe way to umount a filesystem.
> +The 'tst_mount' mounts '$TST_DEVICE' to '$TST_MOUNT', using optional '$TST_MOUNT_PARAMS'.
> +It creates before mounting the '$TST_MOUNT' directory if not exists and fails
> +if mounting was unsuccessful.
>
> -If the path passed to the function is not mounted (present in '/proc/mounts')
> +If the path passed to the 'tst_umount' is not mounted (present in '/proc/mounts')
> it's noop.
>
> Otherwise it retries to umount the filesystem a few times on a failure, which
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 3d2f5afde..4abea6665 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -235,6 +235,25 @@ TST_RTNL_CHK()
> tst_brk TBROK "$@ failed: $output"
> }
>
> +tst_mount()
> +{
> + if [ -z "$FS_TYPE" ]; then
> + tst_brk TBROK "Missing FS_TYPE variable"
> + fi
> +
> + ROD_SILENT mkdir -p $TST_MOUNT
> + mount -t $FS_TYPE $TST_DEVICE $TST_MOUNT $TST_MOUNT_PARAMS
> + local ret=$?
> +
> + if [ $ret -eq 32 ]; then
> + tst_brk TCONF "Cannot mount $FS_TYPE, missing driver?"
> + fi
> +
> + if [ $ret -ne 0 ]; then
> + tst_brk TBROK "Failed to mount device: mount exit = $ret"
> + fi
> +}
> +
> tst_umount()
> {
> local device="$1"
> @@ -401,7 +420,7 @@ tst_run()
> OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
> NEEDS_ROOT|NEEDS_TMPDIR|TMPDIR|NEEDS_DEVICE|DEVICE);;
> NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);;
> - NEEDS_DRIVERS);;
> + NEEDS_DRIVERS|MOUNT|MOUNT_PARAMS);;
> IPV6|IPVER|TEST_DATA|TEST_DATA_IFS);;
> RETRY_FUNC|RETRY_FN_EXP_BACKOFF);;
> *) tst_res TWARN "Reserved variable TST_$_tst_i used!";;
> @@ -461,6 +480,7 @@ tst_run()
> cd "$TST_TMPDIR"
> fi
>
> + TST_MOUNT="${TST_MOUNT:-mntpoint}"
> if [ "$TST_NEEDS_DEVICE" = 1 ]; then
> if [ -z ${TST_TMPDIR} ]; then
> tst_brk TBROK "Use TST_NEEDS_TMPDIR must be set for TST_NEEDS_DEVICE"
> --
> 2.20.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/4] shell: Move mkfs.foo into tst_mkfs()
2019-02-20 16:20 ` [LTP] [PATCH 3/4] shell: Move mkfs.foo into tst_mkfs() Petr Vorel
@ 2019-03-13 14:01 ` Cyril Hrubis
0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2019-03-13 14:01 UTC (permalink / raw)
To: ltp
Hi!
This is obviously OK, acked.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 4/4] shell: Use $FS_TYPE and $TST_DEVICE as default params in tst_mkfs()
2019-02-20 16:20 ` [LTP] [PATCH 4/4] shell: Use $FS_TYPE and $TST_DEVICE as default params in tst_mkfs() Petr Vorel
@ 2019-03-13 14:03 ` Cyril Hrubis
2019-03-13 15:19 ` Petr Vorel
0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2019-03-13 14:03 UTC (permalink / raw)
To: ltp
Hi!
This one is OK apart from the names for the variables, i.e. FS_TYPE
should get TST_ prefix and TST_MOUNT should became TST_MNTPOINT.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 4/4] shell: Use $FS_TYPE and $TST_DEVICE as default params in tst_mkfs()
2019-03-13 14:03 ` Cyril Hrubis
@ 2019-03-13 15:19 ` Petr Vorel
0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2019-03-13 15:19 UTC (permalink / raw)
To: ltp
Hi Cyril,
> Hi!
> This one is OK apart from the names for the variables, i.e. FS_TYPE
> should get TST_ prefix and TST_MOUNT should became TST_MNTPOINT.
Thanks for the review. Good points, do that + document TST_FS_TYPE.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-03-13 15:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20 16:20 [LTP] [PATCH 1/4] shell: Add tst_mount() helper Petr Vorel
2019-02-20 16:20 ` [LTP] [PATCH 2/4] ima, commands/{df,mkfs}: Use tst_mount Petr Vorel
2019-02-20 16:20 ` [LTP] [PATCH 3/4] shell: Move mkfs.foo into tst_mkfs() Petr Vorel
2019-03-13 14:01 ` Cyril Hrubis
2019-02-20 16:20 ` [LTP] [PATCH 4/4] shell: Use $FS_TYPE and $TST_DEVICE as default params in tst_mkfs() Petr Vorel
2019-03-13 14:03 ` Cyril Hrubis
2019-03-13 15:19 ` Petr Vorel
2019-03-13 13:58 ` [LTP] [PATCH 1/4] shell: Add tst_mount() helper Cyril Hrubis
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.