summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOndrej Oprala2013-04-10 15:27:59 +0200
committerKarel Zak2013-04-26 10:03:37 +0200
commit3a8f26bdcc6cb2242cb92718fcdfc195760cab51 (patch)
treecbe71e81675711f9c8a23015da0d7090f5e1aa38 /tests
parentbuild-sys: release++ (v2.23) (diff)
downloadkernel-qcow2-util-linux-3a8f26bdcc6cb2242cb92718fcdfc195760cab51.tar.gz
kernel-qcow2-util-linux-3a8f26bdcc6cb2242cb92718fcdfc195760cab51.tar.xz
kernel-qcow2-util-linux-3a8f26bdcc6cb2242cb92718fcdfc195760cab51.zip
tests: add partx regression tests
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/commands.sh2
-rw-r--r--tests/expected/partx/partx-add-all1
-rw-r--r--tests/expected/partx/partx-add-existing1
-rw-r--r--tests/expected/partx/partx-addpart1
-rw-r--r--tests/expected/partx/partx-change-by-range2
-rw-r--r--tests/expected/partx/partx-delete-all1
-rw-r--r--tests/expected/partx/partx-delete-non-existent1
-rw-r--r--tests/expected/partx/partx-delete-one1
-rw-r--r--tests/expected/partx/partx-delpart1
-rw-r--r--tests/expected/partx/partx-detect-parts3
-rwxr-xr-xtests/ts/partx/partx92
11 files changed, 106 insertions, 0 deletions
diff --git a/tests/commands.sh b/tests/commands.sh
index a2948c911..02ca6c3db 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -22,6 +22,8 @@ TS_HELPER_STRUTILS="$top_builddir/test_strutils"
TS_HELPER_SYSINFO="$top_builddir/test_sysinfo"
# paths to commands
+TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"}
+TS_CMD_DELPART=${TS_CMD_DELPART:-"$top_builddir/delpart"}
TS_CMD_BLKID=${TS_CMD_BLKID-"$top_builddir/blkid"}
TS_CMD_CAL=${TS_CMD_CAL-"$top_builddir/cal"}
TS_CMD_COLRM=${TS_CMD_COLRM:-"$top_builddir/colrm"}
diff --git a/tests/expected/partx/partx-add-all b/tests/expected/partx/partx-add-all
new file mode 100644
index 000000000..ce3894698
--- /dev/null
+++ b/tests/expected/partx/partx-add-all
@@ -0,0 +1 @@
+partitions added
diff --git a/tests/expected/partx/partx-add-existing b/tests/expected/partx/partx-add-existing
new file mode 100644
index 000000000..1c281de05
--- /dev/null
+++ b/tests/expected/partx/partx-add-existing
@@ -0,0 +1 @@
+partx: OK
diff --git a/tests/expected/partx/partx-addpart b/tests/expected/partx/partx-addpart
new file mode 100644
index 000000000..d86bac9de
--- /dev/null
+++ b/tests/expected/partx/partx-addpart
@@ -0,0 +1 @@
+OK
diff --git a/tests/expected/partx/partx-change-by-range b/tests/expected/partx/partx-change-by-range
new file mode 100644
index 000000000..ba9de05bc
--- /dev/null
+++ b/tests/expected/partx/partx-change-by-range
@@ -0,0 +1,2 @@
+partitions deleted
+partitions added
diff --git a/tests/expected/partx/partx-delete-all b/tests/expected/partx/partx-delete-all
new file mode 100644
index 000000000..ee6da6eb2
--- /dev/null
+++ b/tests/expected/partx/partx-delete-all
@@ -0,0 +1 @@
+partitions deleted
diff --git a/tests/expected/partx/partx-delete-non-existent b/tests/expected/partx/partx-delete-non-existent
new file mode 100644
index 000000000..1c281de05
--- /dev/null
+++ b/tests/expected/partx/partx-delete-non-existent
@@ -0,0 +1 @@
+partx: OK
diff --git a/tests/expected/partx/partx-delete-one b/tests/expected/partx/partx-delete-one
new file mode 100644
index 000000000..da85ea12b
--- /dev/null
+++ b/tests/expected/partx/partx-delete-one
@@ -0,0 +1 @@
+last partition removed
diff --git a/tests/expected/partx/partx-delpart b/tests/expected/partx/partx-delpart
new file mode 100644
index 000000000..d86bac9de
--- /dev/null
+++ b/tests/expected/partx/partx-delpart
@@ -0,0 +1 @@
+OK
diff --git a/tests/expected/partx/partx-detect-parts b/tests/expected/partx/partx-detect-parts
new file mode 100644
index 000000000..b24ee9440
--- /dev/null
+++ b/tests/expected/partx/partx-detect-parts
@@ -0,0 +1,3 @@
+ 1 32 33791 33760 16.5M
+ 2 33792 67583 33792 16.5M
+ 3 67584 102399 34816 17M
diff --git a/tests/ts/partx/partx b/tests/ts/partx/partx
index f09d96b86..3567cf87b 100755
--- a/tests/ts/partx/partx
+++ b/tests/ts/partx/partx
@@ -19,10 +19,12 @@
TS_TOPDIR="$(dirname $0)/../.."
TS_DESC="partitions probing"
TS_IMGDIR="$TS_TOPDIR/ts/blkid/images-pt"
+PARTS=3
. $TS_TOPDIR/functions.sh
ts_init "$*"
+ts_skip_nonroot
if [ ! -x "$TS_CMD_PARTX" ]; then
ts_skip "partx disabled"
@@ -42,4 +44,94 @@ for img in $(ls $TS_IMGDIR/*.img.bz2 | sort); do
ts_finalize_subtest
done
+modprobe --dry-run --quiet scsi_debug
+[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
+
+rmmod scsi_debug &> /dev/null
+modprobe scsi_debug dev_size_mb=50
+[ "$?" == 0 ] || ts_die "Cannot init device"
+
+sleep 3
+
+DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
+[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
+
+DEVICE="/dev/${DEVNAME}"
+
+ts_init_subtest "addpart"
+$TS_CMD_ADDPART ${DEVICE} 1 0 1
+[ "$?" == 0 ] && echo OK &>$TS_OUTPUT || ts_die "Unable to add partition"a &>$TS_OUTPUT
+ts_finalize_subtest
+
+sleep 1
+
+ts_init_subtest "delpart"
+$TS_CMD_DELPART ${DEVICE} 1
+[ "$?" == 0 ] && echo OK >> $TS_OUTPUT 2>&1 || ts_die "Unable to remove partition" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+rmmod scsi_debug &> /dev/null
+modprobe scsi_debug dev_size_mb=50 num_parts=$PARTS
+[ "$?" == 0 ] || ts_die "Cannot init device"
+
+sleep 3
+
+DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
+[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
+
+DEVICE="/dev/${DEVNAME}"
+
+ts_init_subtest "detect-parts"
+#detect PARTS partitions
+$TS_CMD_PARTX --show --noheadings $DEVICE &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "delete-all"
+#delete partinfo
+$TS_CMD_PARTX --delete $DEVICE &> $TS_OUTPUT
+[ $? -eq 0 ] && echo "partitions deleted" &> $TS_OUTPUT ||
+ echo "Unable to delete partitions on $DEVICE" &> $TS_OUTPUT
+ls -d "/sys/block/${DEVNAME}/${DEVNAME}*" 2>/dev/null && ts_die
+ts_finalize_subtest
+
+ts_init_subtest "add-all"
+#read DEVICE and restore the partinfo
+$TS_CMD_PARTX --add $DEVICE &> $TS_OUTPUT
+[ $(ls -d /sys/block/${DEVNAME}/${DEVNAME}* 2>/dev/null | wc -l) -eq $PARTS ] &&
+ echo "partitions added" >> $TS_OUTPUT 2>&1 ||
+ echo "Unable to add partitions for $DEVICE" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+sleep 1
+
+ts_init_subtest "delete-one"
+#remove last partition only
+$TS_CMD_PARTX -d --nr -1 $DEVICE >> $TS_OUTPUT 2>&1
+[ $(ls -d /sys/block/${DEVNAME}/${DEVNAME}* 2>/dev/null |
+wc -l) -eq $((PARTS-1)) ] &&
+ echo "last partition removed" >> $TS_OUTPUT 2>&1 ||
+ echo "Unable to remove a partition on $DEVICE" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "delete-non-existent"
+#attempt to remove it again
+$TS_CMD_PARTX -d $PARTS $DEVICE && echo "partx failed: removed non-existing partition" &>$TS_OUTPUT || echo "partx: OK" &>$TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "add-existing"
+#try adding an existing partition
+$TS_CMD_PARTX -a --nr 1 $DEVICE &>/dev/null && echo "partx failed: re-added an existing partition" &> $TS_OUTPUT || echo "partx: OK" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "change-by-range"
+# {-a|-d} --nr 0 should handle all partitions
+$TS_CMD_PARTX -d --nr 0 $DEVICE
+ls -d /sys/block/${DEVNAME}/${DEVNAME}* 2>/dev/null && echo "Unable to delete partitions on $DEVICE" >> $TS_OUTPUT 2>&1 || echo "partitions deleted" >> $TS_OUTPUT 2>&1
+$TS_CMD_PARTX -a --nr 0 $DEVICE
+[ $(ls -d /sys/block/${DEVNAME}/${DEVNAME}* 2>/dev/null | wc -l) -eq $PARTS ] && echo "partitions added" >> $TS_OUTPUT 2>&1 || echo "Failed to add $DEVICE partitions" >> $TS_OUTPUT 2>&1
+ts_finalize_subtest
+
+sleep 3
+rmmod scsi_debug
+
ts_finalize