All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tests: test_md5 prints md5sum only
@ 2016-04-06 10:30 Ruediger Meier
  2016-04-06 10:30 ` [PATCH 2/2] tests: don't depend on GNU md5sum Ruediger Meier
  2016-04-06 12:26 ` [PATCH 1/2] tests: test_md5 prints md5sum only Karel Zak
  0 siblings, 2 replies; 10+ messages in thread
From: Ruediger Meier @ 2016-04-06 10:30 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

We want to to use it for other tests without depending on
gnu md5sum and without cut or awk.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 tests/expected/md5/md5   | 14 +++++++-------
 tests/helpers/test_md5.c |  2 +-
 tests/ts/md5/md5         |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/expected/md5/md5 b/tests/expected/md5/md5
index 6ca300b..d6559a7 100644
--- a/tests/expected/md5/md5
+++ b/tests/expected/md5/md5
@@ -1,7 +1,7 @@
-d41d8cd98f00b204e9800998ecf8427e  -
-900150983cd24fb0d6963f7d28e17f72  -
-5eb6d580e5f68fde65c3778afb8826ff  -
-bd1e13bdaab82581d4dc299eb9a3da0f  -
-d81ee4f567972a18f9326540b5d8aeaf  -
-9561bd208c0041c673080ed744919b85  -
-d98d58d5562ca4dd47f0f0fe86b2d48f  -
+d41d8cd98f00b204e9800998ecf8427e
+900150983cd24fb0d6963f7d28e17f72
+5eb6d580e5f68fde65c3778afb8826ff
+bd1e13bdaab82581d4dc299eb9a3da0f
+d81ee4f567972a18f9326540b5d8aeaf
+9561bd208c0041c673080ed744919b85
+d98d58d5562ca4dd47f0f0fe86b2d48f
diff --git a/tests/helpers/test_md5.c b/tests/helpers/test_md5.c
index 44f6a93..471580e 100644
--- a/tests/helpers/test_md5.c
+++ b/tests/helpers/test_md5.c
@@ -24,6 +24,6 @@ int main(void)
 
 	for (i = 0; i < MD5LENGTH; i++)
 		printf( "%02x", digest[i] );
-	printf("  -\n");
+	printf("\n");
 	return 0;
 }
diff --git a/tests/ts/md5/md5 b/tests/ts/md5/md5
index 6fe3f14..57c4d52 100755
--- a/tests/ts/md5/md5
+++ b/tests/ts/md5/md5
@@ -20,7 +20,7 @@ TS_TOPDIR="${0%/*}/../.."
 . $TS_TOPDIR/functions.sh
 ts_init "$*"
 
-> $TS_OUTPUT
+ts_check_test_command "$TS_HELPER_MD5"
 
 cat $TS_SELF/data | while read data
 do
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] tests: don't depend on GNU md5sum
  2016-04-06 10:30 [PATCH 1/2] tests: test_md5 prints md5sum only Ruediger Meier
@ 2016-04-06 10:30 ` Ruediger Meier
  2016-04-06 12:26 ` [PATCH 1/2] tests: test_md5 prints md5sum only Karel Zak
  1 sibling, 0 replies; 10+ messages in thread
From: Ruediger Meier @ 2016-04-06 10:30 UTC (permalink / raw)
  To: util-linux

From: Ruediger Meier <ruediger.meier@ga-group.nl>

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
---
 .travis-functions.sh            | 2 +-
 tests/expected/misc/rev         | 4 ++--
 tests/functions.sh              | 2 +-
 tests/ts/cramfs/fsck-endianness | 3 ++-
 tests/ts/cramfs/mkfs            | 3 ++-
 tests/ts/fdisk/mbr-dos-mode     | 1 +
 tests/ts/fdisk/mbr-nondos-mode  | 1 +
 tests/ts/fdisk/oddinput         | 1 +
 tests/ts/fdisk/sunlabel         | 1 +
 tests/ts/misc/rev               | 5 +++--
 tests/ts/mount/rlimit           | 3 ++-
 tests/ts/sfdisk/movedata        | 5 +++--
 12 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/.travis-functions.sh b/.travis-functions.sh
