[LTP] [PATCH v5 2/3] Add LVM support scripts

Martin Doucha mdoucha@suse.cz
Tue Apr 14 15:02:36 CEST 2020


On 14. 04. 20 14:29, Cyril Hrubis wrote:
> Hi!
>> diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
> 
> Hmm, where exactly is this called?
> 
> How is the template used?

generate_lvm_runfile.sh will be called near the end of install_ltp to
generate system-specific runfile for LVM tests using the template.
prepare_lvm.sh will be called in a separate OpenQA module right after
boot_ltp. None of these helper scripts should be included in any runfile.

>> diff --git a/testcases/misc/lvm/prepare_lvm.sh b/testcases/misc/lvm/prepare_lvm.sh
>> new file mode 100755
>> index 000000000..a9acd50e0
>> --- /dev/null
>> +++ b/testcases/misc/lvm/prepare_lvm.sh
>> @@ -0,0 +1,83 @@
>> +#!/bin/sh
>> +# SPDX-License-Identifier: GPL-2.0-or-later
>> +# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
>> +#
>> +# Create and mount LVM volume groups for lvm.local runfile
>> +
>> +TST_TESTFUNC=prepare_lvm
>> +TST_NEEDS_ROOT=1
>> +TST_NEEDS_CMDS="mount pvcreate vgcreate lvcreate"
>> +. tst_test.sh
>> +
>> +LVM_TMPDIR="/tmp/ltp/growfiles"
>> +LVM_IMGDIR="/tmp/ltp/imgfiles"
> 
> This should be based on $TMPDIR

That will cause weird errors when somebody changes $TMPDIR between
install_ltp and the actual LVM jobs, e.g. via LTP_ENV. LVM_TMPDIR has to
be hardcoded in the autogenerated runfile either way.

>> +prepare_mounts()
>> +{
>> +	FSNAME1=$1
>> +	FSNAME2=$2
>> +	shift 2
>> +	LVM_DEV1=`tst_device acquire 1040 "$LVM_IMGDIR/lvm_pv1.img"`
>> +	error_check
>> +	LVM_DEV2=`ROD tst_device acquire 1040 "$LVM_IMGDIR/lvm_pv2.img"`
>> +	error_check
> 
> This calls ROD but yet you do error_check, why?
> 
> Also ROD generates better error messages, why do we have to reinvent it
> badly?

This is a typo, ROD doesn't work in backticks because the command gets
executed in a subshell. If tst_device fails here, LVM_DEV2 will be set
to the error message and prepare_mounts() will happily continue as if
nothing happened (until the error_check, that is). I've fixed most
places where I originally used ROD but missed this one.

I'll fix the other issues and resubmit.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


More information about the ltp mailing list