bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [platform-testers] new snapshot available: parted-3.0.136-1f80


From: Jim Meyering
Subject: Re: [platform-testers] new snapshot available: parted-3.0.136-1f80
Date: Tue, 21 Feb 2012 09:23:17 +0100

Bruno Haible wrote:
> Jim Meyering wrote:
>> The sole failure seems to be due to mkswap failing on your system.
>> However, the code that is failing redirects stderr and stdout
>> to /dev/null, so there is no clue in the log.
>>
>> I confirmed that it works on openSUSE 11.4:
>>
>>    $ dd if=/dev/null of=f bs=1 seek=30M && mkswap f && echo ok
>>    ...
>>    ok
>>    $
>>
>> But I get a clue when the existing "device" has a preexisting
>> partition table:
>>
>>     $ dd if=/dev/null of=f bs=1 seek=30M \
>>       && parted -s f mklabel gpt && mkswap f && echo ok
>>     0+0 records in
>>     0+0 records out
>>     0 bytes (0 B) copied, 0.000331645 s, 0.0 kB/s
>>     mkswap: f: warning: don't erase bootbits sectors
>>             (gpt partition table detected). Use -f to force.
>>     Setting up swapspace version 1, size = 30716 KiB
>>     no label, UUID=d8af74af-b83d-487d-9160-a7d9827f2e47
>>     ok
>>
>> Note the warning.
>> I'll bet the 12.1 version of mkswap now requires --force in that case.
>
> Hmm, no, it still works without --force:
...
> No, this patch does not fix the problem, but it gives a clue to the cause:
>
> $ make check -C tests TESTS=t9050-partition-table-types.sh VERBOSE=yes
> ...
> + echo mkswap:bsd
> mkswap:bsd
> + case $i in
> + mkswap -f f
> ./t9050-partition-table-types.sh: line 44: mkswap: command not found
> + fail=1
> ...
>
> So, the reason was that 'mkswap' is not found in $PATH. (It's in /sbin,
> which is not in $PATH of a non-root user in this distro.)

Thank you.
Pesky Suse PATH.  We had a similar problem in coreutils,
so I'm using its solution here:

>From c92748d1bedc53fe0a49ae1eead78315c99e1ec3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 19 Feb 2012 15:31:58 +0100
Subject: [PATCH] tests: sanitize PATH; do not discard mkswap output

* tests/init.cfg (sanitize_path_): New function, from coreutils.
Use it.
* tests/t9050-partition-table-types.sh: Do not discard mkswap output
and diagnostics.  This test would fail (e.g., on OpenSUSE 12.1), when
run with PATH not including /sbin.  Reported by Bruno Haible.
---
 tests/init.cfg                       |   37 ++++++++++++++++++++++++++++++++++
 tests/t9050-partition-table-types.sh |    2 +-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/tests/init.cfg b/tests/init.cfg
index 6072acd..24b10bc 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -25,6 +25,41 @@ require_512_byte_sector_size_()
   test $sector_size_ = 512 || skip_ 'FS test with sector size != 512'
 }

+# Having an unsearchable directory in PATH causes execve to fail with EACCES
+# when applied to an unresolvable program name, contrary to the desired ENOENT.
+# Avoid the problem by rewriting PATH to exclude unsearchable directories.
+# Also, if PATH lacks /sbin and/or /usr/sbin, append it/them.
+sanitize_path_()
+{
+  # FIXME: remove double quotes around $IFS when all tests use init.sh.
+  # They constitute a work-around for a bug in FreeBSD 8.1's /bin/sh.
+  local saved_IFS="$IFS"
+    IFS=:
+    set -- $PATH
+  IFS=$saved_IFS
+
+  local d d1
+  local colon=
+  local new_path=
+  for d in "$@"; do
+    test -z "$d" && d1=. || d1=$d
+    if ls -d "$d1/." > /dev/null 2>&1; then
+      new_path="$new_path$colon$d"
+      colon=':'
+    fi
+  done
+
+  for d in /sbin /usr/sbin ; do
+    case ":$new_path:" in
+      *:$d:*) ;;
+      *) new_path="$new_path:$d" ;;
+    esac
+  done
+
+  PATH=$new_path
+  export PATH
+}
+
 require_udevadm_settle_()
 {
   udevadm --help > /dev/null \
@@ -90,5 +125,7 @@ require_partitionable_loop_device_()
   esac
 }

+sanitize_path_
+
 . "$abs_top_srcdir/tests/t-lib-helpers.sh"
 . "$abs_top_srcdir/tests/t-local.sh"
diff --git a/tests/t9050-partition-table-types.sh 
b/tests/t9050-partition-table-types.sh
index 563b2e8..04dc5c6 100755
--- a/tests/t9050-partition-table-types.sh
+++ b/tests/t9050-partition-table-types.sh
@@ -41,7 +41,7 @@ dd if=/dev/null of=f bs=1 seek=30M || framework_failure_
 for i in $types; do
   for j in $types; do
     echo $i:$j
-    case $i in mkswap) mkswap f >/dev/null 2>&1 || fail=1;;
+    case $i in mkswap) mkswap f || fail=1;;
       *) parted -s f mklabel $i || fail=1;; esac
     case $j in mkswap) continue;; esac
     parted -s f mklabel $j || fail=1
--
1.7.9.1.266.g24ee9



reply via email to

[Prev in Thread] Current Thread [Next in Thread]