tests: add lsblk test script
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
bd45b74fc9
commit
314adce668
|
@ -0,0 +1,19 @@
|
|||
|
||||
Howto add new lsblk test:
|
||||
|
||||
* run mk-input.sh <testname>
|
||||
|
||||
* copy testname.tar.xz file to tests/ts/lsblk/dumps
|
||||
|
||||
* copy lsblk-* files from the tarball to tests/expected/lsblk/
|
||||
|
||||
* run ./tests/run.sh lsblk
|
||||
|
||||
* git add tests/ts/lsblk/testname.tar.xz
|
||||
git add tests/expected/lsblk/lsblk-testname*
|
||||
|
||||
|
||||
Note that we do not use directly lsblk-* from the tarball. It's better to keep
|
||||
copy of the files in the tests/expected/lsblk/, because output formatting may
|
||||
be different in the current version. The version in the tarball is just initial
|
||||
hint only.
|
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2018 Karel Zak <kzak@redhat.com>
|
||||
#
|
||||
# This file is part of util-linux.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This file is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
TS_TOPDIR="${0%/*}/../.."
|
||||
. $TS_TOPDIR/functions.sh
|
||||
|
||||
ts_init "$*"
|
||||
|
||||
ts_check_test_command "$TS_CMD_LSBLK"
|
||||
ts_check_prog xz
|
||||
ts_check_prog tar
|
||||
|
||||
for dump in $(ls $TS_SELF/dumps/*.tar.xz | sort); do
|
||||
name=$(basename $dump .tar.xz)
|
||||
dumpdir="$TS_OUTDIR/dumps"
|
||||
|
||||
mkdir -p $dumpdir
|
||||
tar -C $dumpdir --xz -xf $dump
|
||||
|
||||
#
|
||||
# Read *.cols from the tarball, but the expected output is not used
|
||||
# from the tarball due to changes in lsblk fomatting etc. We keep up to
|
||||
# date version in tests/expected/lsblk.
|
||||
#
|
||||
for cols_file in $(ls $dumpdir/$name/*.cols | sort); do
|
||||
subname=$(basename $cols_file .cols)
|
||||
subtestname="${name}-${subname}"
|
||||
|
||||
ts_init_subtest $subtestname
|
||||
cols=$(cat $cols_file)
|
||||
${TS_CMD_LSBLK} --sysroot "${dumpdir}/${name}" \
|
||||
--output $cols \
|
||||
>"${TS_OUTPUT}" 2>&1
|
||||
|
||||
ts_finalize_subtest
|
||||
done
|
||||
done
|
||||
|
||||
ts_finalize
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 2018 Karel Zak <kzak@redhat.com>
|
||||
#
|
||||
# This script makes a copy of relevant files from /sys and /proc.
|
||||
# The files are useful for lscpu(1) regression tests.
|
||||
# The files are useful for lsblk(1) regression tests.
|
||||
#
|
||||
progname=$(basename $0)
|
||||
|
||||
|
@ -13,6 +13,8 @@ if [ -z "$1" ]; then
|
|||
fi
|
||||
|
||||
TS_DUMP="$1"
|
||||
TS_NAME=$(basename ${TS_DUMP})
|
||||
TS_TARBALL="$TS_DUMP.tar.xz"
|
||||
TS_CMD_LSBLK=${TS_CMD_LSBLK:-"lsblk"}
|
||||
|
||||
#
|
||||
|
@ -70,12 +72,21 @@ done
|
|||
|
||||
|
||||
function mk_output {
|
||||
cols="$2"
|
||||
name="$1"
|
||||
local cols="NAME,${2}"
|
||||
local subname="$1"
|
||||
|
||||
$TS_CMD_LSBLK -o NAME,${cols} > ${TS_DUMP}/lsblk.${name}
|
||||
echo "$cols" > ${TS_DUMP}/${subname}.cols
|
||||
$TS_CMD_LSBLK -o ${cols} > ${TS_DUMP}/lsblk-${TS_NAME}-${subname}
|
||||
}
|
||||
|
||||
|
||||
LANG="POSIX"
|
||||
LANGUAGE="POSIX"
|
||||
LC_ALL="POSIX"
|
||||
CHARSET="UTF-8"
|
||||
|
||||
export LANG LANGUAGE LC_ALL CHARSET
|
||||
|
||||
#
|
||||
# lsblk info
|
||||
#
|
||||
|
@ -90,9 +101,9 @@ mk_output discard DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO
|
|||
mk_output zone ZONED
|
||||
|
||||
|
||||
tar zcvf lsblk-$TS_DUMP.tar.gz $TS_DUMP
|
||||
tar --xz -cvf ${TS_TARBALL} $TS_DUMP
|
||||
rm -rf $TS_DUMP
|
||||
|
||||
echo -e "\nPlease, send lsblk-$TS_DUMP.tar.gz to util-linux upstream. Thanks!\n"
|
||||
echo -e "\nPlease, send ${TS_TARBALL} to util-linux upstream. Thanks!\n"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue