# run parted -s FILE mklabel msdos
parted -s $dev mklabel msdos > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# ----------------------------------------------
# Now, ensure that a simple mklabel command succeeds.
emit_superuser_warning > exp || fail=1
# check its "interactive" output
-compare out exp || fail=1
+compare exp out || fail=1
# create interactive input
printf 'y\n' > in || fail=1
EOF
# check its output -- slightly different here, due to prompts
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# When run as root, there are just curses-related control chars. Remove them.
sed 's/^.\{1,12\}$//;/^$/d' out > k && mv k out \
|| fail=1
- compare out /dev/null || fail=1
+ compare /dev/null out || fail=1
parted -s $dev p || fail=1
rm -f $dev
parted -s $dev mklabel msdos > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# print partition table in --script mode
TERM=xterm parted -m -s $dev u s p > out 2>&1 || fail=1
sed "s,.*/$dev:,$dev:," out > k && mv k out || fail=1
printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:msdos:;\n" > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out || fail=1
# check for expected output
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
s,^Error: .*/$dev:,Error: .../$dev:," o2 > out || fail=1
# check for expected output
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# save a copy of the original primary GPT table
dd if=$dev of=before count=1 skip=1 || fail=1
parted -m -s $dev u s p > out 2> err || fail=1
# don't bother comparing stdout
# expect no stderr
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
# extract the primary GPT table again
dd if=$dev of=after count=1 skip=1 || fail=1
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# shrink the backing file
dd if=/dev/null of=$dev seek=4000 2> /dev/null || fail=1
# create a new GPT table on top of the shrunken backing file
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
Exit $fail
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# Fill the first $bootcode_size bytes with 0's.
# This affects only the protective MBR, so doesn't affect validity of gpt table.
# create a GPT partition table on top of the existing one.
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# Extract the first $bootcode_size Bytes after GPT creation
dd if=$dev of=after bs=1c count=$bootcode_size > /dev/null 2>&1 || fail=1
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# truncate it to 34 sectors.
for i in 33 34 35 67 68 69 101 102 103; do
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
parted --align=none -s $dev mklabel gpt mkpart p1 $((64*1024))B $((1024*1024-$ss))B \
> err 2>&1 || fail=1
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
parted -m -s $dev u s p > exp || fail=1
rm $dev
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
parted --align=none -s $dev mklabel gpt mkpart p1 64KiB 1MiB \
> err 2>&1 || fail=1
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
parted -m -s $dev u s p > out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
dd if=/dev/null of=$dev bs=1M seek=$n_mbs || fail=1
# create 1st partition
parted --align=none -s $dev mklabel gpt mkpart p1 1MiB 2MiB > err 2>&1 || fail=1
-compare err /dev/null || fail=1 # expect no output
+compare /dev/null err || fail=1 # expect no output
#parted -m -s $dev u s p > exp || fail=1
# create 2nd partition - they should not overlap
# this time specify default unit
parted --align=none -s $dev unit MiB mkpart p2 2 3 > err 2>&1 || fail=1
-compare err /dev/null || fail=1 # expect no output
+compare /dev/null err || fail=1 # expect no output
# create 3rd partition - expect no overlap
# specify default unit, but explicitly override it
parted --align=none -s $dev unit TB mkpart p3 3MiB 4MiB > err 2>&1 || fail=1
-compare err /dev/null || fail=1 # expect no output
+compare /dev/null err || fail=1 # expect no output
# Specify default unit of MiB, yet use explicit ending sector number.
parted --align=none -s $dev unit MiB mkpart p4 4MiB 10239s > err 2>&1 || fail=1
-compare err /dev/null || fail=1 # expect no output
+compare /dev/null err || fail=1 # expect no output
# check boundaries of the partitions
parted -m -s $dev u s p > out || fail=1
# compare expected and actual outputs
sed -e "1,2d" out > k; mv k out
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
gpt-header-munge --sector-size=$ss --n=9 $dev || fail=1
parted -m -s $dev u s p > out 2>&1 || fail=1
sed 's/.*:gpt:/:gpt:/' out > k && mv k out
printf 'BYT;\n:gpt:;\n' > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# create a gpt partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:gpt:;\n" > exp
i=1
end=$(expr $start + $part_size - 1)
echo "$i:${start}s:${end}s:${part_size}s::$type:;" >> exp || fail=1
parted -s $dev mkpart primary $type ${start}s ${end}s > err 2>&1 || fail=1
- compare err /dev/null || fail=1
+ compare /dev/null err || fail=1
parted -s $dev name $i $type > err 2>&1 || fail=1
- compare err /dev/null || fail=1
+ compare /dev/null err || fail=1
start=$(expr $end + 1)
i=$(expr $i + 1)
done
sed "s,.*/$dev:,$dev:," out > k && mv k out && ok=1 || ok=0
# match against expected output
-test $ok = 1 && { compare out exp || fail=1; }
+test $ok = 1 && { compare exp out || fail=1; }
Exit $fail
# create a GPT partition table
parted -s $dev mklabel gpt > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# create a DOS partition table on top of it
parted -s $dev mklabel msdos > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
Exit $fail
# create a dos partition table
parted -s $dev mklabel msdos > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
Exit $fail
dev=$(cat dev-name)
parted -s "$dev" mklabel msdos mkpart primary fat32 1 40 > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
mkfs.vfat ${dev}1 || skip_ "mkfs.vfat failed"
mount_point="`pwd`/mnt"
# create expected output file
echo "Error: Partition(s) on $dev are being used." > exp
-compare out exp || fail=1
+compare exp out || fail=1
# Adding a partition must succeed, even though another
# on this same device is mounted (active).
parted -s "$dev" mkpart primary fat32 41 85 > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
parted -s "$dev" u s print
# ==================================================
-e 's,^.*/lt-parted: ,parted: ,' o2 > out
# check for expected failure diagnostic
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
parted -s "$dev" mklabel msdos > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
parted -s "$dev" mkpart primary fat32 1 40 > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
parted -s "$dev" mkpart primary fat32 40 80 > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# wait for new partition device to appear
wait_for_dev_to_appear_ ${dev}2 || fail_ ${dev}2 did not appear
parted -s "$dev" rm 2 > out 2>&1 && fail=1
# expect error
-compare out exp-error || fail=1
+compare exp-error out || fail=1
Exit $fail
# label the test disk
parted -s $dev mklabel msdos > out 2>&1 || fail=1
-compare out /dev/null || fail=1 # expect no output
+compare /dev/null out || fail=1 # expect no output
# create two partitions
parted -s $dev mkpart primary 2048s 4095s \
mkpart primary 4096s 8191s > out 2>&1 || fail=1
-compare out /dev/null || fail=1 # expect no output
+compare /dev/null out || fail=1 # expect no output
# write "FAT" where it would cause trouble
printf FAT | dd bs=1c seek=82 count=3 of=$dev conv=notrunc || fail=1
tail -2 out > k && mv k out || fail=1
printf "1:2048s:4095s:2048s:::;\n2:4096s:8191s:4096s:::;\n" > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# label the test disk
parted -s $dev mklabel pc98 > out 2>&1 || fail=1
-compare out /dev/null || fail=1 # expect no output
+compare /dev/null out || fail=1 # expect no output
parted -s $dev p | grep "^Partition Table: pc98" || fail=1
# Create msdos label
parted -s $dev mklabel msdos > out 2>&1 || fail=1
-compare out /dev/null || fail=1 # Expect no output
+compare /dev/null out || fail=1 # Expect no output
# Create extended partition
parted -s $dev mkpart extended 2048s 8191s > out 2>&1 || fail=1
-compare out /dev/null || fail=1 # Expect no output
+compare /dev/null out || fail=1 # Expect no output
# Create logical partition
parted -s $dev mkpart logical 4096s 8191s > out 2>&1 || fail=1
-compare out /dev/null || fail=1 # Expect no output
+compare /dev/null out || fail=1 # Expect no output
# Install fake bootcode
printf %0${bootcode_size}d 0 > in || fail=1
# Do something to the label
parted -s $dev rm 5 > out 2>&1 || fail=1
-compare out /dev/null || fail=1 # Expect no output
+compare /dev/null out || fail=1 # Expect no output
# Extract the bootcode for comparison
dd if=$dev of=after bs=1 skip=1M count=$bootcode_size || fail=1
parted -s $scsi_dev mklabel msdos || fail=1
parted --align=min -s $scsi_dev mkpart extended 64s 128s> out 2>&1 || fail=1
parted -m -s $scsi_dev u s print
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# Provoke a failure by trying to create a partition that starts just
# one sector after the start of the extended partition.
parted -s $scsi_dev rm 5 || fail=1
parted --align=min -s $scsi_dev mkpart logical 66s 128s > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
parted -m -s $scsi_dev u s print > out 2>&1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
mkpart pri hfs 2048s 4095s \
mkpart pri hfs+ 4096s 6143s > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# Extract the "type" byte of the first partition.
od -An -j450 -tx1 -N1 $dev > out || fail=1
od -An -j466 -tx1 -N1 $dev >> out || fail=1
printf ' af\n af\n' > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
dd if=/dev/null of=$dev bs=1 seek=$N || framework_failure
parted -s "$dev" mklabel gpt mkpart p1 1MiB 2MiB > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
parted -s "$dev" u s p || fail=1
grep -E '^1:2048s:4095s:2048s:::p...;$' out > k; mv k out
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
parted -s $dev mklabel $table_type \
mkpart $pri_or_name ext2 $((1*2048))s $((2*2048-1))s \
> out 2> err || fail=1
- compare out /dev/null || fail=1
+ compare /dev/null out || fail=1
for mode in on_only on_and_off ; do
for flag in $flags; do
extract_flags raw > out
grep -F "$flag" out \
|| { warn_ "$ME: flag not turned on: $(cat out)"; fail=1; }
- compare err /dev/null || fail=1
+ compare /dev/null err || fail=1
if test $mode = on_and_off; then
# Turn it off
extract_flags raw > out
grep -F "$flag" out \
&& { warn_ "$ME: flag not turned off: $(cat out)"; fail=1; }
- compare err /dev/null || fail=1
+ compare /dev/null err || fail=1
fi
done
done
parted -m -s $dev_file u s print > out 2>&1 || fail=1
grep '^1:' out > k; mv k out
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# label the test disk as a sun disk
parted -s $dev mklabel sun > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# create a single partition
parted -s $dev unit s mkpart ext2 0s 127s > out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# print the partition data in machine readable format
parted -m -s $dev unit s p > out 2>&1 || fail=1
# check for expected values for the partition
printf "$exp:::;\n" > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# set the raid flag
parted -s $dev set 1 raid >out 2>&1 || fail=1
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# print the partition data in machine readable format again
parted -m -s $dev unit s p > out 2>&1 || fail=1
# check for expected values (including raid flag) for the partition
printf "$exp:::raid;\n" > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# label the test disk
parted -s $dev mklabel sun > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# extract version
od -t x1 -An -j128 -N4 $dev > out || fail=1
echo " 00 00 00 01" > exp || fail=1
# expect it to be 00 00 00 01, not 00 00 00 00
-compare out exp || fail=1
+compare exp out || fail=1
# extract nparts
od -t x1 -An -j140 -N2 $dev > out || fail=1
echo " 00 08" > exp || fail=1
# expect it to be 00 08, not 00 00
-compare out exp || fail=1
+compare exp out || fail=1
# extract sanity magic
od -t x1 -An -j188 -N4 $dev > out || fail=1
echo " 60 0d de ee" > exp
# expect it to be 60 0d de ee, not 00 00 00 00
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
parted -s $dev unit s p > out 2>&1 || fail=1
sed -n "/^ *1 *$n/s/ */ /gp" out|sed "s/ *\$//" > k && mv k out || fail=1
echo " 1 ${n}s ${end}s 4294967295s primary" > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# a partition length of exactly 2^32 sectors provokes failure.
do_mkpart $n $(echo $n+2^32-1|bc) > err 2>&1
# check for new diagnostic
bad_part_length 4294967296 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
# FIXME: investigate this.
# Unexpectedly to me, both of these failed with this same diagnostic:
# check for new diagnostic
bad_part_length 4294967297 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
# =========================================================
# Now consider partition starting sector numbers.
# print the result
parted -s $dev unit s p > out 2>&1 || fail=1
sed "s/Disk .*:/Disk:/;s/ *$//" out > k && mv k out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# a partition start sector number of 2^32 must fail
do_mkpart_start_and_len $(echo 2^32|bc) 1000 > err 2>&1
# check for new diagnostic
bad_start_sector 4294967296 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
# a partition start sector number of 2^32+1 must fail, too.
do_mkpart_start_and_len $(echo 2^32+1|bc) 1000 > err 2>&1
# check for new diagnostic
bad_start_sector 4294967297 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
done
parted -s $dev unit s p > out 2>&1 || fail=1
sed -n "/^ *1 *$n/s/ */ /gp" out|sed "s/ *\$//" > k && mv k out || fail=1
echo " 1 ${n}s ${end}s 4294967295s primary" > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# a partition length of exactly 2^32 sectors provokes failure.
do_mkpart $n $(echo $n+2^32-1|bc) > err 2>&1
# check for new diagnostic
bad_part_length 4294967296 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
# a partition length of 2^32+1 sectors must provoke failure.
do_mkpart $n $(echo $n+2^32|bc) > err 2>&1
# check for new diagnostic
bad_part_length 4294967297 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
# =========================================================
# Now consider partition starting sector numbers.
# print the result
parted -s $dev unit s p > out 2>&1 || fail=1
sed "s/Disk .*:/Disk:/;s/ *$//" out > k && mv k out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# a partition start sector number of 2^32 must fail
do_mkpart_start_and_len $(echo 2^32|bc) 1000 > err 2>&1
# check for new diagnostic
bad_start_sector 4294967296 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
# a partition start sector number of 2^32+1 must fail, too.
do_mkpart_start_and_len $(echo 2^32+1|bc) 1000 > err 2>&1
# check for new diagnostic
bad_start_sector 4294967297 > exp || fail=1
-compare err exp || fail=1
+compare exp err || fail=1
done
# label the test disk
parted -s $dev mklabel msdos > out 2>&1 || fail=1
# expect no output
-compare out /dev/null || fail=1
+compare /dev/null out || fail=1
# Test the output of print free with no partitions.
cat <<EOF > exp || fail=1
# check for expected output
sed "2s/^[^:]*:/path:/" < out > k; mv k out
-compare out exp || fail=1
+compare exp out || fail=1
# Test the output of print free with one partition.
cat <<EOF > exp || fail=1
# check for expected output
sed "2s/^[^:]*:/path:/" < out > k; mv k out
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# Parted 1.8.9 and earlier would mistakenly try to access partition #17.
# ensure that partprobe succeeds and produces no output"
partprobe -s $dev > out 2>err || fail=1
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
echo "$dev: dvh partitions 9 <17>" > exp || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# Create msdos partition table
parted -s $dev mklabel msdos > out 2>&1 || fail=1
- compare out /dev/null || fail=1
+ compare /dev/null out || fail=1
parted -s "$dev" print > out 2>&1 || fail=1
sed 's/^Disk .*: /Disk DEV: /' out > k; mv k out
EOF
- compare out exp || fail=1
+ compare exp out || fail=1
done
Exit $fail
# Expect this to succeed.
parted -s $d1 mklabel msdos > err 2>&1 || fail=1
-compare err /dev/null || fail=1 # expect no output
+compare /dev/null err || fail=1 # expect no output
# Create a partition
parted -s $d1 mkpart primary 1 10 > err 2>&1 || fail=1
-compare err /dev/null || fail=1 # expect no output
+compare /dev/null err || fail=1 # expect no output
Exit $fail
# Expect this to succeed
parted -s "$loopdev" mklabel msdos > err 2>&1 || fail=1
-compare err /dev/null || fail=1 # expect no output
+compare /dev/null err || fail=1 # expect no output
# Create a partition
parted -s "$loopdev" mkpart primary 1M 2M > err 2>&1 || fail=1
grep '^Sector' out > k 2>&1 || fail=1
mv k out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
# print alignment info
"$abs_srcdir/print-align" $scsi_dev > out 2>&1 || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
print-max $dev > out 2>&1 || fail=1
printf '%s\n' "max len: $max_len" \
"max start sector: $max_start" > exp || fail=1
- compare out exp || fail=1
+ compare exp out || fail=1
done
Exit $fail
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
parted --align=none -s $dev mklabel msdos mkpart pri 1s $((1000*1000))B \
> err 2>&1 || fail=1
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
parted -m -s $dev u s p > exp || fail=1
rm $dev
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
parted --align=none -s $dev mklabel msdos mkpart pri 0 1MB \
> err 2>&1 || fail=1
-compare err /dev/null || fail=1
+compare /dev/null err || fail=1
parted -m -s $dev u s p > out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
Exit $fail
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
parted --align=none -s $dev mklabel msdos mkpart pri 0 0.5MB \
> err 2>&1
-compare err exp || fail=1
+compare exp err || fail=1
Exit $fail
test $(expr $i % 8) = 7 && exp_result=0 || exp_result=1
test $result = $exp_result || fail=1
- compare out /dev/null || fail=1
+ compare /dev/null out || fail=1
parted -s $scsi_dev rm 1
i=$(expr $i + 1)
|| fail=1
parted -m -s $scsi_dev u s p > out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
# We must remove these partitions before terminating.
# Otherwise, even though cleanup-driven rmmod will eventually cause
|| fail=1
parted -m -s $scsi_dev u s p > out || fail=1
-compare out exp || fail=1
+compare exp out || fail=1
wait_for_dev_to_appear_ ${scsi_dev}16 || fail_ ${scsi_dev}16 did not appear
> exp-error || framework_failure_
# expect error
- compare out exp-error || fail=1
+ compare exp-error out || fail=1
done