diff --git a/test/shell/dmstats-filemap.sh b/test/shell/dmstats-filemap.sh new file mode 100644 index 000000000..4f16b0a77 --- /dev/null +++ b/test/shell/dmstats-filemap.sh @@ -0,0 +1,79 @@ +#!/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_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 + +. lib/inittest + +# Don't attempt to test stats with driver < 4.33.00 +aux driver_at_least 4 33 || skip + +# ensure we can create devices (uses dmsetup, etc) +aux prepare_devs 1 2048 + +mount_dir="mnt" +hist_bounds="10ms,20ms,30ms" +file_size="100m" + +test ! -d "$mount_dir" && mkdir "$mount_dir" + +cleanup_mounted_and_teardown() +{ + umount "$mount_dir" 2>/dev/null || true + aux teardown +} + +trap 'cleanup_mounted_and_teardown' EXIT + +mkfs.xfs "$dev1" +mount "$dev1" "$mount_dir" + +test_filemap() +{ + local map_file="$1" + local use_precise="$2" + local use_bounds="$3" + if [[ $use_precise == 1 ]]; then + precise="--precise" + else + precise="" + fi + if [[ $use_bounds == 1 ]]; then + bounds="--bounds $hist_bounds" + else + bounds="" + fi + fallocate -l "$file_size" "$mount_dir/$map_file" + dmstats create ${precise} ${bounds} --filemap "$mount_dir/$map_file" + dmstats list -ostats_name,precise |& tee out + grep "$map_file" out + if [[ $use_precise == 1 ]]; then + grep "1" out + fi + if [[ $use_bounds == 1 ]]; then + dmstats list -ostats_name,hist_bounds |& tee out + grep "$hist_bounds" out + fi + dmstats delete --allregions --alldevices + rm -f "$mount_dir/$map_file" +} + +for file in "filenospace" "File With Spaces" "$(echo -ne 'file\twith\ttabs')"; do + for precise in 0 1; do + for bounds in 0 1; do + test_filemap "$file" "$precise" "$bounds" + done + done +done + +sleep .5 diff --git a/test/shell/dmstats-group.sh b/test/shell/dmstats-group.sh new file mode 100644 index 000000000..1a8d8dcd8 --- /dev/null +++ b/test/shell/dmstats-group.sh @@ -0,0 +1,34 @@ +#!/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_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 + +. lib/inittest + +# Don't attempt to test stats with driver < 4.33.00 +aux driver_at_least 4 33 || skip + +# ensure we can create devices (uses dmsetup, etc) +aux prepare_devs 1 + +GROUP_NAME="group0" + +# Create a region and make it part of a group with an alias +dmstats create "$dev1" +dmstats group --alias "$GROUP_NAME" --regions 0 "$dev1" +dmstats list -ostats_name |& tee out +grep "$GROUP_NAME" out + +# Remove the group and its regions +dmstats delete --groupid 0 "$dev1" + diff --git a/test/shell/dmstats-histogram.sh b/test/shell/dmstats-histogram.sh new file mode 100644 index 000000000..95cac02a2 --- /dev/null +++ b/test/shell/dmstats-histogram.sh @@ -0,0 +1,30 @@ +#!/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_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 + +. lib/inittest + +# Don't attempt to test stats with driver < 4.33.00 +aux driver_at_least 4 33 || skip + +# ensure we can create devices (uses dmsetup, etc) +aux prepare_devs 1 + +HIST_BOUNDS="10ms,20ms,30ms" + +# Create a region with a histogram and verify it in the list output +dmstats create --bounds "$HIST_BOUNDS" "$dev1" +dmstats list -ostats_name,hist_bounds |& tee out +grep "$HIST_BOUNDS" out + diff --git a/test/shell/dmstats-precise.sh b/test/shell/dmstats-precise.sh new file mode 100644 index 000000000..bce3cc315 --- /dev/null +++ b/test/shell/dmstats-precise.sh @@ -0,0 +1,28 @@ +#!/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_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 + +. lib/inittest + +# Don't attempt to test stats with driver < 4.33.00 +aux driver_at_least 4 33 || skip + +# ensure we can create devices (uses dmsetup, etc) +aux prepare_devs 1 + +# Create a region with precise_timestamps and verify it in the list output +dmstats create --precise "$dev1" +dmstats list -oprecise |& tee out +grep "1" out + diff --git a/test/shell/dmstats-ungroup.sh b/test/shell/dmstats-ungroup.sh new file mode 100644 index 000000000..31a8678af --- /dev/null +++ b/test/shell/dmstats-ungroup.sh @@ -0,0 +1,35 @@ +#!/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_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 + +. lib/inittest + +# Don't attempt to test stats with driver < 4.33.00 +aux driver_at_least 4 33 || skip + +# ensure we can create devices (uses dmsetup, etc) +aux prepare_devs 1 + +GROUP_NAME="group0" + +# Create a region and make it part of a group with an alias +dmstats create "$dev1" +dmstats group --alias "$GROUP_NAME" --regions 0 "$dev1" +dmstats list -ostats_name |& tee out +grep "$GROUP_NAME" out + +# Ungroup the regions then remove them +dmstats ungroup --groupid 0 "$dev1" +dmstats delete --allregions "$dev1" + diff --git a/test/shell/dmstats-userdata.sh b/test/shell/dmstats-userdata.sh new file mode 100644 index 000000000..700a54234 --- /dev/null +++ b/test/shell/dmstats-userdata.sh @@ -0,0 +1,31 @@ +#!/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_LVMPOLLD=1 +SKIP_WITH_LVMLOCKD=1 + +. lib/inittest + +# Don't attempt to test stats with driver < 4.33.00 +aux driver_at_least 4 33 || skip + +# ensure we can create devices (uses dmsetup, etc) +aux prepare_devs 1 + +USERDATA="aword" + +# Create dmstats region with userdata and verify it is reported +# in list output +dmstats create --userdata "$USERDATA" "$dev1" +dmstats list -ouserdata |& tee out +grep "$USERDATA" out +