index fb58df2..2b369f1 100755
--- a/.travis-functions.sh
+++ b/.travis-functions.sh
@@ -129,7 +129,7 @@ function osx_prepare_check
 
 	# symlink minimally needed gnu commands into PATH
 	mkdir ~/bin
-	for cmd in md5sum readlink seq truncate find xargs tar sed; do
+	for cmd in readlink seq truncate find xargs tar sed; do
 		ln -s /usr/local/bin/g$cmd $HOME/bin/$cmd
 	done
 	hash -r
diff --git a/tests/expected/misc/rev b/tests/expected/misc/rev
index 41fdf4c..6387476 100644
--- a/tests/expected/misc/rev
+++ b/tests/expected/misc/rev
@@ -1,4 +1,4 @@
-53bbf0d98205319cee2ba589e205c68b  -
-35484965b7a2fd45a471c0d80cb9752c  -
+53bbf0d98205319cee2ba589e205c68b
+35484965b7a2fd45a471c0d80cb9752c
 cba
 321
\ No newline at end of file
diff --git a/tests/functions.sh b/tests/functions.sh
index 5246605..fe7ce6d 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -460,7 +460,7 @@ function ts_cleanup_on_exit {
 
 function ts_image_md5sum {
 	local img=${1:-"$TS_OUTDIR/${TS_TESTNAME}.img"}
-	echo $(md5sum "$img" | awk '{printf $1}') $(basename "$img")
+	echo $("$TS_HELPER_MD5" < "$img") $(basename "$img")
 }
 
 function ts_image_init {
diff --git a/tests/ts/cramfs/fsck-endianness b/tests/ts/cramfs/fsck-endianness
index d6d2ae3..db287f9 100755
--- a/tests/ts/cramfs/fsck-endianness
+++ b/tests/ts/cramfs/fsck-endianness
@@ -23,6 +23,7 @@ ts_init "$*"
 
 ts_check_test_command "$TS_CMD_MKCRAMFS"
 ts_check_test_command "$TS_CMD_FSCKCRAMFS"
+ts_check_test_command "$TS_HELPER_MD5"
 
 ts_skip_nonroot
 
@@ -45,7 +46,7 @@ test_image() {
 	$TS_CMD_MKCRAMFS -N "$TO_ENDIANNESS" -b 4096 "$IMAGE_DATA" \
 		"$IMAGE_CREATED" >> $TS_OUTPUT 2>&1
 
-	md5sum $IMAGE_CREATED | cut -d" " -f1 >> $TS_OUTPUT
+	"$TS_HELPER_MD5" < "$IMAGE_CREATED" >> $TS_OUTPUT
 
 	rm "$IMAGE_CREATED"
 }
diff --git a/tests/ts/cramfs/mkfs b/tests/ts/cramfs/mkfs
index cf6bcd6..d24b418 100755
--- a/tests/ts/cramfs/mkfs
+++ b/tests/ts/cramfs/mkfs
@@ -24,6 +24,7 @@ ts_init "$*"
 ts_check_test_command "$TS_CMD_MKCRAMFS"
 ts_check_test_command "$TS_CMD_MOUNT"
 ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_HELPER_MD5"
 
 ts_skip_nonroot
 ts_check_losetup
@@ -75,7 +76,7 @@ $TS_CMD_MKCRAMFS -n $LABEL $IMAGE_SRC $IMAGE_PATH >> $TS_OUTPUT 2>&1
 ts_cd "$TS_OUTDIR"
 
 ts_log "count MD5 from the image"
-MD5_OUT=$(md5sum "$IMAGE_NAME" | awk '{printf $1}') >> $TS_OUTPUT 2>&1
+MD5_OUT=$("$TS_HELPER_MD5" < "$IMAGE_NAME") >> $TS_OUTPUT 2>&1
 if [ "$MD5_EXP" != "$MD5_OUT" -a "$MD5_EXP" != "unknown" ]; then
 	ts_log "is $MD5_OUT, should be $MD5_EXP"
 fi
diff --git a/tests/ts/fdisk/mbr-dos-mode b/tests/ts/fdisk/mbr-dos-mode
index 4fad8da..219df2f 100755
--- a/tests/ts/fdisk/mbr-dos-mode
+++ b/tests/ts/fdisk/mbr-dos-mode
@@ -23,6 +23,7 @@ TS_DESC="MBR - dos mode"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_HELPER_MD5"
 
 FDISK_CMD_INIT="x\ni\n0x1\nr\n"
 FDISK_CMD_WRITE_CLOSE="w\nq\n"
diff --git a/tests/ts/fdisk/mbr-nondos-mode b/tests/ts/fdisk/mbr-nondos-mode
index f39b5e0..e01b060 100755
--- a/tests/ts/fdisk/mbr-nondos-mode
+++ b/tests/ts/fdisk/mbr-nondos-mode
@@ -21,6 +21,7 @@ TS_DESC="MBR - non-dos mode"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_HELPER_MD5"
 
 # cmd to changes system id to 0x1
 FDISK_CMD_INIT="x\ni\n0x1\nr\n"
diff --git a/tests/ts/fdisk/oddinput b/tests/ts/fdisk/oddinput
index 6625d25..0679242 100755
--- a/tests/ts/fdisk/oddinput
+++ b/tests/ts/fdisk/oddinput
@@ -21,6 +21,7 @@ TS_DESC="invalid input tests"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_HELPER_MD5"
 
 #set -x
 
diff --git a/tests/ts/fdisk/sunlabel b/tests/ts/fdisk/sunlabel
index 5bfbb4f..d6b1033 100755
--- a/tests/ts/fdisk/sunlabel
+++ b/tests/ts/fdisk/sunlabel
@@ -21,6 +21,7 @@ TS_DESC="sunlabel tests"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_HELPER_MD5"
 
 FDISK_CMD_INIT="s\n" # create new sunlabel
 FDISK_CMD_WRITE_CLOSE="w\nq\n"
diff --git a/tests/ts/misc/rev b/tests/ts/misc/rev
index a3d45e6..3a541ac 100755
--- a/tests/ts/misc/rev
+++ b/tests/ts/misc/rev
@@ -19,11 +19,12 @@ TS_DESC="rev"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_REV"
+ts_check_test_command "$TS_HELPER_MD5"
 
-for I in {0..512}; do printf "%s " {a..z}; done | md5sum >> $TS_OUTPUT 2>&1
+for I in {0..512}; do printf "%s " {a..z}; done | "$TS_HELPER_MD5" >> $TS_OUTPUT 2>&1
 
 for I in {0..512}; do printf "%s " {a..z}; done | \
-				    $TS_CMD_REV | md5sum >> $TS_OUTPUT 2>&1
+				    $TS_CMD_REV | "$TS_HELPER_MD5" >> $TS_OUTPUT 2>&1
 
 printf "abc\n123" | $TS_CMD_REV >> $TS_OUTPUT 2>&1
 
diff --git a/tests/ts/mount/rlimit b/tests/ts/mount/rlimit
index 8469084..d6a64ec 100755
--- a/tests/ts/mount/rlimit
+++ b/tests/ts/mount/rlimit
@@ -31,6 +31,7 @@ ts_init "$*"
 
 ts_check_test_command "$TS_CMD_MOUNT"
 ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_HELPER_MD5"
 
 ts_skip_nonroot
 ts_check_losetup
@@ -41,7 +42,7 @@ ts_check_prog "mkfs.ext3"
 
 function mtab_checksum()
 {
-	md5sum /etc/mtab | awk '{printf $1}'
+	"$TS_HELPER_MD5" < /etc/mtab
 }
 
 ts_device_init
diff --git a/tests/ts/sfdisk/movedata b/tests/ts/sfdisk/movedata
index d37f72a..64c7371 100755
--- a/tests/ts/sfdisk/movedata
+++ b/tests/ts/sfdisk/movedata
@@ -22,6 +22,7 @@ TS_DESC="movedata"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_SFDISK"
+ts_check_test_command "$TS_HELPER_MD5"
 
 ts_skip_nonroot
 ts_check_prog "mkfs.ext4"
@@ -35,11 +36,11 @@ udevadm settle
 
 mkfs.ext4 ${TS_DEVICE}1 &> /dev/null
 udevadm settle
-CHECKSUM=$(md5sum ${TS_DEVICE}1 | awk '{print $1}')
+CHECKSUM=$("$TS_HELPER_MD5" < "${TS_DEVICE}1")
 
 function checksum() {
 	local dev="$1"
-	CHECK=$(md5sum ${dev} | awk '{print $1}')
+	CHECK=$("$TS_HELPER_MD5" < "${dev}")
 	if [ "$CHECKSUM" != "$CHECK" ]; then
 		echo "Checksum does not match!" >> $TS_OUTPUT
 	fi
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 10:30 [PATCH 1/2] tests: test_md5 prints md5sum only Ruediger Meier
  2016-04-06 10:30 ` [PATCH 2/2] tests: don't depend on GNU md5sum Ruediger Meier
@ 2016-04-06 12:26 ` Karel Zak
  2016-04-06 12:33   ` Ruediger Meier
  1 sibling, 1 reply; 10+ messages in thread
From: Karel Zak @ 2016-04-06 12:26 UTC (permalink / raw)
  To: Ruediger Meier; +Cc: util-linux

On Wed, Apr 06, 2016 at 12:30:17PM +0200, Ruediger Meier wrote:
> We want to to use it for other tests without depending on
> gnu md5sum and without cut or awk.

It does not seem like anything critical, both patches applied to the
next branch (will be in v2.29). Thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 12:26 ` [PATCH 1/2] tests: test_md5 prints md5sum only Karel Zak
@ 2016-04-06 12:33   ` Ruediger Meier
  2016-04-06 16:40     ` Isaac Dunham
  0 siblings, 1 reply; 10+ messages in thread
From: Ruediger Meier @ 2016-04-06 12:33 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

On Wednesday 06 April 2016, Karel Zak wrote:
> On Wed, Apr 06, 2016 at 12:30:17PM +0200, Ruediger Meier wrote:
> > We want to to use it for other tests without depending on
> > gnu md5sum and without cut or awk.
>
> It does not seem like anything critical, both patches applied to the
> next branch (will be in v2.29). Thanks.

That's ok. These patches do not fix any existing problem yet. They are 
just one minor step to remove coreutils dependency from out tests. We 
would still need to fix usage of readlink, seq and truncate. 

cu,
Rudi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 12:33   ` Ruediger Meier
@ 2016-04-06 16:40     ` Isaac Dunham
  2016-04-06 17:40       ` Ruediger Meier
  0 siblings, 1 reply; 10+ messages in thread
From: Isaac Dunham @ 2016-04-06 16:40 UTC (permalink / raw)
  To: Ruediger Meier; +Cc: Karel Zak, util-linux

On Wed, Apr 06, 2016 at 01:33:58PM +0100, Ruediger Meier wrote:
> On Wednesday 06 April 2016, Karel Zak wrote:
> > On Wed, Apr 06, 2016 at 12:30:17PM +0200, Ruediger Meier wrote:
> > > We want to to use it for other tests without depending on
> > > gnu md5sum and without cut or awk.
> >
> > It does not seem like anything critical, both patches applied to the
> > next branch (will be in v2.29). Thanks.
> 
> That's ok. These patches do not fix any existing problem yet. They are 
> just one minor step to remove coreutils dependency from out tests. We 
> would still need to fix usage of readlink, seq and truncate. 

Is this for the sake of something where you cannot expect *any*
coreutils-equivalent to be installed?
If you can't expect that, can you expect the build scripts to work?

I ask because md5sum, seq, and readlink are included in every set of
base utilities I'm aware of, including coreutils, busybox, toybox,
and even sbase (the 'suckless' base utilities).
That said, seq and md5sum are only specified in the LSB, and readlink
isn't even there.

Thanks,
Isaac Dunham


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 16:40     ` Isaac Dunham
@ 2016-04-06 17:40       ` Ruediger Meier
  2016-04-06 21:11         ` Ruediger Meier
  2016-04-06 21:38         ` Isaac Dunham
  0 siblings, 2 replies; 10+ messages in thread
From: Ruediger Meier @ 2016-04-06 17:40 UTC (permalink / raw)
  To: Isaac Dunham; +Cc: Karel Zak, util-linux

On Wednesday 06 April 2016, Isaac Dunham wrote:
> On Wed, Apr 06, 2016 at 01:33:58PM +0100, Ruediger Meier wrote:
> > On Wednesday 06 April 2016, Karel Zak wrote:
> > > On Wed, Apr 06, 2016 at 12:30:17PM +0200, Ruediger Meier wrote:
> > > > We want to to use it for other tests without depending on
> > > > gnu md5sum and without cut or awk.
> > >
> > > It does not seem like anything critical, both patches applied to
> > > the next branch (will be in v2.29). Thanks.
> >
> > That's ok. These patches do not fix any existing problem yet. They
> > are just one minor step to remove coreutils dependency from out
> > tests. We would still need to fix usage of readlink, seq and
> > truncate.
>
> Is this for the sake of something where you cannot expect *any*
> coreutils-equivalent to be installed?
> If you can't expect that, can you expect the build scripts to work?

Yes, autoconf/automake/libtool generate highly portable shell scripts. 
For example the configure script even checks whether there is a 
thread-safe "mkdir -p" available or what kind of sed is installed.

The only problems are usually caused by hand-written scripts like shell 
snippets in Makefile.am or our test scripts ;)

Our tests depend on GNU extensions for md5sum, readlink, seq, truncate, 
find,  xargs, tar, sed and the shell has to be bash. That's all not 
critical but at least nice to be fixed if it doesn't make our scripts 
too ugly. 

> I ask because md5sum, seq, and readlink are included in every set of
> base utilities I'm aware of, including coreutils, busybox, toybox,
> and even sbase (the 'suckless' base utilities).
> That said, seq and md5sum are only specified in the LSB, and readlink
> isn't even there.

md5sum is special. It's not Posix and not available or completely 
different on non-Linux systems.

About seq, readlink and truncate: our test-suite is using non-portable 
GNU extenstions. I guess it would not run with busybox. You can 
similate that even with coreutils:

$ POSIXLY_CORRECT=1 make check

I you feel boring you may try to fix some of the mentioned GNUisms ;)

cu,
Rudi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 17:40       ` Ruediger Meier
@ 2016-04-06 21:11         ` Ruediger Meier
  2016-04-06 21:38         ` Isaac Dunham
  1 sibling, 0 replies; 10+ messages in thread
From: Ruediger Meier @ 2016-04-06 21:11 UTC (permalink / raw)
  To: Isaac Dunham; +Cc: Karel Zak, util-linux

On Wednesday 06 April 2016, Ruediger Meier wrote:
> On Wednesday 06 April 2016, Isaac Dunham wrote:
> > On Wed, Apr 06, 2016 at 01:33:58PM +0100, Ruediger Meier wrote:
> > > On Wednesday 06 April 2016, Karel Zak wrote:
> > > > On Wed, Apr 06, 2016 at 12:30:17PM +0200, Ruediger Meier wrote:
> > > > > We want to to use it for other tests without depending on
> > > > > gnu md5sum and without cut or awk.
> > > >
> > > > It does not seem like anything critical, both patches applied
> > > > to the next branch (will be in v2.29). Thanks.
> > >
> > > That's ok. These patches do not fix any existing problem yet.
> > > They are just one minor step to remove coreutils dependency from
> > > out tests. We would still need to fix usage of readlink, seq and
> > > truncate.
> >
> > Is this for the sake of something where you cannot expect *any*
> > coreutils-equivalent to be installed?
> > If you can't expect that, can you expect the build scripts to work?
>
> Yes, autoconf/automake/libtool generate highly portable shell
> scripts. For example the configure script even checks whether there
> is a thread-safe "mkdir -p" available or what kind of sed is
> installed.
>
> The only problems are usually caused by hand-written scripts like
> shell snippets in Makefile.am or our test scripts ;)
>
> Our tests depend on GNU extensions for md5sum, readlink, seq,
> truncate, find,  xargs, tar, sed and the shell has to be bash. That's
> all not critical but at least nice to be fixed if it doesn't make our
> scripts too ugly.
>
> > I ask because md5sum, seq, and readlink are included in every set
> > of base utilities I'm aware of, including coreutils, busybox,
> > toybox, and even sbase (the 'suckless' base utilities).
> > That said, seq and md5sum are only specified in the LSB, and
> > readlink isn't even there.
>
> md5sum is special. It's not Posix and not available or completely
> different on non-Linux systems.

Just to clarify. I wouldn't have done this patch like this for other 
projects but here in util-linux we have our own (portable) test_md5 
already since 2008. So why not using it to avoid one more GNUism!

> About seq, readlink and truncate: our test-suite is using
> non-portable GNU extenstions. I guess it would not run with busybox.
> You can similate that even with coreutils:
>
> $ POSIXLY_CORRECT=1 make check
>
> I you feel boring you may try to fix some of the mentioned GNUisms ;)
>
> cu,
> Rudi
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 17:40       ` Ruediger Meier
  2016-04-06 21:11         ` Ruediger Meier
@ 2016-04-06 21:38         ` Isaac Dunham
  2016-04-06 22:36           ` Ruediger Meier
  1 sibling, 1 reply; 10+ messages in thread
From: Isaac Dunham @ 2016-04-06 21:38 UTC (permalink / raw)
  To: Ruediger Meier; +Cc: Karel Zak, util-linux

On Wed, Apr 06, 2016 at 06:40:21PM +0100, Ruediger Meier wrote:
> On Wednesday 06 April 2016, Isaac Dunham wrote:
> > On Wed, Apr 06, 2016 at 01:33:58PM +0100, Ruediger Meier wrote:
> > > On Wednesday 06 April 2016, Karel Zak wrote:
> > > > On Wed, Apr 06, 2016 at 12:30:17PM +0200, Ruediger Meier wrote:
> > > > > We want to to use it for other tests without depending on
> > > > > gnu md5sum and without cut or awk.
> > > >
> > > > It does not seem like anything critical, both patches applied to
> > > > the next branch (will be in v2.29). Thanks.
> > >
> > > That's ok. These patches do not fix any existing problem yet. They
> > > are just one minor step to remove coreutils dependency from out
> > > tests. We would still need to fix usage of readlink, seq and
> > > truncate.
> >
> > Is this for the sake of something where you cannot expect *any*
> > coreutils-equivalent to be installed?
> > If you can't expect that, can you expect the build scripts to work?
> 
> Yes, autoconf/automake/libtool generate highly portable shell scripts. 
> For example the configure script even checks whether there is a 
> thread-safe "mkdir -p" available or what kind of sed is installed.

Ah yes, I should have remembered that it checks that. ;)
http://lists.busybox.net/pipermail/busybox/2004-January/044642.html
(The test is for "GNU sed version ..." rather than behavior.)

