From 775965de859c6df5d5652f3f58edfd68803f0813 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 10 Aug 2010 23:33:57 -0700 Subject: [PATCH] Improved portability of tests Removed assumptions about umask and locale. Fixed hostname tests to work even when the host has no DNS domain set. Signed-off-by: Dan Fandrich Signed-off-by: Denys Vlasenko --- testsuite/cpio.tests | 2 ++ testsuite/date/date-works-1 | 3 +++ testsuite/du/du-k-works | 4 +++- testsuite/du/du-l-works | 3 +++ testsuite/hostname/hostname-d-works | 4 ++-- testsuite/makedevs.tests | 4 ++++ testsuite/tar.tests | 6 ++++++ testsuite/uuencode.tests | 3 +-- 8 files changed, 24 insertions(+), 5 deletions(-) diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests index 7aee774a1..44c17e693 100755 --- a/testsuite/cpio.tests +++ b/testsuite/cpio.tests @@ -4,6 +4,8 @@ . ./testing.sh +umask 022 + # ls -ln shows date. Need to remove that, it's variable. # sed: coalesce spaces # cut: remove date diff --git a/testsuite/date/date-works-1 b/testsuite/date/date-works-1 index e745d3841..cb5cea2c5 100644 --- a/testsuite/date/date-works-1 +++ b/testsuite/date/date-works-1 @@ -1,4 +1,7 @@ unset LANG +unset LANGUAGE +unset LC_TIME +unset LC_ALL dt=`busybox date -d 1:2 +%T` test x"$dt" = x"01:02:00" diff --git a/testsuite/du/du-k-works b/testsuite/du/du-k-works index a52264945..229a948ee 100644 --- a/testsuite/du/du-k-works +++ b/testsuite/du/du-k-works @@ -1,4 +1,6 @@ +mkdir du.testdir +cd du.testdir dd if=/dev/zero of=file1 bs=1k count=64 2>/dev/null dd if=/dev/zero of=file2 bs=1k count=16 2>/dev/null test x"`busybox du -k .`" = x"80 ." \ - -o x"`busybox du -k .`" = x"88 ." \ + -o x"`busybox du -k .`" = x"88 ." diff --git a/testsuite/du/du-l-works b/testsuite/du/du-l-works index 6b150e0dd..426ee891b 100644 --- a/testsuite/du/du-l-works +++ b/testsuite/du/du-l-works @@ -1,8 +1,11 @@ # FEATURE: CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K +mkdir du.testdir +cd du.testdir dd if=/dev/zero of=file1 bs=1k count=64 2>/dev/null ln file1 file1.1 dd if=/dev/zero of=file2 bs=1k count=16 2>/dev/null test x"`busybox du -l .`" = x"144 ." \ -o x"`busybox du -l .`" = x"148 ." \ -o x"`busybox du -l .`" = x"152 ." \ + -o x"`busybox du -l .`" = x"156 ." diff --git a/testsuite/hostname/hostname-d-works b/testsuite/hostname/hostname-d-works index e062242bb..54c0aac0c 100644 --- a/testsuite/hostname/hostname-d-works +++ b/testsuite/hostname/hostname-d-works @@ -1,3 +1,3 @@ -f=$(busybox hostname -f) +f=$(busybox hostname -f). d=$(busybox hostname -d) -test x"${f#*.}" = x"$d" +test x"${f#*.}" = x"$d${d:+.}" diff --git a/testsuite/makedevs.tests b/testsuite/makedevs.tests index f69b4a6b1..f19af8a52 100755 --- a/testsuite/makedevs.tests +++ b/testsuite/makedevs.tests @@ -4,6 +4,10 @@ . ./testing.sh +unset LANG +unset LC_COLLATE +unset LC_ALL + # ls -ln is showing date. Need to remove that, it's variable # sed: (1) "maj, min" -> "maj,min" (2) coalesce spaces # cut: remove date diff --git a/testsuite/tar.tests b/testsuite/tar.tests index f40079037..6604b4d22 100755 --- a/testsuite/tar.tests +++ b/testsuite/tar.tests @@ -4,6 +4,12 @@ . ./testing.sh +unset LANG +unset LANGUAGE +unset LC_COLLATE +unset LC_ALL +umask 022 + rm -rf tar.tempdir 2>/dev/null mkdir tar.tempdir && cd tar.tempdir || exit 1 diff --git a/testsuite/uuencode.tests b/testsuite/uuencode.tests index 6556e60d1..adb2d3390 100755 --- a/testsuite/uuencode.tests +++ b/testsuite/uuencode.tests @@ -13,11 +13,10 @@ # test can create a file "actual" instead of writing to stdout # Test setup of standard input -saved_umask=$(umask) umask 0 testing "uuencode sets standard input mode correctly" \ "uuencode foo 2!F;W@@:G5M<&5D(&]V97(@=&AE(&QA>GD@8G)O=VX@\n%9&]G+@H\`\n\`\nend\n" \