0b7af917e2
- Drop patches incorporated into upstream - Still adds the various DASD patches
111 lines
3.3 KiB
Diff
111 lines
3.3 KiB
Diff
From e38df2d81f0a4647711ffeb92a32c99e7ce9a92d Mon Sep 17 00:00:00 2001
|
|
From: Jim Meyering <meyering@redhat.com>
|
|
Date: Sat, 9 Jun 2012 17:26:21 +0200
|
|
Subject: [PATCH 06/89] tests: add a test to exercise just-fixed code
|
|
|
|
* tests/print-max.c: Extend to provide coverage of
|
|
ped_disk_get_max_supported_partition_count, too.
|
|
* tests/t9021-maxima.sh (max_n_partitions): New function, with
|
|
naively hard-coded max-number-of-partitions-per-partition-table-type
|
|
values.
|
|
Use it to ensure that each expected value matches the actual one.
|
|
* cfg.mk: Exempt this test's use of error from the syntax-check
|
|
for unmarked diagnostics.
|
|
---
|
|
cfg.mk | 2 ++
|
|
tests/print-max.c | 10 ++++++++++
|
|
tests/t9021-maxima.sh | 26 +++++++++++++++++++++++++-
|
|
3 files changed, 37 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/cfg.mk b/cfg.mk
|
|
index c6a00c8..45d2ac2 100644
|
|
--- a/cfg.mk
|
|
+++ b/cfg.mk
|
|
@@ -69,3 +69,5 @@ exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
|
|
|
|
exclude_file_name_regexp--sc_prohibit_path_max_allocation = \
|
|
^libparted/arch/beos\.c$$
|
|
+
|
|
+exclude_file_name_regexp--sc_unmarked_diagnostics = ^tests/print-max\.c$$
|
|
diff --git a/tests/print-max.c b/tests/print-max.c
|
|
index 7560d49..41aa8c6 100644
|
|
--- a/tests/print-max.c
|
|
+++ b/tests/print-max.c
|
|
@@ -2,9 +2,11 @@
|
|
#include <parted/parted.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
+#include <errno.h>
|
|
|
|
#include "closeout.h"
|
|
#include "progname.h"
|
|
+#include "error.h"
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
@@ -26,8 +28,16 @@ main (int argc, char **argv)
|
|
PedSector max_length = ped_disk_max_partition_length (disk);
|
|
PedSector max_start_sector = ped_disk_max_partition_start_sector (disk);
|
|
|
|
+ if (!ped_device_open(dev))
|
|
+ error (EXIT_FAILURE, errno, "failed to open %s\n", dev_name);
|
|
+ int max_n_partitions;
|
|
+ bool ok = ped_disk_get_max_supported_partition_count (disk,
|
|
+ &max_n_partitions);
|
|
+
|
|
printf ("max len: %llu\n", (unsigned long long) max_length);
|
|
printf ("max start sector: %llu\n", (unsigned long long) max_start_sector);
|
|
+ printf ("max number of partitions: %d\n",
|
|
+ ok ? max_n_partitions : -1);
|
|
|
|
ped_disk_destroy (disk);
|
|
ped_device_destroy (dev);
|
|
diff --git a/tests/t9021-maxima.sh b/tests/t9021-maxima.sh
|
|
index 0570585..ca10d17 100755
|
|
--- a/tests/t9021-maxima.sh
|
|
+++ b/tests/t9021-maxima.sh
|
|
@@ -23,6 +23,27 @@ dev=dev-file
|
|
PATH="..:$PATH"
|
|
export PATH
|
|
|
|
+max_n_partitions()
|
|
+{
|
|
+ case $1 in
|
|
+
|
|
+ # Technically, msdos partition tables have no limit on the maximum number
|
|
+ # of partitions, but we pretend it is 64 due to implementation details.
|
|
+ msdos) m=64;;
|
|
+
|
|
+ gpt) m=128;;
|
|
+ dvh) m=16;;
|
|
+ sun) m=8;;
|
|
+ mac) m=65536;;
|
|
+ bsd) m=8;;
|
|
+ amiga) m=128;;
|
|
+ loop) m=1;;
|
|
+ pc98) case $ss in 512) m=16;; *) m=64;; esac;;
|
|
+ *) warn_ invalid partition table type: $1 1>&2; exit 1;;
|
|
+ esac
|
|
+ echo $m
|
|
+}
|
|
+
|
|
# FIXME: add aix when/if it's supported again
|
|
for t in msdos gpt dvh sun mac bsd amiga loop pc98; do
|
|
echo $t
|
|
@@ -40,8 +61,11 @@ for t in msdos gpt dvh sun mac bsd amiga loop pc98; do
|
|
esac
|
|
|
|
print-max $dev > out 2>&1 || fail=1
|
|
+ m=$(max_n_partitions $t) || fail=1
|
|
printf '%s\n' "max len: $max_len" \
|
|
- "max start sector: $max_start" > exp || fail=1
|
|
+ "max start sector: $max_start" \
|
|
+ "max number of partitions: $m" \
|
|
+ > exp || fail=1
|
|
compare exp out || fail=1
|
|
done
|
|
|
|
--
|
|
1.8.5.3
|
|
|