> The only problems are usually caused by hand-written scripts like shell 
> snippets in Makefile.am or our test scripts ;)
> 
> Our tests depend on GNU extensions for md5sum, readlink, seq, truncate, 
> find,  xargs, tar, sed and the shell has to be bash. That's all not 
> critical but at least nice to be fixed if it doesn't make our scripts 
> too ugly. 
>
> > I ask because md5sum, seq, and readlink are included in every set of
> > base utilities I'm aware of, including coreutils, busybox, toybox,
> > and even sbase (the 'suckless' base utilities).
> > That said, seq and md5sum are only specified in the LSB, and readlink
> > isn't even there.
> 
> md5sum is special. It's not Posix and not available or completely 
> different on non-Linux systems.

Ah yes. Somehow I keep forgetting that util-linux needs to worry about
non-linux systems.
As far as I can tell, the BSDs use 'md5', which approximates the desired
output when run as 'md5 -r'; but your approach is better than trying
to coerce suitable output from diverse programs.
 
> About seq, readlink and truncate: our test-suite is using non-portable 
> GNU extenstions. I guess it would not run with busybox. You can 
> similate that even with coreutils:
> 
> $ POSIXLY_CORRECT=1 make check

grep -rw seq tests/ reports only a series of invocations that resolve to
'seq $START $END'; however, one or two of them will probably break due
to the shell not working the same (parameter subsitution inside shell
aritmetic inside $().).
Similarly, -f is the only readlink option that seems to be used.
(Busybox supports this.)
Trying to run "make check", however, runs into busybox xargs not
supporting -P (needed for parallel tests).
truncate is not POSIX, but it's relatively new.

