From 58500b80290563a5cdc68dc296eaec4d9229b8e5 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 6 Jan 2025 09:47:13 -0600 Subject: [PATCH] Adjust various tests to pass on TEST_HOST debian bookworm. --- scripts/runtest.sh | 4 +++- tests/cut.test | 6 +++--- tests/echo.test | 2 +- tests/factor.test | 4 ++-- tests/file.test | 20 +++++++++++--------- tests/hexdump.test | 1 + tests/iconv.test | 2 +- tests/sed.test | 1 + tests/test.test | 7 +++---- 9 files changed, 26 insertions(+), 21 deletions(-) diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 1289d4c6..b1e70768 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -102,7 +102,9 @@ skipnot() # Skip this test (rest of command line) when not running toybox. toyonly() { - IS_TOYBOX="$("$C" --version 2>/dev/null)" + [ -z "$TEST_HOST" ] && IS_TOYBOX=toybox + : ${IS_TOYBOX:=$("$C" --version 2>/dev/null | grep -o toybox)} \ + ${IS_TOYBOX:="$(basename $(readlink -f "$C"))"} # Ideally we'd just check for "toybox", but toybox sed lies to make autoconf # happy, so we have at least two things to check for. case "$IS_TOYBOX" in diff --git a/tests/cut.test b/tests/cut.test index c354b9b2..83dbbd2f 100755 --- a/tests/cut.test +++ b/tests/cut.test @@ -18,7 +18,7 @@ testcmd "-b overlaps" "-b 1-3,2-5,7-9,9-10 abc.txt" \ "one:to:th\nalphabeta\nthe qick \n" "" "" testcmd "-b encapsulated" "-b 3-8,4-6 abc.txt" "e:two:\npha:be\ne quic\n" \ "" "" -testcmd "-bO overlaps" "-O ' ' -b 1-3,2-5,7-9,9-10 abc.txt" \ +toyonly testcmd "-bO overlaps" "-O ' ' -b 1-3,2-5,7-9,9-10 abc.txt" \ "one:t o:th\nalpha beta\nthe q ick \n" "" "" testcmd "high-low error" "-b 8-3 abc.txt 2>/dev/null || echo err" "err\n" \ "" "" @@ -36,7 +36,7 @@ toyonly testcmd "-c japan.txt" '-c 3-6,9-12 "$FILES/utf8/japan.txt"' \ toyonly testcmd "-C test1.txt" '-C -1 "$FILES/utf8/test1.txt"' "l̴̗̞̠\n" "" "" # substitute for awk -testcmd "-DF" "-DF 2,7,5" \ +toyonly testcmd "-DF" "-DF 2,7,5" \ "said and your\nare\nis demand. supply\nforecast :\nyou you better,\n\nEm: Took hate\n" "" \ "Bother, said Pooh. It's your husband, and he has a gun. Cheerios are donut seeds. @@ -45,7 +45,7 @@ Weather forecast for tonight : dark. Apple: you can buy better, but you can't pay more. Subcalifragilisticexpialidocious. Auntie Em: Hate you, hate Kansas. Took the dog. Dorothy." -testcmd "-DF 2" "-DF 7,1,3-6,2-5" \ +toyonly testcmd "-DF 2" "-DF 7,1,3-6,2-5" \ "seven one three four five six two three four five\n" "" \ "one two three four five six seven eight nine\n" diff --git a/tests/echo.test b/tests/echo.test index bd2c3ff7..fef5db90 100755 --- a/tests/echo.test +++ b/tests/echo.test @@ -46,7 +46,7 @@ testcmd "-e \p" "-e '\\p'" "\\p\n" "" "" testcmd "-En" "-En 'one\ntwo'" 'one\\ntwo' "" "" testcmd "-eE" "-eE '\e'" '\\e\n' "" "" -# This is how bash's built-in echo behaves, but now how /bin/echo behaves. +# This is how bash's built-in echo behaves, but not how /bin/echo behaves. toyonly testcmd "" "-e 'a\x123\ufb3bbc' | od -An -tx1" \ " 61 12 33 ef ac bb 62 63 0a\n" "" "" diff --git a/tests/factor.test b/tests/factor.test index 90151851..eb861f4f 100755 --- a/tests/factor.test +++ b/tests/factor.test @@ -20,8 +20,8 @@ testing "10000000019" "factor 10000000019" \ testing "3 6 from stdin" "factor" "3: 3\n6: 2 3\n" "" "3 6" testing "stdin newline" "factor" "3: 3\n6: 2 3\n" "" "3\n6\n" -testing "-h" "factor -h $(((1<<63)-26))" \ +toyonly testing "-h" "factor -h $(((1<<63)-26))" \ "9223372036854775782: 2 3^4 17 23 319279 456065899\n" "" "" -testing "-x" "factor -x $(((1<<63)-20))" \ +toyonly testing "-x" "factor -x $(((1<<63)-20))" \ "7fffffffffffffec: 2 2 3 283 43f2ba978e663\n" "" "" diff --git a/tests/file.test b/tests/file.test index 8dddfe3f..e87d5a3a 100755 --- a/tests/file.test +++ b/tests/file.test @@ -24,12 +24,12 @@ rm -f empty testing "script" "file input | grep -o ' script'" " script\n" "#!/bin/bash\n" "" testing "script with spaces" "file input | grep -o ' script'" " script\n" \ "#! /bin/bash\n" "" -testing "env script" "file input | egrep -o '(python|script)' | sort" \ +testing "env script" "file input | tr P p | egrep -o '(python|script)' | sort" \ "python\nscript\n" "#! /usr/bin/env python\n" "" testing "ascii" "file input" "input: ASCII text\n" "Hello, world!\n" "" testing "utf-8" \ - "file \"$FILES\"/utf8/japan.txt | egrep -o '(UTF-8|text)' | LANG=c sort" \ - "UTF-8\ntext\n" "" "" + "file \"$FILES\"/utf8/japan.txt | egrep -o 'UTF-8 text' | LANG=c sort" \ + "UTF-8 text\n" "" "" # TODO each of these has multiple options we could test testing "java class" \ @@ -37,8 +37,9 @@ testing "java class" \ "Java class\nversion 53.0\n" "" "" echo "cafebabe000000020100000700000003000040000000d9300000000e0100000c8000000200014000000098500000000e" | xxd -r -p > universal -testcmd "mach-o universal" "universal" \ - "universal: Mach-O universal binary with 2 architectures: [x86_64] [arm64]\n" "" "" +testcmd "mach-o universal" \ + "universal | egrep -o '(Mach-O|universal|x86_64|arm64)' | sort -u" \ + "Mach-O\narm64\nuniversal\nx86_64\n" "" "" rm universal test_line "tar file" "tar/tar.tar" "POSIX tar archive (GNU)\n" "" "" @@ -65,13 +66,14 @@ rm -f android.dex # These actually test a lot of the ELF code: 32-/64-bit, arm/arm64, PT_INTERP, # the two kinds of NDK ELF note, BuildID, and stripped/not stripped. toyonly test_line "Android NDK full ELF note" "elf/ndk-elf-note-full" \ - "ELF shared object, 64-bit LSB arm64, dynamic (/system/bin/linker64), for Android 24, built by NDK r19b (5304403), BuildID=0c712b8af424d57041b85326f0000fadad38ee0a, not stripped\n" "" "" + "ELF shared object, 64-bit LSB arm64, dynamic (/system/bin/linker64), for Android 24, built by NDK r19b (5304403), BuildID=0c712b8af424d57041b85326f0000fadad38ee0a, not stripped\n" "" "" toyonly test_line "Android NDK short ELF note" "elf/ndk-elf-note-short" \ - "ELF shared object, 32-bit LSB arm, EABI5, soft float, dynamic (/system/bin/linker), for Android 28, BuildID=da6a5f4ca8da163b9339326e626d8a3c, stripped\n" "" "" + "ELF shared object, 32-bit LSB arm, EABI5, soft float, dynamic (/system/bin/linker), for Android 28, BuildID=da6a5f4ca8da163b9339326e626d8a3c, stripped\n" "" "" toyonly test_line "ELF static fdpic" "elf/fdstatic" \ - "ELF executable (fdpic), 32-bit MSB sh, static, stripped\n" "" "" + "ELF executable (fdpic), 32-bit MSB sh, static, stripped\n" "" "" echo -ne '\x7fELF\00000000000000000000000000000000000000000000' > bad-bits -testing "ELF bad bits" "file bad-bits" "bad-bits: ELF (bad type 12336), (bad class -1) (bad endian 48) unknown arch 12336\n" "" "" +testing "ELF bad bits" "file bad-bits | egrep -o '(ELF|unknown)'" \ + "ELF\nunknown\n" "" "" rm -f bad-bits testing "broken symlink" "file dangler" "dangler: broken symbolic link to $BROKEN\n" "" "" diff --git a/tests/hexdump.test b/tests/hexdump.test index e319957c..1a2955f8 100755 --- a/tests/hexdump.test +++ b/tests/hexdump.test @@ -2,6 +2,7 @@ [ -f testing.sh ] && . testing.sh +[ -n "$TEST_HOST" ] && NOSPACE=1 testcmd "simple file" "input" "0000000 6973 706d 656c 000a\n0000007\n" "simple\\n" "" testcmd "simple file -b" "-b input" "0000000 163 151 155 160 154 145 012\n0000007\n" "simple\\n" "" testcmd "simple file -c" "-c input" "0000000 s i m p l e \\\\n\n0000007\n" "simple\\n" "" diff --git a/tests/iconv.test b/tests/iconv.test index d0a3cb1d..39718f5c 100755 --- a/tests/iconv.test +++ b/tests/iconv.test @@ -10,7 +10,7 @@ echo -ne "\x24\xe2\x82\xac\xf0\x90\x90\xb7" > chars #testing "name" "command" "result" "infile" "stdin" - +utf8locale testing "" "iconv chars | xxd -p" "24e282acf09090b7\n" "" "" testing "-t UTF-16BE" "iconv -t UTF-16BE chars | xxd -p" "002420acd801dc37\n" "" "" testing "-t UTF-16LE" "iconv -t UTF-16LE chars | xxd -p" "2400ac2001d837dc\n" "" "" diff --git a/tests/sed.test b/tests/sed.test index ce35161f..06fec59b 100755 --- a/tests/sed.test +++ b/tests/sed.test @@ -191,6 +191,7 @@ testcmd '\n too high' '-E "s/(.*)/\2/p" 2>/dev/null || echo OK' "OK\n" "" "foo" toyonly testcmd 's///x' '"s/(hello )?(world)/\2/x"' "world" "" "hello world" +SKIP=1 # Performance test X=x; Y=20; while [ $Y -gt 0 ]; do X=$X$X; Y=$(($Y-1)); done testing 'megabyte s/x/y/g (20 sec timeout)' \ diff --git a/tests/test.test b/tests/test.test index a40902d3..d8808a2d 100644 --- a/tests/test.test +++ b/tests/test.test @@ -135,11 +135,10 @@ testing "<2" 'test def \< abc || echo yes' "yes\n" "" "" testing ">1" 'test abc \> def || echo yes' "yes\n" "" "" testing ">2" 'test def \> abc && echo yes' "yes\n" "" "" -# toyonly doesn't work with TOYFLAG_NOHELP # bash only has this for [[ ]] but extra tests to _exclude_ silly... -#toyonly testcmd "=~" 'abc =~ a.c && echo yes' "yes\n" "" "" -#toyonly testcmd "=~ fail" 'abc =~ d.c; echo $?' '1\n' "" "" -#toyonly testcmd "=~ zero length match" 'abc =~ "1*" && echo yes' 'yes\n' '' '' +toyonly testcmd "=~" 'abc =~ a.c && echo yes' "yes\n" "" "" +toyonly testcmd "=~ fail" 'abc =~ d.c; echo $?' '1\n' "" "" +toyonly testcmd "=~ zero length match" 'abc =~ "1*" && echo yes' 'yes\n' '' '' # test ! = -o a # test ! \( = -o a \) -- 2.39.5