[parted-devel] Running parted-2.2 tests

Jim Meyering jim at meyering.net
Tue Mar 2 11:41:48 UTC 2010


Gilles Espinasse wrote:
> I was in a way to better document how to run tests when I find some oddities
> Using make check -C tests run 31 tests.
> Using make check like documented in readme-hacking run only 28 tests

Thanks for the report and analysis.

When you run "make check -C tests", that skips the tests (driven by
the top-level Makefile.am) that simulate nonstandard sector sizes:

    .PHONY: ss-1024 ss-2048 ss-4096
    ss-1024 ss-2048 ss-4096:
            PARTED_SECTOR_SIZE=$(subst ss-,,$@) $(MAKE) check-recursive

    # Run the regression test suite with different settings,
    # to ensure it works with simulated partition sizes > 512.
    .PHONY: check-other-sector_sizes
    check-other-sector_sizes:
            $(MAKE) ss-1024
            $(MAKE) ss-2048
            $(MAKE) ss-4096

    check: check-other-sector_sizes

The above runs the "make check" tests three additional times,
first with PARTED_SECTOR_SIZE=1024 in the environment,
then 2048, and finally 4096.  Those three runs happen *before*
the final usual "make check" with nothing special in the environment.

When I run make check (using parted.git's master), I see "All 27 tests
passed" for each of the first 3 runs, and "All 30 tests passed" for the
final one.  That is to be expected, because 3 tests exercise file-system-
specific code that we won't bother trying to make that work for disks
with larger-than-512-byte sectors.  Hence, those three tests must be
skipped when simulating >512-byte sectors.

> FAIL: t5000-tags.sh

I haven't looked at this one yet.
...
> FAIL: t0280-gpt-corrupt.sh
...
> Written by <http://parted.alioth.debian.org/cgi-bin/trac.cgi/browser/AUTHORS>.
> + : .
> + . ./t-lib.sh
> ++ unset function_test
> ++ eval 'function_test() { return 11; }; function_test'
> +++ function_test
> +++ return 11
> ++ test 11 '!=' 11
> +++ pwd
> ++ test_dir_=/usr/src/parted-2.2/tests
> +++ this_test_
> +++ echo ././t0280-gpt-corrupt.sh
> +++ sed 's,.*/,,'
> ++ this_test=t0280-gpt-corrupt.sh
> +++ mktemp -d --tmp=/usr/src/parted-2.2/tests pe-t0280-gpt-corrupt.sh.XXXXXXXXXX
> ++ t_=/usr/src/parted-2.2/tests/pe-t0280-gpt-corrupt.sh.TLpC1247No
> ++ cleanup_eval_=:
> ++ . ./t-local.sh
> +++ sector_size_=512
> +++ scsi_debug_lock_file_=/usr/src/parted-2.2/tests/scsi_debug.lock
> +++ scsi_debug_modprobe_succeeded_=
> +++ cleanup_eval_=':; scsi_debug_cleanup_'
> +++ . ./t-lvm.sh
> ++++ export LVM_SUPPRESS_FD_WARNINGS=1
> ++++ LVM_SUPPRESS_FD_WARNINGS=1
> +++++ basename ./t0280-gpt-corrupt.sh
> ++++ ME=t0280-gpt-corrupt.sh
> ++ trap remove_tmp_ 0
> ++ trap 'Exit $?' 1 2 13 15
> ++ cd /usr/src/parted-2.2/tests/pe-t0280-gpt-corrupt.sh.TLpC1247No
> ++ diff --version
> ++ grep GNU
> + dev=loop-file
> + ss=512
> + n_sectors=5000
> + fail=0
> + dd if=/dev/null of=loop-file bs=512 seek=5000
> 0+0 records in
> 0+0 records out
> 0 bytes (0 B) copied, 1.7021e-05 s, 0.0 kB/s
> + parted -s loop-file mklabel gpt
> + compare /dev/null empty
> + diff -u /dev/null empty
> + parted -m -s loop-file unit s print
> + sed 's,.*/loop-file:,loop-file:,' t
> + printf 'BYT;\nloop-file:5000s:file:512:512:gpt:;\n'
> + compare exp out
> + diff -u exp out
> + parted -s loop-file mkpart sw linux-swap 2048s 4095s
> + compare /dev/null empty
> + diff -u /dev/null empty
> ++ gpt_corrupt_primary_table_ loop-file 512
> ++ case $# in
> ++ local dev=loop-file
> ++ local ss=512
> ++ case $ss in
> ++++ gpt1_pte_name_offset_ 512
> ++++ local ss=512
> ++++ case $ss in
> ++++ expr 512 '*' 2 + 56
> ++++ return 0
> +++ peek_ loop-file 1080
> +++ case $# in
> +++ case $2 in
> +++ dd if=loop-file bs=1 skip=1080 count=1
> 1+0 records in
> 1+0 records out
> 1 byte (1 B) copied, 3.2736e-05 s, 30.5 kB/s
> ++ local orig_pte_name_byte=
> ++ local new_byte

This may be due to a defective /bin/sh on your system.
What version of which shell is that?

On other systems (I've tried both debian unstable with bash-4.1.0
and Fedora 12), we get this:

    orig_pte_name_byte=s

That your shell assigns the empty string there is very suspicious.

FYI, in case you can investigate, the code in question is in tests/t-local.sh:

# Change the name of the first partition in the primary GPT table,
# thus invalidating the PartitionEntryArrayCRC32 checksum.
gpt_corrupt_primary_table_()
{
  case $# in 2) ;; *) echo "$0: expected 2 args, got $#" >&2; return 1;; esac
  local dev=$1
  local ss=$2
  case $ss in *[^0-9]*) echo "$0: invalid sector size: $ss">&2; return 1;; esac

  # get the first byte of the name
  local orig_pte_name_byte=$(peek_ $dev $(gpt1_pte_name_offset_ $ss)) || return 1

  local new_byte
  test x"$orig_pte_name_byte" = xA && new_byte=B || new_byte=A

  # Replace with a different byte
  poke_ $dev $(gpt1_pte_name_offset_ $ss) "$new_byte" || return 1

  printf %s "$orig_pte_name_byte"
  return 0
}



More information about the parted-devel mailing list