> If you feel bored you may try to fix some of the mentioned GNUisms ;)

I might.
Most likely, the biggest issue is bash.


Thanks,
Isaac


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 21:38         ` Isaac Dunham
@ 2016-04-06 22:36           ` Ruediger Meier
  2016-04-07  7:45             ` Karel Zak
  0 siblings, 1 reply; 10+ messages in thread
From: Ruediger Meier @ 2016-04-06 22:36 UTC (permalink / raw)
  To: Isaac Dunham; +Cc: Karel Zak, util-linux

On Wednesday 06 April 2016, Isaac Dunham wrote:
> On Wed, Apr 06, 2016 at 06:40:21PM +0100, Ruediger Meier wrote:
> > On Wednesday 06 April 2016, Isaac Dunham wrote:
> > > On Wed, Apr 06, 2016 at 01:33:58PM +0100, Ruediger Meier wrote:
> > > > On Wednesday 06 April 2016, Karel Zak wrote:
> > > > > On Wed, Apr 06, 2016 at 12:30:17PM +0200, Ruediger Meier 
wrote:
> > > > > > We want to to use it for other tests without depending on
> > > > > > gnu md5sum and without cut or awk.
> > > > >
> > > > > It does not seem like anything critical, both patches applied
> > > > > to the next branch (will be in v2.29). Thanks.
> > > >
> > > > That's ok. These patches do not fix any existing problem yet.
> > > > They are just one minor step to remove coreutils dependency
> > > > from out tests. We would still need to fix usage of readlink,
> > > > seq and truncate.
> > >
> > > Is this for the sake of something where you cannot expect *any*
> > > coreutils-equivalent to be installed?
> > > If you can't expect that, can you expect the build scripts to
> > > work?
> >
> > Yes, autoconf/automake/libtool generate highly portable shell
> > scripts. For example the configure script even checks whether there
> > is a thread-safe "mkdir -p" available or what kind of sed is
> > installed.
>
> Ah yes, I should have remembered that it checks that. ;)
> http://lists.busybox.net/pipermail/busybox/2004-January/044642.html
> (The test is for "GNU sed version ..." rather than behavior.)
>
> > The only problems are usually caused by hand-written scripts like
> > shell snippets in Makefile.am or our test scripts ;)
> >
> > Our tests depend on GNU extensions for md5sum, readlink, seq,
> > truncate, find,  xargs, tar, sed and the shell has to be bash.
> > That's all not critical but at least nice to be fixed if it doesn't
> > make our scripts too ugly.
> >
> > > I ask because md5sum, seq, and readlink are included in every set
> > > of base utilities I'm aware of, including coreutils, busybox,
> > > toybox, and even sbase (the 'suckless' base utilities).
> > > That said, seq and md5sum are only specified in the LSB, and
> > > readlink isn't even there.
> >
> > md5sum is special. It's not Posix and not available or completely
> > different on non-Linux systems.
>
> Ah yes. Somehow I keep forgetting that util-linux needs to worry
> about non-linux systems.

I have to admit that IMO it would be ok to skip non-Linux support but 
personally I like portability and sometimes runs on other systems 
discovers theoretical or future bugs even for the major Linux target.

> As far as I can tell, the BSDs use 'md5', which approximates the
> desired output when run as 'md5 -r'; but your approach is better than
> trying to coerce suitable output from diverse programs.
>
> > About seq, readlink and truncate: our test-suite is using
> > non-portable GNU extenstions. I guess it would not run with
> > busybox. You can similate that even with coreutils:
> >
> > $ POSIXLY_CORRECT=1 make check
>
> grep -rw seq tests/ reports only a series of invocations that resolve
> to 'seq $START $END';

Yep, I've grepped that too a few hours ago. But I know for sure that our 
seq usage did not worked on OSX a few weeks ago. Maybe we've used float 
increment a some commits ago .. I don't remember.

> however, one or two of them will probably break 
> due to the shell not working the same (parameter subsitution inside
> shell aritmetic inside $().).
> Similarly, -f is the only readlink option that seems to be used.
> (Busybox supports this.)

Unfortunately readlink -f is the most useful option of readlink. But 
probably we wouldn't need it always where we are using it right now.

> Trying to run "make check", however, runs into busybox xargs not
> supporting -P (needed for parallel tests).

Could be fixed by checking for xargs -P on runtime, disable parallel 
tests otherwhise. But AFAIR missing xargs -r was also an issue.

Generally I remember there are issues with find and xargs don't behave 
like Posix on all non-Unix systems. So for now it was easier to simply 
require well defined GNU findutils.

> truncate is not POSIX, but it's relatively new.

Could be re-replaced by dd but would be nice to check if it keeps the 
files sparse (dd seek=x).

> > If you feel bored you may try to fix some of the mentioned GNUisms
> > ;)
>
> I might.
> Most likely, the biggest issue is bash.

At least we explicitly require bash in the shebang. Maybe we could use
#!/usr/bin/env bash
.. to make it easier on systems where is no bash in /bin

Making test scripts portable to /bin/sh would be really annoying I 
guess. Installing bash-4 is IMO much easier for the users than fixing 
all the other issues (coreutils, findutils, sed, tar). BTW our awk 
usage seems to be ok right now.

cu,
Rudi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] tests: test_md5 prints md5sum only
  2016-04-06 22:36           ` Ruediger Meier
