From 1f02c5f2e4bc1c8871d1a0943a6e859fa86c02fa Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Tue, 22 Aug 2023 14:55:31 +0200 Subject: [PATCH] tests: add shell/report-headings.sh --- test/shell/report-headings.sh | 130 ++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 test/shell/report-headings.sh diff --git a/test/shell/report-headings.sh b/test/shell/report-headings.sh new file mode 100644 index 000000000..4a817f116 --- /dev/null +++ b/test/shell/report-headings.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash + +# Copyright (C) 2023 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +SKIP_WITH_LVMLOCKD=1 +SKIP_WITH_LVMPOLLD=1 + +. lib/inittest + +aux prepare_pvs 1 + +aux lvmconf 'log/prefix=""' +aux lvmconf 'report/compact_output=0' +aux lvmconf 'report/compact_output_cols=""' + +OPTS="ba_start,seg_start,seg_start_pe" + +aux lvmconf 'report/headings=0' + +pvs -o $OPTS > out +not grep "BA Start Start Start" out +not grep "pv_ba_start seg_start seg_start_pe" out + + +aux lvmconf 'report/headings=1' + +pvs -o $OPTS > out +grep "BA Start Start Start" out + +pvs --headings 1 -o $OPTS > out +grep "BA Start Start Start" out + +pvs --headings abbrev -o $OPTS > out +grep "BA Start Start Start" out + +pvs --headings 2 -o $OPTS > out +grep "pv_ba_start seg_start seg_start_pe" out + +pvs --headings full -o $OPTS > out +grep "pv_ba_start seg_start seg_start_pe" out + +pvs --headings none -o $OPTS > out +not grep "BA Start Start Start" out +not grep "pv_ba_start seg_start seg_start_pe" out + +pvs --rows -o $OPTS > out +grep "BA Start 0" out +grep "Start 0" out + +pvs --rows --headings 1 -o $OPTS > out +grep "BA Start" out +grep "Start 0" out; + +pvs --rows --headings abbrev -o $OPTS > out +grep "BA Start" out +grep "Start 0" out; + +pvs --rows --headings 2 -o $OPTS > out +grep "pv_ba_start 0" out +grep "seg_start 0" out +grep "seg_start_pe 0" out + +pvs --rows --headings full -o $OPTS > out +grep "pv_ba_start 0" out +grep "seg_start 0" out +grep "seg_start_pe 0" out + + +aux lvmconf 'report/headings=2' + +pvs -o $OPTS > out +grep "pv_ba_start seg_start seg_start_pe" out + +pvs --headings 1 -o $OPTS > out +grep "BA Start Start Start" out + +pvs --headings abbrev -o $OPTS > out +grep "BA Start Start Start" out + +pvs --headings 2 -o $OPTS > out +grep "pv_ba_start seg_start seg_start_pe" out + +pvs --headings full -o $OPTS > out +grep "pv_ba_start seg_start seg_start_pe" out + +pvs --rows -o $OPTS > out +grep "pv_ba_start 0" out +grep "seg_start 0" out +grep "seg_start_pe 0" out + +pvs --rows --headings 1 -o $OPTS > out +grep "BA Start" out +grep "Start 0" out; + +pvs --rows --headings abbrev -o $OPTS > out +grep "BA Start" out +grep "Start 0" out; + +pvs --rows --headings 2 -o $OPTS > out +grep "pv_ba_start 0" out +grep "seg_start 0" out +grep "seg_start_pe 0" out + +pvs --rows --headings full -o $OPTS > out +grep "pv_ba_start 0" out +grep "seg_start 0" out +grep "seg_start_pe 0" out + + +# if report/headings=100 (out of bound value), then it is as if "1" was used +aux lvmconf 'report/headings=100' + +pvs -o $OPTS > out +grep "BA Start Start Start" out + + +# if using --nameprefixes, the report/headings=2 is ignored +pvs --headings 2 --nameprefixes -o $OPTS > out +grep "LVM2_PV_BA_START='0 ' LVM2_SEG_START='0 ' LVM2_SEG_START_PE='0'" out + +# --noheadings and --headings not allowed +not pvs --headings 1 --noheadings