summaryrefslogtreecommitdiff
path: root/tests/t9040-many-partitions.sh
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-01-23 21:32:00 +0100
committerJim Meyering <meyering@redhat.com>2012-01-23 21:32:00 +0100
commitcd280c622f5f5f8708ace2f04118d80d9a2c6a8f (patch)
tree16a4780e16edaf4700ba2927caf56cfa2f0a9418 /tests/t9040-many-partitions.sh
parentfd9fe8fa65019e62c80f87b68aa1dda46b63ecf8 (diff)
downloadparted-cd280c622f5f5f8708ace2f04118d80d9a2c6a8f.tar.gz
tests: create 128 partitions also in the scsi-backed test
* tests/t9040-many-partitions.sh: Tighten up: use less memory: 1 sector per partition rather than 256. Exec parted just once, not once per partition. With that, we can increase the number of partitions to create from 60 (which used to take 2.5 minutes on an F12-era kernel) to the standard-GPT-header-imposed maximum of 128. Suggested by Phillip Susi.
Diffstat (limited to 'tests/t9040-many-partitions.sh')
-rw-r--r--tests/t9040-many-partitions.sh38
1 files changed, 22 insertions, 16 deletions
diff --git a/tests/t9040-many-partitions.sh b/tests/t9040-many-partitions.sh
index c77628c..db065f4 100644
--- a/tests/t9040-many-partitions.sh
+++ b/tests/t9040-many-partitions.sh
@@ -25,9 +25,9 @@ grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
skip_ 'this system lacks a new-enough libblkid'
ss=$sector_size_
-partition_sectors=256 # sectors per partition
-n_partitions=60 # how many partitions to create
-start=2048 # start sector for the first partition
+partition_sectors=1 # sectors per partition
+n_partitions=128 # how many partitions to create
+start=34 # start sector for the first partition
gpt_slop=34 # sectors at end of disk reserved for GPT
n_sectors=$(($start + n_partitions * partition_sectors + gpt_slop))
@@ -43,29 +43,35 @@ n=$((n_MiB * sectors_per_MiB))
printf "BYT;\n$scsi_dev:${n}s:scsi:$ss:$ss:gpt:Linux scsi_debug;\n" \
> exp || fail=1
-parted -s $scsi_dev mklabel gpt || fail=1
-parted -s $scsi_dev u s p || fail=1
-
+cmd=
i=1
-t0=$(date +%s.%N)
while :; do
- end=$((start + partition_sectors - 1))
- parted -s $scsi_dev mkpart p$i ${start}s ${end}s || fail=1
- printf "$i:${start}s:${end}s:${partition_sectors}s::p$i:;\n" >> exp
- test $i = $n_partitions && break
- start=$((start + partition_sectors))
- i=$((i+1))
+ s=$((start + i - 1))
+ e=$((s + partition_sectors - 1))
+ cmd="$cmd mkpart p$i ${s}s ${e}s"
+ test $i = $n_partitions && break; i=$((i+1))
done
+
+# Time the actual command:
+t0=$(date +%s.%N)
+parted -m -a min -s $scsi_dev mklabel gpt $cmd u s p > out 2>&1 || fail=1
t_final=$(date +%s.%N)
+i=1
+while :; do
+ s=$((start + i - 1))
+ e=$((s + partition_sectors - 1))
+ printf "$i:${s}s:${e}s:${partition_sectors}s::p$i:;\n" >> exp
+ test $i = $n_partitions && break; i=$((i+1))
+done
+
# Fail the test if it takes too long.
-# On Fedora 13, it takes about 15 seconds.
-# With older kernels, it typically takes more than 150 seconds.
+# On Fedora 16, this takes about 10 seconds for me.
+# With Fedora-12-era kernels, it typically took more than 150 seconds.
$AWK "BEGIN {d = $t_final - $t0; n = $n_partitions; st = 60 < d;"\
' printf "created %d partitions in %.2f seconds\n", n, d; exit st }' /dev/null \
|| fail=1
-parted -m -s $scsi_dev u s p > out || fail=1
compare exp out || fail=1
Exit $fail