@ 2016-04-07  7:45             ` Karel Zak
  0 siblings, 0 replies; 10+ messages in thread
From: Karel Zak @ 2016-04-07  7:45 UTC (permalink / raw)
  To: Ruediger Meier; +Cc: Isaac Dunham, util-linux

On Thu, Apr 07, 2016 at 12:36:47AM +0200, Ruediger Meier wrote:
> > however, one or two of them will probably break 
> > due to the shell not working the same (parameter subsitution inside
> > shell aritmetic inside $().).
> > Similarly, -f is the only readlink option that seems to be used.
> > (Busybox supports this.)
> 
> Unfortunately readlink -f is the most useful option of readlink. But 
> probably we wouldn't need it always where we are using it right now.

BTW, we have lib/canonicalize.c, so write replacement for readlink -f
for our tests is trivial.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-04-07  7:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-06 10:30 [PATCH 1/2] tests: test_md5 prints md5sum only Ruediger Meier
2016-04-06 10:30 ` [PATCH 2/2] tests: don't depend on GNU md5sum Ruediger Meier
2016-04-06 12:26 ` [PATCH 1/2] tests: test_md5 prints md5sum only Karel Zak
2016-04-06 12:33   ` Ruediger Meier
2016-04-06 16:40     ` Isaac Dunham
2016-04-06 17:40       ` Ruediger Meier
2016-04-06 21:11         ` Ruediger Meier
2016-04-06 21:38         ` Isaac Dunham
2016-04-06 22:36           ` Ruediger Meier
2016-04-07  7:45             ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.