From 73b16af8feec390afbabd9356d6e5e83c0390838 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Fri, 15 May 2015 10:20:47 +0200 Subject: busybox: imported from http://www.busybox.net/downloads/busybox-1.13.3.tar.bz2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- testsuite/README | 33 ++ testsuite/TODO | 26 + testsuite/all_sourcecode.tests | 92 ++++ testsuite/awk.tests | 32 ++ testsuite/awk_t1.tar.bz2 | Bin 0 -> 15955 bytes .../basename-does-not-remove-identical-extension | 1 + testsuite/basename/basename-works | 2 + testsuite/bunzip2.tests | 524 +++++++++++++++++++++ .../bunzip2/bunzip2-reads-from-standard-input | 2 + testsuite/bunzip2/bunzip2-removes-compressed-file | 3 + .../bunzip2/bzcat-does-not-remove-compressed-file | 3 + testsuite/busybox.tests | 46 ++ testsuite/bzcat.tests | 49 ++ testsuite/cat/cat-prints-a-file | 3 + testsuite/cat/cat-prints-a-file-and-standard-input | 7 + testsuite/cmp/cmp-detects-difference | 9 + testsuite/comm.tests | 19 + testsuite/cp/cp-RHL-does_not_preserve-links | 6 + testsuite/cp/cp-a-files-to-dir | 15 + testsuite/cp/cp-a-preserves-links | 5 + testsuite/cp/cp-copies-empty-file | 3 + testsuite/cp/cp-copies-large-file | 3 + testsuite/cp/cp-copies-small-file | 3 + testsuite/cp/cp-d-files-to-dir | 11 + testsuite/cp/cp-dev-file | 2 + testsuite/cp/cp-dir-create-dir | 4 + testsuite/cp/cp-dir-existing-dir | 5 + testsuite/cp/cp-does-not-copy-unreadable-file | 11 + testsuite/cp/cp-files-to-dir | 11 + testsuite/cp/cp-follows-links | 4 + testsuite/cp/cp-preserves-hard-links | 6 + testsuite/cp/cp-preserves-links | 5 + testsuite/cp/cp-preserves-source-file | 3 + testsuite/cpio.tests | 83 ++++ testsuite/cut.tests | 18 + testsuite/cut/cut-cuts-a-character | 1 + testsuite/cut/cut-cuts-a-closed-range | 1 + testsuite/cut/cut-cuts-a-field | 1 + testsuite/cut/cut-cuts-an-open-range | 1 + testsuite/cut/cut-cuts-an-unclosed-range | 1 + testsuite/date/date-R-works | 1 + testsuite/date/date-format-works | 4 + testsuite/date/date-u-works | 1 + testsuite/date/date-works | 44 ++ testsuite/date/date-works-1 | 129 +++++ testsuite/dd/dd-accepts-if | 2 + testsuite/dd/dd-accepts-of | 2 + ...d-copies-from-standard-input-to-standard-output | 1 + testsuite/dd/dd-prints-count-to-standard-error | 2 + testsuite/dd/dd-reports-write-errors | 2 + testsuite/diff.tests | 124 +++++ testsuite/dirname/dirname-handles-absolute-path | 1 + testsuite/dirname/dirname-handles-empty-path | 1 + testsuite/dirname/dirname-handles-multiple-slashes | 1 + testsuite/dirname/dirname-handles-relative-path | 1 + testsuite/dirname/dirname-handles-root | 1 + testsuite/dirname/dirname-handles-single-component | 1 + testsuite/dirname/dirname-works | 2 + testsuite/du/du-h-works | 4 + testsuite/du/du-k-works | 4 + testsuite/du/du-l-works | 4 + testsuite/du/du-m-works | 4 + testsuite/du/du-s-works | 4 + testsuite/du/du-works | 4 + testsuite/echo/echo-does-not-print-newline | 1 + testsuite/echo/echo-prints-argument | 1 + testsuite/echo/echo-prints-arguments | 1 + testsuite/echo/echo-prints-newline | 1 + testsuite/echo/echo-prints-slash-zero | 1 + testsuite/expand/expand-works-like-GNU | 18 + testsuite/expr/expr-big | 16 + testsuite/expr/expr-works | 59 +++ testsuite/false/false-is-silent | 1 + testsuite/false/false-returns-failure | 1 + testsuite/find/find-supports-minus-xdev | 1 + testsuite/grep.tests | 88 ++++ testsuite/gunzip.tests | 3 + testsuite/gunzip/gunzip-reads-from-standard-input | 2 + testsuite/gzip/gzip-accepts-multiple-files | 3 + testsuite/gzip/gzip-accepts-single-minus | 1 + testsuite/gzip/gzip-removes-original-file | 3 + testsuite/head/head-n-works | 4 + testsuite/head/head-works | 4 + testsuite/hostid/hostid-works | 2 + testsuite/hostname/hostname-d-works | 2 + testsuite/hostname/hostname-i-works | 2 + testsuite/hostname/hostname-s-works | 1 + testsuite/hostname/hostname-works | 1 + testsuite/id/id-g-works | 1 + testsuite/id/id-u-works | 1 + testsuite/id/id-un-works | 1 + testsuite/id/id-ur-works | 1 + testsuite/ln/ln-creates-hard-links | 4 + testsuite/ln/ln-creates-soft-links | 4 + testsuite/ln/ln-force-creates-hard-links | 5 + testsuite/ln/ln-force-creates-soft-links | 5 + testsuite/ln/ln-preserves-hard-links | 8 + testsuite/ln/ln-preserves-soft-links | 9 + testsuite/ls/ls-1-works | 4 + testsuite/ls/ls-h-works | 4 + testsuite/ls/ls-l-works | 4 + testsuite/ls/ls-s-works | 4 + testsuite/makedevs.device_table.txt | 172 +++++++ testsuite/makedevs.tests | 139 ++++++ testsuite/md5sum/md5sum-verifies-non-binary-file | 3 + testsuite/mdev.tests | 143 ++++++ testsuite/mkdir/mkdir-makes-a-directory | 2 + testsuite/mkdir/mkdir-makes-parent-directories | 2 + testsuite/mkfs.minix.tests | 22 + testsuite/mount.testroot | 183 +++++++ testsuite/mount.tests | 35 ++ .../msh/msh-supports-underscores-in-variable-names | 1 + testsuite/mv/mv-files-to-dir | 16 + testsuite/mv/mv-follows-links | 4 + testsuite/mv/mv-moves-empty-file | 4 + testsuite/mv/mv-moves-file | 3 + testsuite/mv/mv-moves-hardlinks | 4 + testsuite/mv/mv-moves-large-file | 4 + testsuite/mv/mv-moves-small-file | 4 + testsuite/mv/mv-moves-symlinks | 6 + testsuite/mv/mv-moves-unreadable-files | 5 + testsuite/mv/mv-preserves-hard-links | 6 + testsuite/mv/mv-preserves-links | 5 + testsuite/mv/mv-refuses-mv-dir-to-subdir | 23 + testsuite/mv/mv-removes-source-file | 4 + testsuite/od.tests | 17 + testsuite/parse.tests | 109 +++++ testsuite/patch.tests | 65 +++ testsuite/pidof.tests | 31 ++ testsuite/printf.tests | 108 +++++ testsuite/pwd/pwd-prints-working-directory | 1 + testsuite/readlink.tests | 32 ++ testsuite/rm/rm-removes-file | 3 + testsuite/rmdir/rmdir-removes-parent-directories | 3 + testsuite/runtest | 164 +++++++ testsuite/sed.tests | 210 +++++++++ testsuite/seq.tests | 36 ++ testsuite/sort.tests | 119 +++++ testsuite/start-stop-daemon.tests | 19 + testsuite/strings/strings-works-like-GNU | 9 + testsuite/sum.tests | 24 + testsuite/tail/tail-n-works | 4 + testsuite/tail/tail-works | 4 + testsuite/tar/tar-archives-multiple-files | 6 + testsuite/tar/tar-complains-about-missing-file | 3 + testsuite/tar/tar-demands-at-least-one-ctx | 1 + testsuite/tar/tar-demands-at-most-one-ctx | 1 + testsuite/tar/tar-extracts-all-subdirs | 12 + testsuite/tar/tar-extracts-file | 5 + testsuite/tar/tar-extracts-from-standard-input | 5 + testsuite/tar/tar-extracts-multiple-files | 6 + testsuite/tar/tar-extracts-to-standard-output | 3 + testsuite/tar/tar-handles-cz-options | 5 + ...andles-empty-include-and-non-empty-exclude-list | 6 + .../tar/tar-handles-exclude-and-extract-lists | 8 + testsuite/tar/tar-handles-multiple-X-options | 10 + testsuite/tar/tar-handles-nested-exclude | 9 + testsuite/tar/tar_with_link_with_size | 29 ++ testsuite/tar/tar_with_prefix_fields | 261 ++++++++++ testsuite/taskset.tests | 17 + testsuite/tee/tee-appends-input | 5 + testsuite/tee/tee-tees-input | 3 + testsuite/test.tests | 69 +++ testsuite/testing.sh | 154 ++++++ testsuite/touch/touch-creates-file | 2 + testsuite/touch/touch-does-not-create-file | 2 + .../touch-touches-files-after-non-existent-file | 3 + testsuite/tr/tr-d-alnum-works | 4 + testsuite/tr/tr-d-works | 4 + testsuite/tr/tr-non-gnu | 1 + testsuite/tr/tr-rejects-wrong-class | 19 + testsuite/tr/tr-works | 26 + testsuite/true/true-is-silent | 1 + testsuite/true/true-returns-success | 1 + testsuite/umlwrapper.sh | 20 + testsuite/unexpand/unexpand-works-like-GNU | 52 ++ testsuite/uniq.tests | 87 ++++ testsuite/unzip.tests | 38 ++ testsuite/uptime/uptime-works | 2 + testsuite/uuencode.tests | 28 ++ testsuite/wc/wc-counts-all | 2 + testsuite/wc/wc-counts-characters | 1 + testsuite/wc/wc-counts-lines | 1 + testsuite/wc/wc-counts-words | 1 + testsuite/wc/wc-prints-longest-line-length | 1 + testsuite/wget/wget--O-overrides--P | 3 + testsuite/wget/wget-handles-empty-path | 1 + testsuite/wget/wget-retrieves-google-index | 2 + testsuite/wget/wget-supports--P | 3 + testsuite/which/which-uses-default-path | 4 + testsuite/xargs.tests | 29 ++ testsuite/xargs/xargs-works | 4 + 192 files changed, 4378 insertions(+) create mode 100644 testsuite/README create mode 100644 testsuite/TODO create mode 100755 testsuite/all_sourcecode.tests create mode 100755 testsuite/awk.tests create mode 100644 testsuite/awk_t1.tar.bz2 create mode 100644 testsuite/basename/basename-does-not-remove-identical-extension create mode 100644 testsuite/basename/basename-works create mode 100755 testsuite/bunzip2.tests create mode 100644 testsuite/bunzip2/bunzip2-reads-from-standard-input create mode 100644 testsuite/bunzip2/bunzip2-removes-compressed-file create mode 100644 testsuite/bunzip2/bzcat-does-not-remove-compressed-file create mode 100755 testsuite/busybox.tests create mode 100755 testsuite/bzcat.tests create mode 100644 testsuite/cat/cat-prints-a-file create mode 100644 testsuite/cat/cat-prints-a-file-and-standard-input create mode 100644 testsuite/cmp/cmp-detects-difference create mode 100755 testsuite/comm.tests create mode 100644 testsuite/cp/cp-RHL-does_not_preserve-links create mode 100644 testsuite/cp/cp-a-files-to-dir create mode 100644 testsuite/cp/cp-a-preserves-links create mode 100644 testsuite/cp/cp-copies-empty-file create mode 100644 testsuite/cp/cp-copies-large-file create mode 100644 testsuite/cp/cp-copies-small-file create mode 100644 testsuite/cp/cp-d-files-to-dir create mode 100644 testsuite/cp/cp-dev-file create mode 100644 testsuite/cp/cp-dir-create-dir create mode 100644 testsuite/cp/cp-dir-existing-dir create mode 100644 testsuite/cp/cp-does-not-copy-unreadable-file create mode 100644 testsuite/cp/cp-files-to-dir create mode 100644 testsuite/cp/cp-follows-links create mode 100644 testsuite/cp/cp-preserves-hard-links create mode 100644 testsuite/cp/cp-preserves-links create mode 100644 testsuite/cp/cp-preserves-source-file create mode 100755 testsuite/cpio.tests create mode 100755 testsuite/cut.tests create mode 100644 testsuite/cut/cut-cuts-a-character create mode 100644 testsuite/cut/cut-cuts-a-closed-range create mode 100644 testsuite/cut/cut-cuts-a-field create mode 100644 testsuite/cut/cut-cuts-an-open-range create mode 100644 testsuite/cut/cut-cuts-an-unclosed-range create mode 100644 testsuite/date/date-R-works create mode 100644 testsuite/date/date-format-works create mode 100644 testsuite/date/date-u-works create mode 100644 testsuite/date/date-works create mode 100644 testsuite/date/date-works-1 create mode 100644 testsuite/dd/dd-accepts-if create mode 100644 testsuite/dd/dd-accepts-of create mode 100644 testsuite/dd/dd-copies-from-standard-input-to-standard-output create mode 100644 testsuite/dd/dd-prints-count-to-standard-error create mode 100644 testsuite/dd/dd-reports-write-errors create mode 100755 testsuite/diff.tests create mode 100644 testsuite/dirname/dirname-handles-absolute-path create mode 100644 testsuite/dirname/dirname-handles-empty-path create mode 100644 testsuite/dirname/dirname-handles-multiple-slashes create mode 100644 testsuite/dirname/dirname-handles-relative-path create mode 100644 testsuite/dirname/dirname-handles-root create mode 100644 testsuite/dirname/dirname-handles-single-component create mode 100644 testsuite/dirname/dirname-works create mode 100644 testsuite/du/du-h-works create mode 100644 testsuite/du/du-k-works create mode 100644 testsuite/du/du-l-works create mode 100644 testsuite/du/du-m-works create mode 100644 testsuite/du/du-s-works create mode 100644 testsuite/du/du-works create mode 100644 testsuite/echo/echo-does-not-print-newline create mode 100644 testsuite/echo/echo-prints-argument create mode 100644 testsuite/echo/echo-prints-arguments create mode 100644 testsuite/echo/echo-prints-newline create mode 100644 testsuite/echo/echo-prints-slash-zero create mode 100644 testsuite/expand/expand-works-like-GNU create mode 100644 testsuite/expr/expr-big create mode 100644 testsuite/expr/expr-works create mode 100644 testsuite/false/false-is-silent create mode 100644 testsuite/false/false-returns-failure create mode 100644 testsuite/find/find-supports-minus-xdev create mode 100755 testsuite/grep.tests create mode 100755 testsuite/gunzip.tests create mode 100644 testsuite/gunzip/gunzip-reads-from-standard-input create mode 100644 testsuite/gzip/gzip-accepts-multiple-files create mode 100644 testsuite/gzip/gzip-accepts-single-minus create mode 100644 testsuite/gzip/gzip-removes-original-file create mode 100644 testsuite/head/head-n-works create mode 100644 testsuite/head/head-works create mode 100644 testsuite/hostid/hostid-works create mode 100644 testsuite/hostname/hostname-d-works create mode 100644 testsuite/hostname/hostname-i-works create mode 100644 testsuite/hostname/hostname-s-works create mode 100644 testsuite/hostname/hostname-works create mode 100644 testsuite/id/id-g-works create mode 100644 testsuite/id/id-u-works create mode 100644 testsuite/id/id-un-works create mode 100644 testsuite/id/id-ur-works create mode 100644 testsuite/ln/ln-creates-hard-links create mode 100644 testsuite/ln/ln-creates-soft-links create mode 100644 testsuite/ln/ln-force-creates-hard-links create mode 100644 testsuite/ln/ln-force-creates-soft-links create mode 100644 testsuite/ln/ln-preserves-hard-links create mode 100644 testsuite/ln/ln-preserves-soft-links create mode 100644 testsuite/ls/ls-1-works create mode 100644 testsuite/ls/ls-h-works create mode 100644 testsuite/ls/ls-l-works create mode 100644 testsuite/ls/ls-s-works create mode 100644 testsuite/makedevs.device_table.txt create mode 100755 testsuite/makedevs.tests create mode 100644 testsuite/md5sum/md5sum-verifies-non-binary-file create mode 100755 testsuite/mdev.tests create mode 100644 testsuite/mkdir/mkdir-makes-a-directory create mode 100644 testsuite/mkdir/mkdir-makes-parent-directories create mode 100755 testsuite/mkfs.minix.tests create mode 100755 testsuite/mount.testroot create mode 100755 testsuite/mount.tests create mode 100644 testsuite/msh/msh-supports-underscores-in-variable-names create mode 100644 testsuite/mv/mv-files-to-dir create mode 100644 testsuite/mv/mv-follows-links create mode 100644 testsuite/mv/mv-moves-empty-file create mode 100644 testsuite/mv/mv-moves-file create mode 100644 testsuite/mv/mv-moves-hardlinks create mode 100644 testsuite/mv/mv-moves-large-file create mode 100644 testsuite/mv/mv-moves-small-file create mode 100644 testsuite/mv/mv-moves-symlinks create mode 100644 testsuite/mv/mv-moves-unreadable-files create mode 100644 testsuite/mv/mv-preserves-hard-links create mode 100644 testsuite/mv/mv-preserves-links create mode 100644 testsuite/mv/mv-refuses-mv-dir-to-subdir create mode 100644 testsuite/mv/mv-removes-source-file create mode 100755 testsuite/od.tests create mode 100755 testsuite/parse.tests create mode 100755 testsuite/patch.tests create mode 100755 testsuite/pidof.tests create mode 100755 testsuite/printf.tests create mode 100644 testsuite/pwd/pwd-prints-working-directory create mode 100755 testsuite/readlink.tests create mode 100644 testsuite/rm/rm-removes-file create mode 100644 testsuite/rmdir/rmdir-removes-parent-directories create mode 100755 testsuite/runtest create mode 100755 testsuite/sed.tests create mode 100755 testsuite/seq.tests create mode 100755 testsuite/sort.tests create mode 100755 testsuite/start-stop-daemon.tests create mode 100644 testsuite/strings/strings-works-like-GNU create mode 100755 testsuite/sum.tests create mode 100644 testsuite/tail/tail-n-works create mode 100644 testsuite/tail/tail-works create mode 100644 testsuite/tar/tar-archives-multiple-files create mode 100644 testsuite/tar/tar-complains-about-missing-file create mode 100644 testsuite/tar/tar-demands-at-least-one-ctx create mode 100644 testsuite/tar/tar-demands-at-most-one-ctx create mode 100644 testsuite/tar/tar-extracts-all-subdirs create mode 100644 testsuite/tar/tar-extracts-file create mode 100644 testsuite/tar/tar-extracts-from-standard-input create mode 100644 testsuite/tar/tar-extracts-multiple-files create mode 100644 testsuite/tar/tar-extracts-to-standard-output create mode 100644 testsuite/tar/tar-handles-cz-options create mode 100644 testsuite/tar/tar-handles-empty-include-and-non-empty-exclude-list create mode 100644 testsuite/tar/tar-handles-exclude-and-extract-lists create mode 100644 testsuite/tar/tar-handles-multiple-X-options create mode 100644 testsuite/tar/tar-handles-nested-exclude create mode 100644 testsuite/tar/tar_with_link_with_size create mode 100644 testsuite/tar/tar_with_prefix_fields create mode 100755 testsuite/taskset.tests create mode 100644 testsuite/tee/tee-appends-input create mode 100644 testsuite/tee/tee-tees-input create mode 100755 testsuite/test.tests create mode 100755 testsuite/testing.sh create mode 100644 testsuite/touch/touch-creates-file create mode 100644 testsuite/touch/touch-does-not-create-file create mode 100644 testsuite/touch/touch-touches-files-after-non-existent-file create mode 100644 testsuite/tr/tr-d-alnum-works create mode 100644 testsuite/tr/tr-d-works create mode 100644 testsuite/tr/tr-non-gnu create mode 100644 testsuite/tr/tr-rejects-wrong-class create mode 100644 testsuite/tr/tr-works create mode 100644 testsuite/true/true-is-silent create mode 100644 testsuite/true/true-returns-success create mode 100755 testsuite/umlwrapper.sh create mode 100644 testsuite/unexpand/unexpand-works-like-GNU create mode 100755 testsuite/uniq.tests create mode 100755 testsuite/unzip.tests create mode 100644 testsuite/uptime/uptime-works create mode 100755 testsuite/uuencode.tests create mode 100644 testsuite/wc/wc-counts-all create mode 100644 testsuite/wc/wc-counts-characters create mode 100644 testsuite/wc/wc-counts-lines create mode 100644 testsuite/wc/wc-counts-words create mode 100644 testsuite/wc/wc-prints-longest-line-length create mode 100644 testsuite/wget/wget--O-overrides--P create mode 100644 testsuite/wget/wget-handles-empty-path create mode 100644 testsuite/wget/wget-retrieves-google-index create mode 100644 testsuite/wget/wget-supports--P create mode 100644 testsuite/which/which-uses-default-path create mode 100755 testsuite/xargs.tests create mode 100644 testsuite/xargs/xargs-works (limited to 'testsuite') diff --git a/testsuite/README b/testsuite/README new file mode 100644 index 0000000..b4719e6 --- /dev/null +++ b/testsuite/README @@ -0,0 +1,33 @@ +To run the test suite, change to this directory and run "./runtest". It will +run all of the test cases, and list those with unexpected outcomes. Adding the +-v option will cause it to show expected outcomes as well. To only run the test +cases for particular applets: + +./runtest ... + +The test cases for an applet reside in the subdirectory of the applet name. The +name of the test case should be the assertion that is tested. The test case +should be a shell fragment that returns successfully if the test case passes, +and unsuccessfully otherwise. + +If the test case relies on a certain feature, it should include the string +"FEATURE: " followed by the name of the feature in a comment. If it is always +expected to fail, it should include the string "XFAIL" in a comment. + +For the entire testsuite, the copyright is as follows: + +Copyright (C) 2001, 2002 Matt Kraai + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. diff --git a/testsuite/TODO b/testsuite/TODO new file mode 100644 index 0000000..b8957f4 --- /dev/null +++ b/testsuite/TODO @@ -0,0 +1,26 @@ +This testsuite is quite obviously a work in progress. As such, +there are a number of good extensions. If you are looking for +something to do, feel free to tackle one or more of the following: + +Moving to the new format. + The old way was "lots of little tests files in a directory", which + doesn't interact well with source control systems. The new test + format is command.tests files that use testing.sh. + +Every busybox applet needs a corresponding applet.tests. + +Full SUSv3 test suite. + Let's make the Linux Test Project jealous, shall we? Don't just + audit programs for standards compliance, _prove_ it with a regression + test harness. + + http://www.opengroup.org/onlinepubs/009695399/utilities/ + +Some tests need root access. + It's hard to test things like mount or init as a normal user. + Possibly User Mode Linux could be used for this, or perhaps + Erik's buildroot. + +libbb unit testing + Being able to test the functions of libbb individually may + help to prevent regressions. diff --git a/testsuite/all_sourcecode.tests b/testsuite/all_sourcecode.tests new file mode 100755 index 0000000..45f4011 --- /dev/null +++ b/testsuite/all_sourcecode.tests @@ -0,0 +1,92 @@ +#!/bin/sh + +# Tests for the sourcecode base itself. +# Copyright 2006 by Mike Frysinger +# Licensed under GPL v2, see file LICENSE for details. + +[ -n "$srcdir" ] || srcdir=$(pwd) +. testing.sh + + +# +# if we don't have the sourcecode available, let's just bail +# +[ -s "$srcdir/../Makefile" ] || exit 0 +[ -s "$srcdir/../include/applets.h" ] || exit 0 + + +# +# make sure all usage strings are properly escaped. oftentimes people miss +# an escape sequence so we end up with: +# #define foo_usage \ +# " this line is ok" \ +# " as is this line" +# " but this one is broken as the \ is missing from above" +# +${CROSS_COMPILE}cpp -dD -P $srcdir/../include/usage.h \ + | sed -e '/^#define/d' -e '/^$/d' > src.usage.escaped +testing "Usage strings escaped" "cat src.usage.escaped" "" "" "" +rm -f src.usage.escaped + + +# +# verify the applet order is correct in applets.h, otherwise +# applets won't be called properly. +# +sed -n -e '/^USE_[A-Z]*(APPLET/{s:,.*::;s:.*(::;s:"::g;p}' \ + $srcdir/../include/applets.h > applet.order.current +LC_ALL=C sort applet.order.current > applet.order.correct +testing "Applet order" "diff -u applet.order.current applet.order.correct" "" "" "" +rm -f applet.order.current applet.order.correct + + +# +# check for misc common typos +# +find $srcdir/../ \ + '(' -type d -a '(' -name .svn -o -name testsuite ')' -prune ')' \ + -o '(' -type f -a -print0 ')' | xargs -0 \ + grep -I \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' -e '\' -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + -e '\' \ + | sed -e "s:^$srcdir/\.\./::g" > src.typos +testing "Common typos" "cat src.typos" "" "" "" +rm -f src.typos + + +# +# don't allow obsolete functions +# +find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \ + grep -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes|sigblock|siggetmask|sigsetmask)\>[[:space:]]*\(' \ + | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.funcs +testing "Obsolete function usage" "cat src.obsolete.funcs" "" "" "" +rm -f src.obsolete.funcs + + +# +# don't allow obsolete headers +# +find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \ + grep -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \ + | sed -e "s:^$srcdir/\.\./::g" > src.obsolete.headers +testing "Obsolete headers" "cat src.obsolete.headers" "" "" "" +rm -f src.obsolete.headers + + +exit $FAILCOUNT diff --git a/testsuite/awk.tests b/testsuite/awk.tests new file mode 100755 index 0000000..aa38636 --- /dev/null +++ b/testsuite/awk.tests @@ -0,0 +1,32 @@ +#!/bin/sh + +# Copyright 2007 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "description" "command" "result" "infile" "stdin" + +testing "awk -F case 0" "awk -F '[#]' '{ print NF }'" "" "" "" +testing "awk -F case 1" "awk -F '[#]' '{ print NF }'" "0\n" "" "\n" +testing "awk -F case 2" "awk -F '[#]' '{ print NF }'" "2\n" "" "#\n" +testing "awk -F case 3" "awk -F '[#]' '{ print NF }'" "3\n" "" "#abc#\n" +testing "awk -F case 4" "awk -F '[#]' '{ print NF }'" "3\n" "" "#abc#zz\n" +testing "awk -F case 5" "awk -F '[#]' '{ print NF }'" "4\n" "" "#abc##zz\n" +testing "awk -F case 6" "awk -F '[#]' '{ print NF }'" "4\n" "" "z#abc##zz\n" +testing "awk -F case 7" "awk -F '[#]' '{ print NF }'" "5\n" "" "z##abc##zz\n" + +# 4294967295 = 0xffffffff +testing "awk bitwise op" "awk '{ print or(4294967295,1) }'" "4.29497e+09\n" "" "\n" +testing "awk hex const 1" "awk '{ print or(0xffffffff,1) }'" "4.29497e+09\n" "" "\n" +testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n" +testing "awk oct const" "awk '{ print or(01234,1) }'" "669\n" "" "\n" + +tar xjf awk_t1.tar.bz2 +testing "awk 'gcc build bug'" \ + "awk -f awk_t1_opt-functions.awk -f awk_t1_opth-gen.awk t1.$ext + hello_$ext >t2.$ext +} + +check() { + eval $2 >t_actual 2>&1 + if $ECHO -ne "$expected" | cmp - t_actual; then + echo "$1: PASS" + else + echo "$1: FAIL" + fi +} + +mkdir testdir 2>/dev/null +( +cd testdir || { echo "cannot cd testdir!"; exit 1; } + +expected="$unpack: z: No such file or directory +1 +HELLO +" +prep; check "$unpack: doesnt exist" "${bb}$unpack z t1.$ext; echo \$?; cat t1" + + +expected="$unpack: t.zz: unknown suffix - ignored +1 +HELLO +" +prep; >t.zz; check "$unpack: unknown suffix" "${bb}$unpack t.zz t1.$ext; echo \$?; cat t1" + + +# In this case file "t1" exists, and we skip t1.gz and unpack t2.gz +expected="$unpack: can't open 't1': File exists +1 +HELLO +" +prep; >t1; check "$unpack: already exists" "${bb}$unpack t1.$ext t2.$ext; echo \$?; cat t1 t2" + + +# From old testsuite +expected="HELLO\n0\n" +prep; check "$unpack: stream unpack" "cat t1.$ext | ${bb}$unpack; echo $?" + +expected="ok\n" +prep; check "$unpack: delete src" "${bb}$unpack t2.$ext; test ! -f t2.$ext && echo ok" + +) +rm -rf testdir + +# This test is only for bunzip2 +if test "${0##*/}" = "bunzip2.tests"; then + if test1_bz2 | ${bb}bunzip2 >/dev/null \ + && test "`test1_bz2 | ${bb}bunzip2 | md5sum`" = "61bbeee4be9c6f110a71447f584fda7b -" + then + echo "$unpack: test bz2 file: PASS" + else + echo "$unpack: test bz2 file: FAIL" + fi +fi diff --git a/testsuite/bunzip2/bunzip2-reads-from-standard-input b/testsuite/bunzip2/bunzip2-reads-from-standard-input new file mode 100644 index 0000000..e212a12 --- /dev/null +++ b/testsuite/bunzip2/bunzip2-reads-from-standard-input @@ -0,0 +1,2 @@ +echo foo | bzip2 | busybox bunzip2 > output +echo foo | cmp - output diff --git a/testsuite/bunzip2/bunzip2-removes-compressed-file b/testsuite/bunzip2/bunzip2-removes-compressed-file new file mode 100644 index 0000000..f1d1550 --- /dev/null +++ b/testsuite/bunzip2/bunzip2-removes-compressed-file @@ -0,0 +1,3 @@ +echo foo | bzip2 >foo.bz2 +busybox bunzip2 foo.bz2 +test ! -f foo.bz2 diff --git a/testsuite/bunzip2/bzcat-does-not-remove-compressed-file b/testsuite/bunzip2/bzcat-does-not-remove-compressed-file new file mode 100644 index 0000000..7d4016e --- /dev/null +++ b/testsuite/bunzip2/bzcat-does-not-remove-compressed-file @@ -0,0 +1,3 @@ +echo foo | bzip2 >foo.bz2 +busybox bzcat foo.bz2 +test -f foo.bz2 diff --git a/testsuite/busybox.tests b/testsuite/busybox.tests new file mode 100755 index 0000000..26536c6 --- /dev/null +++ b/testsuite/busybox.tests @@ -0,0 +1,46 @@ +#!/bin/sh + +# Tests for busybox applet itself. +# Copyright 2005 by Rob Landley +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +HELPDUMP=`busybox` + +# We need to test under calling the binary under other names. + + +testing "busybox --help busybox" "busybox --help busybox" "$HELPDUMP\n\n" "" "" + +ln -s `which busybox` busybox-suffix +for i in busybox ./busybox-suffix +do + # The gratuitous "\n"s are due to a shell idiosyncrasy: + # environment variables seem to strip trailing whitespace. + + testing "" "$i" "$HELPDUMP\n\n" "" "" + + testing "$i unknown" "$i unknown 2>&1" \ + "unknown: applet not found\n" "" "" + + testing "$i --help" "$i --help 2>&1" "$HELPDUMP\n\n" "" "" + + optional CAT + testing "" "$i cat" "moo" "" "moo" + testing "$i --help cat" "$i --help cat 2>&1 | grep prints" \ + "Concatenates FILE(s) and prints them to stdout.\n" "" "" + optional "" + + testing "$i --help unknown" "$i --help unknown 2>&1" \ + "unknown: applet not found\n" "" "" +done +rm busybox-suffix + +ln -s `which busybox` unknown + +testing "busybox as unknown name" "./unknown 2>&1" \ + "unknown: applet not found\n" "" "" +rm unknown + +exit $FAILCOUNT diff --git a/testsuite/bzcat.tests b/testsuite/bzcat.tests new file mode 100755 index 0000000..0bc7442 --- /dev/null +++ b/testsuite/bzcat.tests @@ -0,0 +1,49 @@ +#!/bin/sh + +ext=bz2 + +bb="busybox " + +unset LC_ALL +unset LC_MESSAGES +unset LANG +unset LANGUAGE + +hello_gz() { + # Gzipped "HELLO\n" + #_________________________ vvv vvv vvv vvv - mtime + $ECHO -ne "\x1f\x8b\x08\x00\x85\x1d\xef\x45\x02\x03\xf3\x70\xf5\xf1\xf1\xe7" + $ECHO -ne "\x02\x00\x6e\xd7\xac\xfd\x06\x00\x00\x00" +} + +hello_bz2() { + # Bzipped "HELLO\n" + $ECHO -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x5b\xb8\xe8\xa3\x00\x00" + $ECHO -ne "\x01\x44\x00\x00\x10\x02\x44\xa0\x00\x30\xcd\x00\xc3\x46\x29\x97" + $ECHO -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3" +} + +prep() { + rm -f t* + hello_$ext >t1.$ext + hello_$ext >t2.$ext +} + +check() { + eval $2 >t_actual 2>&1 + if $ECHO -ne "$expected" | cmp - t_actual; then + echo "$1: PASS" + else + echo "$1: FAIL" + fi +} + +mkdir testdir 2>/dev/null +( +cd testdir || { echo "cannot cd testdir!"; exit 1; } + +expected="HELLO\nok\n" +prep; check "bzcat: dont delete src" "${bb}bzcat t2.bz2; test -f t2.bz2 && echo ok" + +) +rm -rf testdir diff --git a/testsuite/cat/cat-prints-a-file b/testsuite/cat/cat-prints-a-file new file mode 100644 index 0000000..e3f35a8 --- /dev/null +++ b/testsuite/cat/cat-prints-a-file @@ -0,0 +1,3 @@ +echo I WANT > foo +busybox cat foo >bar +cmp foo bar diff --git a/testsuite/cat/cat-prints-a-file-and-standard-input b/testsuite/cat/cat-prints-a-file-and-standard-input new file mode 100644 index 0000000..bc92318 --- /dev/null +++ b/testsuite/cat/cat-prints-a-file-and-standard-input @@ -0,0 +1,7 @@ +echo I WANT > foo +echo SOMETHING | busybox cat foo - >bar +cat >baz <foo +echo bar >bar +set +e +busybox cmp -s foo bar +if [ $? != 0 ] ; then + exit 0; +fi + +exit 1; diff --git a/testsuite/comm.tests b/testsuite/comm.tests new file mode 100755 index 0000000..44169f9 --- /dev/null +++ b/testsuite/comm.tests @@ -0,0 +1,19 @@ +#!/bin/sh + +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "description" "command" "result" "infile" "stdin" + +testing "comm test 1" "comm input -" "\t123\n""456\n""abc\n""\tdef\n" "456\nabc\n" "123\ndef\n" +testing "comm test 2" "comm - input" "123\n""\t456\n""\tabc\n""def\n" "456\nabc\n" "123\ndef\n" +testing "comm test 3" "comm input -" "abc\n""\tdef\n""xyz\n" "abc\nxyz\n" "def\n" +testing "comm test 4" "comm - input" "\tabc\n""def\n""\txyz\n" "abc\nxyz\n" "def\n" +testing "comm test 5" "comm input -" "123\n""abc\n""\tdef\n" "123\nabc\n" "def\n" +testing "comm test 6" "comm - input" "\t123\n""\tabc\n""def\n" "123\nabc\n" "def\n" +testing "comm unterminated line 1" "comm input -" "abc\n""\tdef\n" "abc" "def" +testing "comm unterminated line 2" "comm - input" "\tabc\n""def\n" "abc" "def" + +exit $FAILCOUNT diff --git a/testsuite/cp/cp-RHL-does_not_preserve-links b/testsuite/cp/cp-RHL-does_not_preserve-links new file mode 100644 index 0000000..eed6c3e --- /dev/null +++ b/testsuite/cp/cp-RHL-does_not_preserve-links @@ -0,0 +1,6 @@ +mkdir a +>a/file +ln -s file a/link +busybox cp -RHL a b +test ! -L b/link +#sh /dev/tty 2>&1 diff --git a/testsuite/cp/cp-a-files-to-dir b/testsuite/cp/cp-a-files-to-dir new file mode 100644 index 0000000..abdbdf7 --- /dev/null +++ b/testsuite/cp/cp-a-files-to-dir @@ -0,0 +1,15 @@ +echo file number one > file1 +echo file number two > file2 +ln -s file2 link1 +mkdir dir1 +# why??? +#touch --date='Sat Jan 29 21:24:08 PST 2000' dir1/file3 +mkdir there +busybox cp -a file1 file2 link1 dir1 there +test -f there/file1 +test -f there/file2 +test ! -s there/dir1/file3 +test -L there/link1 +test xfile2 = x`readlink there/link1` +test ! dir1/file3 -ot there/dir1/file3 +test ! dir1/file3 -nt there/dir1/file3 diff --git a/testsuite/cp/cp-a-preserves-links b/testsuite/cp/cp-a-preserves-links new file mode 100644 index 0000000..0c0cd96 --- /dev/null +++ b/testsuite/cp/cp-a-preserves-links @@ -0,0 +1,5 @@ +touch foo +ln -s foo bar +busybox cp -a bar baz +test -L baz +test xfoo = x`readlink baz` diff --git a/testsuite/cp/cp-copies-empty-file b/testsuite/cp/cp-copies-empty-file new file mode 100644 index 0000000..ad25aa1 --- /dev/null +++ b/testsuite/cp/cp-copies-empty-file @@ -0,0 +1,3 @@ +touch foo +busybox cp foo bar +cmp foo bar diff --git a/testsuite/cp/cp-copies-large-file b/testsuite/cp/cp-copies-large-file new file mode 100644 index 0000000..c2225c6 --- /dev/null +++ b/testsuite/cp/cp-copies-large-file @@ -0,0 +1,3 @@ +dd if=/dev/zero of=foo seek=10k count=1 2>/dev/null +busybox cp foo bar +cmp foo bar diff --git a/testsuite/cp/cp-copies-small-file b/testsuite/cp/cp-copies-small-file new file mode 100644 index 0000000..d52a887 --- /dev/null +++ b/testsuite/cp/cp-copies-small-file @@ -0,0 +1,3 @@ +echo I WANT > foo +busybox cp foo bar +cmp foo bar diff --git a/testsuite/cp/cp-d-files-to-dir b/testsuite/cp/cp-d-files-to-dir new file mode 100644 index 0000000..9571a56 --- /dev/null +++ b/testsuite/cp/cp-d-files-to-dir @@ -0,0 +1,11 @@ +echo file number one > file1 +echo file number two > file2 +touch file3 +ln -s file2 link1 +mkdir there +busybox cp -d file1 file2 file3 link1 there +test -f there/file1 +test -f there/file2 +test ! -s there/file3 +test -L there/link1 +test xfile2 = x`readlink there/link1` diff --git a/testsuite/cp/cp-dev-file b/testsuite/cp/cp-dev-file new file mode 100644 index 0000000..055f0d9 --- /dev/null +++ b/testsuite/cp/cp-dev-file @@ -0,0 +1,2 @@ +busybox cp /dev/null foo +test -f foo diff --git a/testsuite/cp/cp-dir-create-dir b/testsuite/cp/cp-dir-create-dir new file mode 100644 index 0000000..a8d7b50 --- /dev/null +++ b/testsuite/cp/cp-dir-create-dir @@ -0,0 +1,4 @@ +mkdir bar +touch bar/baz +busybox cp -R bar foo +test -f foo/baz diff --git a/testsuite/cp/cp-dir-existing-dir b/testsuite/cp/cp-dir-existing-dir new file mode 100644 index 0000000..4c788ba --- /dev/null +++ b/testsuite/cp/cp-dir-existing-dir @@ -0,0 +1,5 @@ +mkdir bar +touch bar/baz +mkdir foo +busybox cp -R bar foo +test -f foo/bar/baz diff --git a/testsuite/cp/cp-does-not-copy-unreadable-file b/testsuite/cp/cp-does-not-copy-unreadable-file new file mode 100644 index 0000000..e17e8e6 --- /dev/null +++ b/testsuite/cp/cp-does-not-copy-unreadable-file @@ -0,0 +1,11 @@ +touch foo +chmod a-r foo +set +e +if test `id -u` = 0; then + # run as user with nonzero uid + setuidgid 1 busybox cp foo bar +else + busybox cp foo bar +fi +set -e +test ! -f bar diff --git a/testsuite/cp/cp-files-to-dir b/testsuite/cp/cp-files-to-dir new file mode 100644 index 0000000..fdb8191 --- /dev/null +++ b/testsuite/cp/cp-files-to-dir @@ -0,0 +1,11 @@ +echo file number one > file1 +echo file number two > file2 +touch file3 +ln -s file2 link1 +mkdir there +busybox cp file1 file2 file3 link1 there +test -f there/file1 +test -f there/file2 +test ! -s there/file3 +test -f there/link1 +cmp there/file2 there/link1 diff --git a/testsuite/cp/cp-follows-links b/testsuite/cp/cp-follows-links new file mode 100644 index 0000000..2d9f05e --- /dev/null +++ b/testsuite/cp/cp-follows-links @@ -0,0 +1,4 @@ +touch foo +ln -s foo bar +busybox cp bar baz +test -f baz diff --git a/testsuite/cp/cp-preserves-hard-links b/testsuite/cp/cp-preserves-hard-links new file mode 100644 index 0000000..4de7b85 --- /dev/null +++ b/testsuite/cp/cp-preserves-hard-links @@ -0,0 +1,6 @@ +# FEATURE: CONFIG_FEATURE_PRESERVE_HARDLINKS +touch foo +ln foo bar +mkdir baz +busybox cp -d foo bar baz +test baz/foo -ef baz/bar diff --git a/testsuite/cp/cp-preserves-links b/testsuite/cp/cp-preserves-links new file mode 100644 index 0000000..301dc5f --- /dev/null +++ b/testsuite/cp/cp-preserves-links @@ -0,0 +1,5 @@ +touch foo +ln -s foo bar +busybox cp -d bar baz +test -L baz +test xfoo = x`readlink baz` diff --git a/testsuite/cp/cp-preserves-source-file b/testsuite/cp/cp-preserves-source-file new file mode 100644 index 0000000..f0f5065 --- /dev/null +++ b/testsuite/cp/cp-preserves-source-file @@ -0,0 +1,3 @@ +touch foo +busybox cp foo bar +test -f foo diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests new file mode 100755 index 0000000..eb3e576 --- /dev/null +++ b/testsuite/cpio.tests @@ -0,0 +1,83 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# ls -ln shows date. Need to remove that, it's variable. +# sed: coalesce spaces +# cut: remove date +FILTER_LS="sed 's/ */ /g' | cut -d' ' -f 1-5,9-" + + +# newc cpio archive of directory cpio.testdir with empty x and y hardlinks +hexdump="\ +\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x64\x1e\x91\x8c\x00\x00\ +\x48\x7f\x80\x4c\x48\x08\x00\x28\x01\xff\xe0\x3f\x24\x14\x00\x0e\ +\x20\xdc\x60\x20\x00\x92\x11\xea\xa0\x1a\x00\x00\x00\x03\x20\x8a\ +\x93\xd4\x9a\x68\x1a\x0d\x1e\x91\xa1\xa0\x06\x98\xe3\x5c\x2f\xd9\ +\x26\xa1\x25\x24\x20\xed\x47\xc7\x21\x40\x2b\x6e\xf2\xe6\xfe\x98\ +\x13\x68\xa8\xbd\x82\xb2\x4f\x26\x02\x24\x16\x5b\x22\x16\x72\x74\ +\x15\xcd\xc1\xa6\x9e\xa6\x5e\x6c\x16\x37\x35\x01\x99\xc4\x81\x21\ +\x29\x28\x4b\x69\x51\xa9\x3c\x1a\x9b\x0a\xe1\xe4\xb4\xaf\x85\x73\ +\xba\x23\x10\x59\xe8\xb3\xe1\xa1\x63\x05\x8c\x4f\xc5\xdc\x91\x4e\ +\x14\x24\x19\x07\xa4\x63\x00" + +user=$(id -u) +group=$(id -g) + +rm -rf cpio.testdir cpio.testdir2 2>/dev/null + +# testing "test name" "command" "expected result" "file input" "stdin" + +testing "cpio extracts zero-sized hardlinks" \ +"$ECHO -ne '$hexdump' | bzcat | cpio -i; echo \$?; +ls -ln cpio.testdir | $FILTER_LS" \ +"\ +1 blocks +0 +-rw-r--r-- 2 $user $group 0 x +-rw-r--r-- 2 $user $group 0 y +" \ + "" "" + +# Currently fails. Numerous: "1 blocks" versus "1 block", +# "1 block" must go to stderr, does not list cpio.testdir/x and cpio.testdir/y +testing "cpio lists hardlinks" \ +"$ECHO -ne '$hexdump' | bzcat | cpio -t 2>&1; echo \$?" \ +"\ +1 block +cpio.testdir +cpio.testdir/x +cpio.testdir/y +0 +" \ + "" "" + +# More complex case +rm -rf cpio.testdir cpio.testdir2 2>/dev/null +mkdir cpio.testdir +touch cpio.testdir/solo +touch cpio.testdir/empty +echo x >cpio.testdir/nonempty +ln cpio.testdir/empty cpio.testdir/empty1 +ln cpio.testdir/nonempty cpio.testdir/nonempty1 +mkdir cpio.testdir2 + +testing "cpio extracts zero-sized hardlinks 2" \ +"find cpio.testdir | cpio -H newc --create | (cd cpio.testdir2 && cpio -i); echo \$?; +ls -ln cpio.testdir2/cpio.testdir | $FILTER_LS" \ +"\ +0 +-rw-r--r-- 2 $user $group 0 empty +-rw-r--r-- 2 $user $group 0 empty1 +-rw-r--r-- 2 $user $group 2 nonempty +-rw-r--r-- 2 $user $group 2 nonempty1 +-rw-r--r-- 1 $user $group 0 solo +" \ + "" "" + +# Clean up +rm -rf cpio.testdir cpio.testdir2 2>/dev/null + +exit $FAILCOUNT diff --git a/testsuite/cut.tests b/testsuite/cut.tests new file mode 100755 index 0000000..2788d1f --- /dev/null +++ b/testsuite/cut.tests @@ -0,0 +1,18 @@ +#!/bin/sh + +# Copyright 2007 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +testing "cut '-' (stdin) and multi file handling" \ + "cut -d' ' -f2 - input" \ + "over\n""quick\n" \ + "the quick brown fox\n" \ + "jumps over the lazy dog\n" \ + +exit $FAILCOUNT diff --git a/testsuite/cut/cut-cuts-a-character b/testsuite/cut/cut-cuts-a-character new file mode 100644 index 0000000..d6c5efa --- /dev/null +++ b/testsuite/cut/cut-cuts-a-character @@ -0,0 +1 @@ +test $(echo abcd | busybox cut -c 3) = c diff --git a/testsuite/cut/cut-cuts-a-closed-range b/testsuite/cut/cut-cuts-a-closed-range new file mode 100644 index 0000000..9680b76 --- /dev/null +++ b/testsuite/cut/cut-cuts-a-closed-range @@ -0,0 +1 @@ +test $(echo abcd | busybox cut -c 1-2) = ab diff --git a/testsuite/cut/cut-cuts-a-field b/testsuite/cut/cut-cuts-a-field new file mode 100644 index 0000000..4c7f440 --- /dev/null +++ b/testsuite/cut/cut-cuts-a-field @@ -0,0 +1 @@ +test $(echo -e "f1\tf2\tf3" | busybox cut -f 2) = f2 diff --git a/testsuite/cut/cut-cuts-an-open-range b/testsuite/cut/cut-cuts-an-open-range new file mode 100644 index 0000000..1fbf277 --- /dev/null +++ b/testsuite/cut/cut-cuts-an-open-range @@ -0,0 +1 @@ +test $(echo abcd | busybox cut -c -3) = abc diff --git a/testsuite/cut/cut-cuts-an-unclosed-range b/testsuite/cut/cut-cuts-an-unclosed-range new file mode 100644 index 0000000..a2b0cdb --- /dev/null +++ b/testsuite/cut/cut-cuts-an-unclosed-range @@ -0,0 +1 @@ +test $(echo abcd | busybox cut -c 3-) = cd diff --git a/testsuite/date/date-R-works b/testsuite/date/date-R-works new file mode 100644 index 0000000..34cd735 --- /dev/null +++ b/testsuite/date/date-R-works @@ -0,0 +1 @@ +test x"`date -R`" = x"`busybox date -R`" diff --git a/testsuite/date/date-format-works b/testsuite/date/date-format-works new file mode 100644 index 0000000..f2a2091 --- /dev/null +++ b/testsuite/date/date-format-works @@ -0,0 +1,4 @@ +# TODO: gnu date doesn't accept '2000.11.22-11:22:33' format, +# but accepts '2000-11-22 11:22:33'. We must follow. +test x"01/01/99" = x"`busybox date -d 1999.01.01-11:22:33 '+%d/%m/%y'`" +test x"22/11/00" = x"`busybox date -d 2000.11.22-11:22:33 '+%d/%m/%y'`" diff --git a/testsuite/date/date-u-works b/testsuite/date/date-u-works new file mode 100644 index 0000000..eea6e5a --- /dev/null +++ b/testsuite/date/date-u-works @@ -0,0 +1 @@ +test x"Sat Jan 1 11:22:33 UTC 2000" = x"`TZ=CET-1CEST-2 busybox date -u -d 2000.01.01-11:22:33`" diff --git a/testsuite/date/date-works b/testsuite/date/date-works new file mode 100644 index 0000000..0802e88 --- /dev/null +++ b/testsuite/date/date-works @@ -0,0 +1,44 @@ +dt=`busybox date` +# Expected format: Fri Apr 25 03:47:55 CEST 2008 +dt=`echo "$dt" | sed 's/^[^ ][^ ][^ ] [^ ][^ ][^ ] [ 0123][0-9] [012][0-9]:[0-5][0-9]:[0-6][0-9] [A-Z][A-Z]* [012][0-9][0-9][0-9]$/OK/'` +test x"$dt" = x"OK" + +dt=`busybox date -d 1:2` +dt=`echo "$dt" | cut -b12-19` +test x"$dt" = x"01:02:00" + +dt=`busybox date -d 1:2:3` +dt=`echo "$dt" | cut -b12-19` +test x"$dt" = x"01:02:03" + +dt=`busybox date -d 1.2-3:4` +dt=`echo "$dt" | cut -b5-19` +test x"$dt" = x"Jan 2 03:04:00" + +dt=`busybox date -d 1.2-3:4:5` +dt=`echo "$dt" | cut -b5-19` +test x"$dt" = x"Jan 2 03:04:05" + +dt=`busybox date -d 1999.1.2-3:4` +dt=`echo "$dt" | cut -b1-19` +test x"$dt" = x"Sat Jan 2 03:04:00" + +dt=`busybox date -d 1999.1.2-3:4:5` +dt=`echo "$dt" | cut -b1-19` +test x"$dt" = x"Sat Jan 2 03:04:05" + +dt=`busybox date -d '1999-1-2 3:4:5'` +dt=`echo "$dt" | cut -b1-19` +test x"$dt" = x"Sat Jan 2 03:04:05" + +dt=`busybox date -d 01231133` +dt=`echo "$dt" | cut -b5-19` +test x"$dt" = x"Jan 23 11:33:00" + +dt=`busybox date -d 012311332000` +dt=`echo "$dt" | cut -b1-19` +test x"$dt" = x"Sun Jan 23 11:33:00" + +dt=`busybox date -d 012311332000.30` +dt=`echo "$dt" | cut -b1-19` +test x"$dt" = x"Sun Jan 23 11:33:30" diff --git a/testsuite/date/date-works-1 b/testsuite/date/date-works-1 new file mode 100644 index 0000000..e318944 --- /dev/null +++ b/testsuite/date/date-works-1 @@ -0,0 +1,129 @@ +dt=`busybox date -d 1:2 +%T` +test x"$dt" = x"01:02:00" + +dt=`busybox date -d 1:2:3 +%T` +test x"$dt" = x"01:02:03" + +host_date=/bin/date + +# date (GNU coreutils) 6.10 reports: +# date: invalid date '1.2-3:4' +# busybox 1.11.0.svn date reports: +# date: invalid date '1/2 3:4' + +# TODO: (1) compare with strings, not "host date" +# (2) implement d/m[/y] hh:mm[:ss] fmt in date applet +#hdt=`$host_date -d '1/2 3:4'` +#dt=`busybox date -d 1.2-3:4` +#test x"$hdt" = x"$dt" + +#hdt=`$host_date -d '1/2 3:4:5'` +#dt=`busybox date -d 1.2-3:4:5` +#test x"$hdt" = x"$dt" + +#hdt=`$host_date -d '1/2/1999 3:4'` +#dt=`busybox date -d 1999.1.2-3:4` +#test x"$hdt" = x"$dt" + +#hdt=`$host_date -d '1/2/1999 3:4:5'` +#dt=`busybox date -d 1999.1.2-3:4:5` +#test x"$hdt" = x"$dt" + +hdt=`$host_date -d '1999-1-2 3:4:5'` +dt=`busybox date -d '1999-1-2 3:4:5'` +test x"$hdt" = x"$dt" + +# Avoiding using week day in this evaluation, as it's mostly different every year +# date (GNU coreutils) 6.10 reports: +# date: invalid date '01231133' +dt=`busybox date -d 01231133 +%c` +dt=`echo "$dt" | cut -b5-19` +test x"$dt" = x"Jan 23 11:33:00" + +# date (GNU coreutils) 6.10 reports: +# date: invalid date '012311332000' +dt=`busybox date -d 012311332000 +%c` +test x"$dt" = x"Sun Jan 23 11:33:00 2000" + +# date (GNU coreutils) 6.10 reports: +# date: invalid date '012311332000' +dt=`busybox date -d 012311332000.30 +%c` +test x"$dt" = x"Sun Jan 23 11:33:30 2000" + +lcbbd="LC_ALL=C busybox date" +wd=$(eval $lcbbd +%a) # weekday name +mn=$(eval $lcbbd +%b) # month name +dm=$(eval $lcbbd +%e) # day of month, space padded +h=$(eval $lcbbd +%H) # hour, zero padded +m=$(eval $lcbbd +%M) # minute, zero padded +s=$(eval $lcbbd +%S) # second, zero padded +z=$(eval $lcbbd -u +%Z) # time zone abbreviation +y=$(eval $lcbbd +%Y) # year + +res=OK +case $wd in + Sun) + ;; + Mon) + ;; + Tue) + ;; + Wed) + ;; + Thu) + ;; + Fri) + ;; + Sat) + ;; + *) + res=BAD + ;; +esac + +case $mn in + Jan) + ;; + Feb) + ;; + Mar) + ;; + Apr) + ;; + May) + ;; + Jun) + ;; + Jul) + ;; + Aug) + ;; + Sep) + ;; + Oct) + ;; + Nov) + ;; + Dec) + ;; + *) + res=BAD + ;; +esac + +dm=${dm# *} +[ $dm -ge 1 ] && [ $dm -le 31 ] || res=BAD +h=${h#0} +[ $h -ge 0 ] && [ $h -le 23 ] || res=BAD +m=${m#0} +[ $m -ge 0 ] && [ $m -le 59 ] || res=BAD +s=${s#0} +[ $s -ge 0 ] && [ $s -le 59 ] || res=BAD +[ $z = UTC ] || res=BAD +[ $y -ge 1970 ] || res=BAD + +test x"$res" = xOK + +# This should error out (by showing usage text). Testing for that +dt=`busybox date -d 012311332000.30 %+c 2>&1 | head -n 1` +test x"${dt#BusyBox * multi-call binary}" = x diff --git a/testsuite/dd/dd-accepts-if b/testsuite/dd/dd-accepts-if new file mode 100644 index 0000000..03d1af8 --- /dev/null +++ b/testsuite/dd/dd-accepts-if @@ -0,0 +1,2 @@ +echo I WANT >foo +test "$(busybox dd if=foo 2>/dev/null)" = "I WANT" diff --git a/testsuite/dd/dd-accepts-of b/testsuite/dd/dd-accepts-of new file mode 100644 index 0000000..84405e6 --- /dev/null +++ b/testsuite/dd/dd-accepts-of @@ -0,0 +1,2 @@ +echo I WANT | busybox dd of=foo 2>/dev/null +echo I WANT | cmp foo - diff --git a/testsuite/dd/dd-copies-from-standard-input-to-standard-output b/testsuite/dd/dd-copies-from-standard-input-to-standard-output new file mode 100644 index 0000000..d890eb0 --- /dev/null +++ b/testsuite/dd/dd-copies-from-standard-input-to-standard-output @@ -0,0 +1 @@ +test "$(echo I WANT | busybox dd 2>/dev/null)" = "I WANT" diff --git a/testsuite/dd/dd-prints-count-to-standard-error b/testsuite/dd/dd-prints-count-to-standard-error new file mode 100644 index 0000000..2187dc0 --- /dev/null +++ b/testsuite/dd/dd-prints-count-to-standard-error @@ -0,0 +1,2 @@ +echo I WANT | busybox dd of=foo >/dev/null 2>bar +grep -q records bar diff --git a/testsuite/dd/dd-reports-write-errors b/testsuite/dd/dd-reports-write-errors new file mode 100644 index 0000000..4920600 --- /dev/null +++ b/testsuite/dd/dd-reports-write-errors @@ -0,0 +1,2 @@ +busybox dd if="$0" of=/dev/full 2>/dev/null || status=$? +test $status = 1 diff --git a/testsuite/diff.tests b/testsuite/diff.tests new file mode 100755 index 0000000..ac68a08 --- /dev/null +++ b/testsuite/diff.tests @@ -0,0 +1,124 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" + +# diff outputs date/time in the header, which should not be analysed +# NB: sed has tab character in s command! +TRIM_TAB="sed 's/ .*//'" + +testing "diff of stdin" \ + "diff -u - input | $TRIM_TAB" \ +"\ +--- - ++++ input +@@ -1 +1,3 @@ ++qwe + asd ++zxc +" \ + "qwe\nasd\nzxc\n" \ + "asd\n" + +testing "diff of stdin, no newline in the file" \ + "diff -u - input | $TRIM_TAB" \ +"\ +--- - ++++ input +@@ -1 +1,3 @@ ++qwe + asd ++zxc +\\ No newline at end of file +" \ + "qwe\nasd\nzxc" \ + "asd\n" + +# we also test that stdin is in fact NOT read +testing "diff of stdin, twice" \ + "diff - -; echo $?; wc -c" \ + "0\n5\n" \ + "" \ + "stdin" + +# testing "test name" "options" "expected result" "file input" "stdin" + +rm -rf diff1 diff2 +mkdir diff1 diff2 diff2/subdir +echo qwe >diff1/- +echo asd >diff2/subdir/- +testing "diff diff1 diff2/subdir" \ + "diff -ur diff1 diff2/subdir | $TRIM_TAB" \ +"\ +--- diff1/- ++++ diff2/subdir/- +@@ -1 +1 @@ +-qwe ++asd +" \ + "" "" + +# using directory structure from prev test... +testing "diff dir dir2/file/-" \ + "diff -ur diff1 diff2/subdir/- | $TRIM_TAB" \ +"\ +--- diff1/- ++++ diff2/subdir/- +@@ -1 +1 @@ +-qwe ++asd +" \ + "" "" + +# using directory structure from prev test... +mkdir diff1/test +mkfifo diff2/subdir/test +testing "diff of dir and fifo" \ + "diff -ur diff1 diff2/subdir | $TRIM_TAB" \ +"\ +--- diff1/- ++++ diff2/subdir/- +@@ -1 +1 @@ +-qwe ++asd +Only in diff2/subdir: test +" \ + "" "" + +# using directory structure from prev test... +rmdir diff1/test +echo >diff1/test +testing "diff of file and fifo" \ + "diff -ur diff1 diff2/subdir | $TRIM_TAB" \ +"\ +--- diff1/- ++++ diff2/subdir/- +@@ -1 +1 @@ +-qwe ++asd +File diff2/subdir/test is not a regular file or directory and was skipped +" \ + "" "" + +# using directory structure from prev test... +mkfifo diff1/test2 +testing "diff -rN does not read non-regular files" \ + "diff -urN diff1 diff2/subdir | $TRIM_TAB" \ +"\ +--- diff1/- ++++ diff2/subdir/- +@@ -1 +1 @@ +-qwe ++asd +File diff2/subdir/test is not a regular file or directory and was skipped +File diff1/test2 is not a regular file or directory and was skipped +" \ + "" "" + +# clean up +rm -rf diff1 diff2 + +exit $FAILCOUNT diff --git a/testsuite/dirname/dirname-handles-absolute-path b/testsuite/dirname/dirname-handles-absolute-path new file mode 100644 index 0000000..ca1a51b --- /dev/null +++ b/testsuite/dirname/dirname-handles-absolute-path @@ -0,0 +1 @@ +test $(busybox dirname /foo/bar/baz) = /foo/bar diff --git a/testsuite/dirname/dirname-handles-empty-path b/testsuite/dirname/dirname-handles-empty-path new file mode 100644 index 0000000..04134a5 --- /dev/null +++ b/testsuite/dirname/dirname-handles-empty-path @@ -0,0 +1 @@ +test $(busybox dirname '') = . diff --git a/testsuite/dirname/dirname-handles-multiple-slashes b/testsuite/dirname/dirname-handles-multiple-slashes new file mode 100644 index 0000000..286f253 --- /dev/null +++ b/testsuite/dirname/dirname-handles-multiple-slashes @@ -0,0 +1 @@ +test $(busybox dirname foo/bar///baz) = foo/bar diff --git a/testsuite/dirname/dirname-handles-relative-path b/testsuite/dirname/dirname-handles-relative-path new file mode 100644 index 0000000..ffe4ab4 --- /dev/null +++ b/testsuite/dirname/dirname-handles-relative-path @@ -0,0 +1 @@ +test $(busybox dirname foo/bar/baz) = foo/bar diff --git a/testsuite/dirname/dirname-handles-root b/testsuite/dirname/dirname-handles-root new file mode 100644 index 0000000..6bd62b8 --- /dev/null +++ b/testsuite/dirname/dirname-handles-root @@ -0,0 +1 @@ +test $(busybox dirname /) = / diff --git a/testsuite/dirname/dirname-handles-single-component b/testsuite/dirname/dirname-handles-single-component new file mode 100644 index 0000000..24f9ae1 --- /dev/null +++ b/testsuite/dirname/dirname-handles-single-component @@ -0,0 +1 @@ +test $(busybox dirname foo) = . diff --git a/testsuite/dirname/dirname-works b/testsuite/dirname/dirname-works new file mode 100644 index 0000000..f339c8f --- /dev/null +++ b/testsuite/dirname/dirname-works @@ -0,0 +1,2 @@ +test x$(dirname $(pwd)) = x$(busybox dirname $(pwd)) + diff --git a/testsuite/du/du-h-works b/testsuite/du/du-h-works new file mode 100644 index 0000000..3f8ff3d --- /dev/null +++ b/testsuite/du/du-h-works @@ -0,0 +1,4 @@ +d=/bin +du -h "$d" > logfile.gnu +busybox du -h "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/du/du-k-works b/testsuite/du/du-k-works new file mode 100644 index 0000000..6c2c5d0 --- /dev/null +++ b/testsuite/du/du-k-works @@ -0,0 +1,4 @@ +d=/bin +du -k "$d" > logfile.gnu +busybox du -k "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/du/du-l-works b/testsuite/du/du-l-works new file mode 100644 index 0000000..c3d2ec0 --- /dev/null +++ b/testsuite/du/du-l-works @@ -0,0 +1,4 @@ +d=/bin +du -l "$d" > logfile.gnu +busybox du -l "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/du/du-m-works b/testsuite/du/du-m-works new file mode 100644 index 0000000..bf0a90e --- /dev/null +++ b/testsuite/du/du-m-works @@ -0,0 +1,4 @@ +d=/bin +du -m "$d" > logfile.gnu +busybox du -m "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/du/du-s-works b/testsuite/du/du-s-works new file mode 100644 index 0000000..ae97077 --- /dev/null +++ b/testsuite/du/du-s-works @@ -0,0 +1,4 @@ +d=/bin +du -s "$d" > logfile.gnu +busybox du -s "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/du/du-works b/testsuite/du/du-works new file mode 100644 index 0000000..46a336d --- /dev/null +++ b/testsuite/du/du-works @@ -0,0 +1,4 @@ +d=/bin +du "$d" > logfile.gnu +busybox du "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/echo/echo-does-not-print-newline b/testsuite/echo/echo-does-not-print-newline new file mode 100644 index 0000000..2ed03ca --- /dev/null +++ b/testsuite/echo/echo-does-not-print-newline @@ -0,0 +1 @@ +test `busybox echo -n word | wc -c` -eq 4 diff --git a/testsuite/echo/echo-prints-argument b/testsuite/echo/echo-prints-argument new file mode 100644 index 0000000..479dac8 --- /dev/null +++ b/testsuite/echo/echo-prints-argument @@ -0,0 +1 @@ +test xfubar = x`busybox echo fubar` diff --git a/testsuite/echo/echo-prints-arguments b/testsuite/echo/echo-prints-arguments new file mode 100644 index 0000000..4e4e3b4 --- /dev/null +++ b/testsuite/echo/echo-prints-arguments @@ -0,0 +1 @@ +test "`busybox echo foo bar`" = "foo bar" diff --git a/testsuite/echo/echo-prints-newline b/testsuite/echo/echo-prints-newline new file mode 100644 index 0000000..838671e --- /dev/null +++ b/testsuite/echo/echo-prints-newline @@ -0,0 +1 @@ +test `busybox echo word | wc -c` -eq 5 diff --git a/testsuite/echo/echo-prints-slash-zero b/testsuite/echo/echo-prints-slash-zero new file mode 100644 index 0000000..d246632 --- /dev/null +++ b/testsuite/echo/echo-prints-slash-zero @@ -0,0 +1 @@ +test "`busybox echo -e -n 'msg\n\0' | od -t x1 | head -n 1`" = "0000000 6d 73 67 0a 00" diff --git a/testsuite/expand/expand-works-like-GNU b/testsuite/expand/expand-works-like-GNU new file mode 100644 index 0000000..ee8c793 --- /dev/null +++ b/testsuite/expand/expand-works-like-GNU @@ -0,0 +1,18 @@ +rm -f foo bar +echo -e "\ty" | expand -t 3 ../../busybox > foo +echo -e "\ty" | busybox unexpand -t 3 ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi +rm -f foo bar +echo -e "\ty\tx" | expand -it 3 ../../busybox > foo +echo -e "\ty\tx" | busybox unexpand -it 3 ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi diff --git a/testsuite/expr/expr-big b/testsuite/expr/expr-big new file mode 100644 index 0000000..23dbbb3 --- /dev/null +++ b/testsuite/expr/expr-big @@ -0,0 +1,16 @@ +# busybox expr + +# 3*1000*1000*1000 overflows 32-bit signed int +res=`busybox expr 0 '<' 3000000000` +[ x"$res" = x1 ] || exit 1 + +# 9223372036854775807 = 2^31-1 +res=`busybox expr 0 '<' 9223372036854775807` +[ x"$res" = x1 ] || exit 1 +# coreutils fails this one! +res=`busybox expr -9223372036854775800 '<' 9223372036854775807` +[ x"$res" = x1 ] || exit 1 + +# This one works only by chance +# res=`busybox expr 0 '<' 9223372036854775808` +# [ x"$res" = x1 ] || exit 1 diff --git a/testsuite/expr/expr-works b/testsuite/expr/expr-works new file mode 100644 index 0000000..af49ac4 --- /dev/null +++ b/testsuite/expr/expr-works @@ -0,0 +1,59 @@ +# busybox expr +busybox expr 1 \| 1 +busybox expr 1 \| 0 +busybox expr 0 \| 1 +busybox expr 1 \& 1 +busybox expr 0 \< 1 +busybox expr 1 \> 0 +busybox expr 0 \<= 1 +busybox expr 1 \<= 1 +busybox expr 1 \>= 0 +busybox expr 1 \>= 1 +busybox expr 1 + 2 +busybox expr 2 - 1 +busybox expr 2 \* 3 +busybox expr 12 / 2 +busybox expr 12 % 5 + + +set +e +busybox expr 0 \| 0 +if [ $? != 1 ] ; then + exit 1; +fi; + +busybox expr 1 \& 0 +if [ $? != 1 ] ; then + exit 1; +fi; + +busybox expr 0 \& 1 +if [ $? != 1 ] ; then + exit 1; +fi; + +busybox expr 0 \& 0 +if [ $? != 1 ] ; then + exit 1; +fi; + +busybox expr 1 \< 0 +if [ $? != 1 ] ; then + exit 1; +fi; + +busybox expr 0 \> 1 +if [ $? != 1 ] ; then + exit 1; +fi; + +busybox expr 1 \<= 0 +if [ $? != 1 ] ; then + exit 1; +fi; + +busybox expr 0 \>= 1 +if [ $? != 1 ] ; then + exit 1; +fi; + diff --git a/testsuite/false/false-is-silent b/testsuite/false/false-is-silent new file mode 100644 index 0000000..8a9aa0c --- /dev/null +++ b/testsuite/false/false-is-silent @@ -0,0 +1 @@ +busybox false 2>&1 | cmp - /dev/null diff --git a/testsuite/false/false-returns-failure b/testsuite/false/false-returns-failure new file mode 100644 index 0000000..1a061f2 --- /dev/null +++ b/testsuite/false/false-returns-failure @@ -0,0 +1 @@ +! busybox false diff --git a/testsuite/find/find-supports-minus-xdev b/testsuite/find/find-supports-minus-xdev new file mode 100644 index 0000000..4c559a1 --- /dev/null +++ b/testsuite/find/find-supports-minus-xdev @@ -0,0 +1 @@ +busybox find . -xdev >/dev/null 2>&1 diff --git a/testsuite/grep.tests b/testsuite/grep.tests new file mode 100755 index 0000000..8cee1b9 --- /dev/null +++ b/testsuite/grep.tests @@ -0,0 +1,88 @@ +#!/bin/sh + +# Copyright 2005 by Rob Landley +# Licensed under GPL v2, see file LICENSE for details. + +# AUDIT: + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +# Test exit status + +testing "grep (exit with error)" "grep nonexistent 2> /dev/null ; echo \$?" \ + "1\n" "" "" +testing "grep (exit success)" "grep grep $0 > /dev/null 2>&1 ; echo \$?" "0\n" \ + "" "" +# Test various data sources and destinations + +testing "grep (default to stdin)" "grep two" "two\n" "" \ + "one\ntwo\nthree\nthree\nthree\n" +testing "grep - (specify stdin)" "grep two -" "two\n" "" \ + "one\ntwo\nthree\nthree\nthree\n" +testing "grep input (specify file)" "grep two input" "two\n" \ + "one\ntwo\nthree\nthree\nthree\n" "" + +# GNU grep 2.5.3 outputs a new line character after the located string +# even if there is no new line character in the input +testing "grep (no newline at EOL)" "grep bug input" "bug\n" "bug" "" + +>empty +testing "grep two files" "grep two input empty 2>/dev/null" \ + "input:two\n" "one\ntwo\nthree\nthree\nthree\n" "" +rm empty + +testing "grep - infile (specify stdin and file)" "grep two - input" \ + "(standard input):two\ninput:two\n" "one\ntwo\nthree\n" \ + "one\ntwo\ntoo\nthree\nthree\n" + +# Check if we see the correct return value if both stdin and non-existing file +# are given. +testing "grep - nofile (specify stdin and nonexisting file)" \ + "grep two - nonexistent 2> /dev/null ; echo \$?" \ + "(standard input):two\n(standard input):two\n2\n" \ + "" "one\ntwo\ntwo\nthree\nthree\nthree\n" +testing "grep -q - nofile (specify stdin and nonexisting file, no match)" \ + "grep -q nomatch - nonexistent 2> /dev/null ; echo \$?" \ + "2\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" +# SUSv3: If the -q option is specified, the exit status shall be zero +# if an input line is selected, even if an error was detected. +testing "grep -q - nofile (specify stdin and nonexisting file, match)" \ + "grep -q two - nonexistent ; echo \$?" \ + "0\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" + +# Test various command line options +# -s no error messages +testing "grep -s nofile (nonexisting file, no match)" \ + "grep -s nomatch nonexistent ; echo \$?" "2\n" "" "" +testing "grep -s nofile - (stdin and nonexisting file, match)" \ + "grep -s domatch nonexistent - ; echo \$?" \ + "(standard input):domatch\n2\n" "" "nomatch\ndomatch\nend\n" + +testing "grep handles NUL in files" "grep -a foo input" "\0foo\n" "\0foo\n\n" "" +testing "grep handles NUL on stdin" "grep -a foo" "\0foo\n" "" "\0foo\n\n" + +testing "grep matches NUL" "grep . input > /dev/null 2>&1 ; echo \$?" \ + "0\n" "\0\n" "" + +# -e regex +testing "grep handles multiple regexps" "grep -e one -e two input ; echo \$?" \ + "one\ntwo\n0\n" "one\ntwo\n" "" +testing "grep -F handles multiple expessions" "grep -F -e one -e two input ; echo \$?" \ + "one\ntwo\n0\n" "one\ntwo\n" "" + +# -f file/- +testing "grep can read regexps from stdin" "grep -f - input ; echo \$?" \ + "two\nthree\n0\n" "tw\ntwo\nthree\n" "tw.\nthr\n" + +optional FEATURE_GREP_EGREP_ALIAS +testing "grep -E supports extended regexps" "grep -E fo+" "foo\n" "" \ + "b\ar\nfoo\nbaz" +testing "grep is also egrep" "egrep foo" "foo\n" "" "foo\nbar\n" +testing "egrep is not case insensitive" \ + "egrep foo ; [ \$? -ne 0 ] && echo yes" "yes\n" "" "FOO\n" + +exit $FAILCOUNT diff --git a/testsuite/gunzip.tests b/testsuite/gunzip.tests new file mode 100755 index 0000000..d781004 --- /dev/null +++ b/testsuite/gunzip.tests @@ -0,0 +1,3 @@ +#!/bin/sh + +. bunzip2.tests diff --git a/testsuite/gunzip/gunzip-reads-from-standard-input b/testsuite/gunzip/gunzip-reads-from-standard-input new file mode 100644 index 0000000..7c498c0 --- /dev/null +++ b/testsuite/gunzip/gunzip-reads-from-standard-input @@ -0,0 +1,2 @@ +echo foo | gzip | busybox gunzip > output +echo foo | cmp - output diff --git a/testsuite/gzip/gzip-accepts-multiple-files b/testsuite/gzip/gzip-accepts-multiple-files new file mode 100644 index 0000000..8f0d9c8 --- /dev/null +++ b/testsuite/gzip/gzip-accepts-multiple-files @@ -0,0 +1,3 @@ +touch foo bar +busybox gzip foo bar +test -f foo.gz -a -f bar.gz diff --git a/testsuite/gzip/gzip-accepts-single-minus b/testsuite/gzip/gzip-accepts-single-minus new file mode 100644 index 0000000..8b51fdf --- /dev/null +++ b/testsuite/gzip/gzip-accepts-single-minus @@ -0,0 +1 @@ +echo foo | busybox gzip - >/dev/null diff --git a/testsuite/gzip/gzip-removes-original-file b/testsuite/gzip/gzip-removes-original-file new file mode 100644 index 0000000..b9cb995 --- /dev/null +++ b/testsuite/gzip/gzip-removes-original-file @@ -0,0 +1,3 @@ +touch foo +busybox gzip foo +test ! -f foo diff --git a/testsuite/head/head-n-works b/testsuite/head/head-n-works new file mode 100644 index 0000000..db43255 --- /dev/null +++ b/testsuite/head/head-n-works @@ -0,0 +1,4 @@ +[ -n "$d" ] || d=.. +head -n 2 "$d/README" > logfile.gnu +busybox head -n 2 "$d/README" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/head/head-works b/testsuite/head/head-works new file mode 100644 index 0000000..56ad3e3 --- /dev/null +++ b/testsuite/head/head-works @@ -0,0 +1,4 @@ +[ -n "$d" ] || d=.. +head "$d/README" > logfile.gnu +busybox head "$d/README" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/hostid/hostid-works b/testsuite/hostid/hostid-works new file mode 100644 index 0000000..e85698e --- /dev/null +++ b/testsuite/hostid/hostid-works @@ -0,0 +1,2 @@ +test x$(hostid) = x$(busybox hostid) + diff --git a/testsuite/hostname/hostname-d-works b/testsuite/hostname/hostname-d-works new file mode 100644 index 0000000..a9aeb92 --- /dev/null +++ b/testsuite/hostname/hostname-d-works @@ -0,0 +1,2 @@ +test x$(hostname -d) = x$(busybox hostname -d) + diff --git a/testsuite/hostname/hostname-i-works b/testsuite/hostname/hostname-i-works new file mode 100644 index 0000000..68a3e67 --- /dev/null +++ b/testsuite/hostname/hostname-i-works @@ -0,0 +1,2 @@ +test x$(hostname -i) = x$(busybox hostname -i) + diff --git a/testsuite/hostname/hostname-s-works b/testsuite/hostname/hostname-s-works new file mode 100644 index 0000000..172b944 --- /dev/null +++ b/testsuite/hostname/hostname-s-works @@ -0,0 +1 @@ +test x$(hostname -s) = x$(busybox hostname -s) diff --git a/testsuite/hostname/hostname-works b/testsuite/hostname/hostname-works new file mode 100644 index 0000000..f51a406 --- /dev/null +++ b/testsuite/hostname/hostname-works @@ -0,0 +1 @@ +test x$(hostname) = x$(busybox hostname) diff --git a/testsuite/id/id-g-works b/testsuite/id/id-g-works new file mode 100644 index 0000000..671fc53 --- /dev/null +++ b/testsuite/id/id-g-works @@ -0,0 +1 @@ +test x$(id -g) = x$(busybox id -g) diff --git a/testsuite/id/id-u-works b/testsuite/id/id-u-works new file mode 100644 index 0000000..2358cb0 --- /dev/null +++ b/testsuite/id/id-u-works @@ -0,0 +1 @@ +test x$(id -u) = x$(busybox id -u) diff --git a/testsuite/id/id-un-works b/testsuite/id/id-un-works new file mode 100644 index 0000000..db390e7 --- /dev/null +++ b/testsuite/id/id-un-works @@ -0,0 +1 @@ +test x$(id -un) = x$(busybox id -un) diff --git a/testsuite/id/id-ur-works b/testsuite/id/id-ur-works new file mode 100644 index 0000000..6b0fcb0 --- /dev/null +++ b/testsuite/id/id-ur-works @@ -0,0 +1 @@ +test x$(id -ur) = x$(busybox id -ur) diff --git a/testsuite/ln/ln-creates-hard-links b/testsuite/ln/ln-creates-hard-links new file mode 100644 index 0000000..2f6e23f --- /dev/null +++ b/testsuite/ln/ln-creates-hard-links @@ -0,0 +1,4 @@ +echo file number one > file1 +busybox ln file1 link1 +test -f file1 +test -f link1 diff --git a/testsuite/ln/ln-creates-soft-links b/testsuite/ln/ln-creates-soft-links new file mode 100644 index 0000000..e875e4c --- /dev/null +++ b/testsuite/ln/ln-creates-soft-links @@ -0,0 +1,4 @@ +echo file number one > file1 +busybox ln -s file1 link1 +test -L link1 +test xfile1 = x`readlink link1` diff --git a/testsuite/ln/ln-force-creates-hard-links b/testsuite/ln/ln-force-creates-hard-links new file mode 100644 index 0000000..c96b7d6 --- /dev/null +++ b/testsuite/ln/ln-force-creates-hard-links @@ -0,0 +1,5 @@ +echo file number one > file1 +echo file number two > link1 +busybox ln -f file1 link1 +test -f file1 +test -f link1 diff --git a/testsuite/ln/ln-force-creates-soft-links b/testsuite/ln/ln-force-creates-soft-links new file mode 100644 index 0000000..cab8d1d --- /dev/null +++ b/testsuite/ln/ln-force-creates-soft-links @@ -0,0 +1,5 @@ +echo file number one > file1 +echo file number two > link1 +busybox ln -f -s file1 link1 +test -L link1 +test xfile1 = x`readlink link1` diff --git a/testsuite/ln/ln-preserves-hard-links b/testsuite/ln/ln-preserves-hard-links new file mode 100644 index 0000000..47fb989 --- /dev/null +++ b/testsuite/ln/ln-preserves-hard-links @@ -0,0 +1,8 @@ +echo file number one > file1 +echo file number two > link1 +set +e +busybox ln file1 link1 +if [ $? != 0 ] ; then + exit 0; +fi +exit 1; diff --git a/testsuite/ln/ln-preserves-soft-links b/testsuite/ln/ln-preserves-soft-links new file mode 100644 index 0000000..a8123ec --- /dev/null +++ b/testsuite/ln/ln-preserves-soft-links @@ -0,0 +1,9 @@ +echo file number one > file1 +echo file number two > link1 +set +e +busybox ln -s file1 link1 +if [ $? != 0 ] ; then + exit 0; +fi +exit 1; + diff --git a/testsuite/ls/ls-1-works b/testsuite/ls/ls-1-works new file mode 100644 index 0000000..8ad484f --- /dev/null +++ b/testsuite/ls/ls-1-works @@ -0,0 +1,4 @@ +[ -n "$d" ] || d=.. +ls -1 "$d" > logfile.gnu +busybox ls -1 "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/ls/ls-h-works b/testsuite/ls/ls-h-works new file mode 100644 index 0000000..7331262 --- /dev/null +++ b/testsuite/ls/ls-h-works @@ -0,0 +1,4 @@ +[ -n "$d" ] || d=.. +ls -h "$d" > logfile.gnu +busybox ls -h "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/ls/ls-l-works b/testsuite/ls/ls-l-works new file mode 100644 index 0000000..efc2b19 --- /dev/null +++ b/testsuite/ls/ls-l-works @@ -0,0 +1,4 @@ +[ -n "$d" ] || d=.. +LC_ALL=C ls -l "$d" > logfile.gnu +busybox ls -l "$d" > logfile.bb +diff -w logfile.gnu logfile.bb diff --git a/testsuite/ls/ls-s-works b/testsuite/ls/ls-s-works new file mode 100644 index 0000000..6c8bf36 --- /dev/null +++ b/testsuite/ls/ls-s-works @@ -0,0 +1,4 @@ +[ -n "$d" ] || d=.. +LC_ALL=C ls -1s "$d" > logfile.gnu +busybox ls -1s "$d" > logfile.bb +cmp logfile.gnu logfile.bb diff --git a/testsuite/makedevs.device_table.txt b/testsuite/makedevs.device_table.txt new file mode 100644 index 0000000..4400083 --- /dev/null +++ b/testsuite/makedevs.device_table.txt @@ -0,0 +1,172 @@ +# When building a target filesystem, it is desirable to not have to +# become root and then run 'mknod' a thousand times. Using a device +# table you can create device nodes and directories "on the fly". +# +# This is a sample device table file for use with genext2fs. You can +# do all sorts of interesting things with a device table file. For +# example, if you want to adjust the permissions on a particular file +# you can just add an entry like: +# /sbin/foobar f 2755 0 0 - - - - - +# and (assuming the file /sbin/foobar exists) it will be made setuid +# root (regardless of what its permissions are on the host filesystem. +# Furthermore, you can use a single table entry to create a many device +# minors. For example, if I wanted to create /dev/hda and /dev/hda[0-15] +# I could just use the following two table entries: +# /dev/hda b 640 0 0 3 0 0 0 - +# /dev/hda b 640 0 0 3 1 1 1 15 +# +# Device table entries take the form of: +# +# where name is the file name, type can be one of: +# f A regular file +# d Directory +# c Character special device file +# b Block special device file +# p Fifo (named pipe) +# uid is the user id for the target file, gid is the group id for the +# target file. The rest of the entries (major, minor, etc) apply only +# to device special files. + +# Have fun +# -Erik Andersen +# + +# +/dev d 755 0 0 - - - - - +/dev/pts d 755 0 0 - - - - - +/dev/shm d 755 0 0 - - - - - +/tmp d 1777 0 0 - - - - - +/etc d 755 0 0 - - - - - +/home/default d 2755 1000 1000 - - - - - +# +###/bin/busybox f 4755 0 0 - - - - - +###/etc/shadow f 600 0 0 - - - - - +###/etc/passwd f 644 0 0 - - - - - +/etc/network/if-up.d d 755 0 0 - - - - - +/etc/network/if-pre-up.d d 755 0 0 - - - - - +/etc/network/if-down.d d 755 0 0 - - - - - +/etc/network/if-post-down.d d 755 0 0 - - - - - +###/usr/share/udhcpc/default.script f 755 0 0 - - - - - +# uncomment this to allow starting x as non-root +#/usr/X11R6/bin/Xfbdev f 4755 0 0 - - - - - + +# Normal system devices +# +/dev/mem c 640 0 0 1 1 0 0 - +/dev/kmem c 640 0 0 1 2 0 0 - +/dev/null c 666 0 0 1 3 0 0 - +/dev/zero c 666 0 0 1 5 0 0 - +/dev/random c 666 0 0 1 8 0 0 - +/dev/urandom c 666 0 0 1 9 0 0 - +/dev/ram b 640 0 0 1 1 0 0 - +/dev/ram b 640 0 0 1 0 0 1 4 +/dev/loop b 640 0 0 7 0 0 1 2 +/dev/rtc c 640 0 0 10 135 - - - +/dev/console c 666 0 0 5 1 - - - +/dev/tty c 666 0 0 5 0 - - - +/dev/tty c 666 0 0 4 0 0 1 8 +/dev/ttyp c 666 0 0 3 0 0 1 10 +/dev/ptyp c 666 0 0 2 0 0 1 10 +/dev/ptmx c 666 0 0 5 2 - - - +/dev/ttyP c 666 0 0 57 0 0 1 4 +/dev/ttyS c 666 0 0 4 64 0 1 4 +/dev/fb c 640 0 5 29 0 0 32 4 +#/dev/ttySA c 666 0 0 204 5 0 1 3 +/dev/psaux c 666 0 0 10 1 0 0 - +#/dev/ppp c 666 0 0 108 0 - - - + +# Input stuff +/dev/input d 755 0 0 - - - - - +/dev/input/mice c 640 0 0 13 63 0 0 - +/dev/input/mouse c 660 0 0 13 32 0 1 4 +/dev/input/event c 660 0 0 13 64 0 1 4 +#/dev/input/js c 660 0 0 13 0 0 1 4 + + +# MTD stuff +/dev/mtd c 640 0 0 90 0 0 2 4 +/dev/mtdblock b 640 0 0 31 0 0 1 4 + +#Tun/tap driver +/dev/net d 755 0 0 - - - - - +/dev/net/tun c 660 0 0 10 200 - - - + +# Audio stuff +#/dev/audio c 666 0 29 14 4 - - - +#/dev/audio1 c 666 0 29 14 20 - - - +#/dev/dsp c 666 0 29 14 3 - - - +#/dev/dsp1 c 666 0 29 14 19 - - - +#/dev/sndstat c 666 0 29 14 6 - - - + +# User-mode Linux stuff +#/dev/ubda b 640 0 0 98 0 0 0 - +#/dev/ubda b 640 0 0 98 1 1 1 15 + +# IDE Devices +/dev/hda b 640 0 0 3 0 0 0 - +/dev/hda b 640 0 0 3 1 1 1 15 +/dev/hdb b 640 0 0 3 64 0 0 - +/dev/hdb b 640 0 0 3 65 1 1 15 +#/dev/hdc b 640 0 0 22 0 0 0 - +#/dev/hdc b 640 0 0 22 1 1 1 15 +#/dev/hdd b 640 0 0 22 64 0 0 - +#/dev/hdd b 640 0 0 22 65 1 1 15 +#/dev/hde b 640 0 0 33 0 0 0 - +#/dev/hde b 640 0 0 33 1 1 1 15 +#/dev/hdf b 640 0 0 33 64 0 0 - +#/dev/hdf b 640 0 0 33 65 1 1 15 +#/dev/hdg b 640 0 0 34 0 0 0 - +#/dev/hdg b 640 0 0 34 1 1 1 15 +#/dev/hdh b 640 0 0 34 64 0 0 - +#/dev/hdh b 640 0 0 34 65 1 1 15 + +# SCSI Devices +#/dev/sda b 640 0 0 8 0 0 0 - +#/dev/sda b 640 0 0 8 1 1 1 15 +#/dev/sdb b 640 0 0 8 16 0 0 - +#/dev/sdb b 640 0 0 8 17 1 1 15 +#/dev/sdc b 640 0 0 8 32 0 0 - +#/dev/sdc b 640 0 0 8 33 1 1 15 +#/dev/sdd b 640 0 0 8 48 0 0 - +#/dev/sdd b 640 0 0 8 49 1 1 15 +#/dev/sde b 640 0 0 8 64 0 0 - +#/dev/sde b 640 0 0 8 65 1 1 15 +#/dev/sdf b 640 0 0 8 80 0 0 - +#/dev/sdf b 640 0 0 8 81 1 1 15 +#/dev/sdg b 640 0 0 8 96 0 0 - +#/dev/sdg b 640 0 0 8 97 1 1 15 +#/dev/sdh b 640 0 0 8 112 0 0 - +#/dev/sdh b 640 0 0 8 113 1 1 15 +#/dev/sg c 640 0 0 21 0 0 1 15 +#/dev/scd b 640 0 0 11 0 0 1 15 +#/dev/st c 640 0 0 9 0 0 1 8 +#/dev/nst c 640 0 0 9 128 0 1 8 +#/dev/st c 640 0 0 9 32 1 1 4 +#/dev/st c 640 0 0 9 64 1 1 4 +#/dev/st c 640 0 0 9 96 1 1 4 + +# Floppy disk devices +#/dev/fd b 640 0 0 2 0 0 1 2 +#/dev/fd0d360 b 640 0 0 2 4 0 0 - +#/dev/fd1d360 b 640 0 0 2 5 0 0 - +#/dev/fd0h1200 b 640 0 0 2 8 0 0 - +#/dev/fd1h1200 b 640 0 0 2 9 0 0 - +#/dev/fd0u1440 b 640 0 0 2 28 0 0 - +#/dev/fd1u1440 b 640 0 0 2 29 0 0 - +#/dev/fd0u2880 b 640 0 0 2 32 0 0 - +#/dev/fd1u2880 b 640 0 0 2 33 0 0 - + +# All the proprietary cdrom devices in the world +#/dev/aztcd b 640 0 0 29 0 0 0 - +#/dev/bpcd b 640 0 0 41 0 0 0 - +#/dev/capi20 c 640 0 0 68 0 0 1 2 +#/dev/cdu31a b 640 0 0 15 0 0 0 - +#/dev/cdu535 b 640 0 0 24 0 0 0 - +#/dev/cm206cd b 640 0 0 32 0 0 0 - +#/dev/sjcd b 640 0 0 18 0 0 0 - +#/dev/sonycd b 640 0 0 15 0 0 0 - +#/dev/gscd b 640 0 0 16 0 0 0 - +#/dev/sbpcd b 640 0 0 25 0 0 0 - +#/dev/sbpcd b 640 0 0 25 0 0 1 4 +#/dev/mcd b 640 0 0 23 0 0 0 - +#/dev/optcd b 640 0 0 17 0 0 0 - diff --git a/testsuite/makedevs.tests b/testsuite/makedevs.tests new file mode 100755 index 0000000..9e068bd --- /dev/null +++ b/testsuite/makedevs.tests @@ -0,0 +1,139 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# ls -ln is showing date. Need to remove that, it's variable +# sed: (1) "maj, min" -> "maj,min" (2) coalesce spaces +# cut: remove date +FILTER_LS="sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-5,9-" +# cut: remove size+date +FILTER_LS2="sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-4,9-" + +# testing "test name" "options" "expected result" "file input" "stdin" + +rm -rf makedevs.testdir +mkdir makedevs.testdir + +testing "makedevs -d ../makedevs.device_table.txt ." \ + "(cd makedevs.testdir && makedevs -d ../makedevs.device_table.txt . 2>&1); + find makedevs.testdir ! -type d | sort | xargs ls -lnR | $FILTER_LS" \ +"\ +rootdir=. +table='../makedevs.device_table.txt' +crw-rw-rw- 1 0 0 5,1 makedevs.testdir/dev/console +crw-r----- 1 0 5 29,0 makedevs.testdir/dev/fb0 +crw-r----- 1 0 5 29,32 makedevs.testdir/dev/fb1 +crw-r----- 1 0 5 29,64 makedevs.testdir/dev/fb2 +crw-r----- 1 0 5 29,96 makedevs.testdir/dev/fb3 +brw-r----- 1 0 0 3,0 makedevs.testdir/dev/hda +brw-r----- 1 0 0 3,1 makedevs.testdir/dev/hda1 +brw-r----- 1 0 0 3,10 makedevs.testdir/dev/hda10 +brw-r----- 1 0 0 3,11 makedevs.testdir/dev/hda11 +brw-r----- 1 0 0 3,12 makedevs.testdir/dev/hda12 +brw-r----- 1 0 0 3,13 makedevs.testdir/dev/hda13 +brw-r----- 1 0 0 3,14 makedevs.testdir/dev/hda14 +brw-r----- 1 0 0 3,15 makedevs.testdir/dev/hda15 +brw-r----- 1 0 0 3,2 makedevs.testdir/dev/hda2 +brw-r----- 1 0 0 3,3 makedevs.testdir/dev/hda3 +brw-r----- 1 0 0 3,4 makedevs.testdir/dev/hda4 +brw-r----- 1 0 0 3,5 makedevs.testdir/dev/hda5 +brw-r----- 1 0 0 3,6 makedevs.testdir/dev/hda6 +brw-r----- 1 0 0 3,7 makedevs.testdir/dev/hda7 +brw-r----- 1 0 0 3,8 makedevs.testdir/dev/hda8 +brw-r----- 1 0 0 3,9 makedevs.testdir/dev/hda9 +brw-r----- 1 0 0 3,64 makedevs.testdir/dev/hdb +brw-r----- 1 0 0 3,65 makedevs.testdir/dev/hdb1 +brw-r----- 1 0 0 3,74 makedevs.testdir/dev/hdb10 +brw-r----- 1 0 0 3,75 makedevs.testdir/dev/hdb11 +brw-r----- 1 0 0 3,76 makedevs.testdir/dev/hdb12 +brw-r----- 1 0 0 3,77 makedevs.testdir/dev/hdb13 +brw-r----- 1 0 0 3,78 makedevs.testdir/dev/hdb14 +brw-r----- 1 0 0 3,79 makedevs.testdir/dev/hdb15 +brw-r----- 1 0 0 3,66 makedevs.testdir/dev/hdb2 +brw-r----- 1 0 0 3,67 makedevs.testdir/dev/hdb3 +brw-r----- 1 0 0 3,68 makedevs.testdir/dev/hdb4 +brw-r----- 1 0 0 3,69 makedevs.testdir/dev/hdb5 +brw-r----- 1 0 0 3,70 makedevs.testdir/dev/hdb6 +brw-r----- 1 0 0 3,71 makedevs.testdir/dev/hdb7 +brw-r----- 1 0 0 3,72 makedevs.testdir/dev/hdb8 +brw-r----- 1 0 0 3,73 makedevs.testdir/dev/hdb9 +crw-rw---- 1 0 0 13,64 makedevs.testdir/dev/input/event0 +crw-rw---- 1 0 0 13,65 makedevs.testdir/dev/input/event1 +crw-rw---- 1 0 0 13,66 makedevs.testdir/dev/input/event2 +crw-rw---- 1 0 0 13,67 makedevs.testdir/dev/input/event3 +crw-r----- 1 0 0 13,63 makedevs.testdir/dev/input/mice +crw-rw---- 1 0 0 13,32 makedevs.testdir/dev/input/mouse0 +crw-rw---- 1 0 0 13,33 makedevs.testdir/dev/input/mouse1 +crw-rw---- 1 0 0 13,34 makedevs.testdir/dev/input/mouse2 +crw-rw---- 1 0 0 13,35 makedevs.testdir/dev/input/mouse3 +crw-r----- 1 0 0 1,2 makedevs.testdir/dev/kmem +brw-r----- 1 0 0 7,0 makedevs.testdir/dev/loop0 +brw-r----- 1 0 0 7,1 makedevs.testdir/dev/loop1 +crw-r----- 1 0 0 1,1 makedevs.testdir/dev/mem +crw-r----- 1 0 0 90,0 makedevs.testdir/dev/mtd0 +crw-r----- 1 0 0 90,2 makedevs.testdir/dev/mtd1 +crw-r----- 1 0 0 90,4 makedevs.testdir/dev/mtd2 +crw-r----- 1 0 0 90,6 makedevs.testdir/dev/mtd3 +brw-r----- 1 0 0 31,0 makedevs.testdir/dev/mtdblock0 +brw-r----- 1 0 0 31,1 makedevs.testdir/dev/mtdblock1 +brw-r----- 1 0 0 31,2 makedevs.testdir/dev/mtdblock2 +brw-r----- 1 0 0 31,3 makedevs.testdir/dev/mtdblock3 +crw-rw---- 1 0 0 10,200 makedevs.testdir/dev/net/tun +crw-rw-rw- 1 0 0 1,3 makedevs.testdir/dev/null +crw-rw-rw- 1 0 0 10,1 makedevs.testdir/dev/psaux +crw-rw-rw- 1 0 0 5,2 makedevs.testdir/dev/ptmx +crw-rw-rw- 1 0 0 2,0 makedevs.testdir/dev/ptyp0 +crw-rw-rw- 1 0 0 2,1 makedevs.testdir/dev/ptyp1 +crw-rw-rw- 1 0 0 2,2 makedevs.testdir/dev/ptyp2 +crw-rw-rw- 1 0 0 2,3 makedevs.testdir/dev/ptyp3 +crw-rw-rw- 1 0 0 2,4 makedevs.testdir/dev/ptyp4 +crw-rw-rw- 1 0 0 2,5 makedevs.testdir/dev/ptyp5 +crw-rw-rw- 1 0 0 2,6 makedevs.testdir/dev/ptyp6 +crw-rw-rw- 1 0 0 2,7 makedevs.testdir/dev/ptyp7 +crw-rw-rw- 1 0 0 2,8 makedevs.testdir/dev/ptyp8 +crw-rw-rw- 1 0 0 2,9 makedevs.testdir/dev/ptyp9 +brw-r----- 1 0 0 1,1 makedevs.testdir/dev/ram +brw-r----- 1 0 0 1,0 makedevs.testdir/dev/ram0 +brw-r----- 1 0 0 1,1 makedevs.testdir/dev/ram1 +brw-r----- 1 0 0 1,2 makedevs.testdir/dev/ram2 +brw-r----- 1 0 0 1,3 makedevs.testdir/dev/ram3 +crw-rw-rw- 1 0 0 1,8 makedevs.testdir/dev/random +crw-r----- 1 0 0 10,135 makedevs.testdir/dev/rtc +crw-rw-rw- 1 0 0 5,0 makedevs.testdir/dev/tty +crw-rw-rw- 1 0 0 4,0 makedevs.testdir/dev/tty0 +crw-rw-rw- 1 0 0 4,1 makedevs.testdir/dev/tty1 +crw-rw-rw- 1 0 0 4,2 makedevs.testdir/dev/tty2 +crw-rw-rw- 1 0 0 4,3 makedevs.testdir/dev/tty3 +crw-rw-rw- 1 0 0 4,4 makedevs.testdir/dev/tty4 +crw-rw-rw- 1 0 0 4,5 makedevs.testdir/dev/tty5 +crw-rw-rw- 1 0 0 4,6 makedevs.testdir/dev/tty6 +crw-rw-rw- 1 0 0 4,7 makedevs.testdir/dev/tty7 +crw-rw-rw- 1 0 0 57,0 makedevs.testdir/dev/ttyP0 +crw-rw-rw- 1 0 0 57,1 makedevs.testdir/dev/ttyP1 +crw-rw-rw- 1 0 0 57,2 makedevs.testdir/dev/ttyP2 +crw-rw-rw- 1 0 0 57,3 makedevs.testdir/dev/ttyP3 +crw-rw-rw- 1 0 0 4,64 makedevs.testdir/dev/ttyS0 +crw-rw-rw- 1 0 0 4,65 makedevs.testdir/dev/ttyS1 +crw-rw-rw- 1 0 0 4,66 makedevs.testdir/dev/ttyS2 +crw-rw-rw- 1 0 0 4,67 makedevs.testdir/dev/ttyS3 +crw-rw-rw- 1 0 0 3,0 makedevs.testdir/dev/ttyp0 +crw-rw-rw- 1 0 0 3,1 makedevs.testdir/dev/ttyp1 +crw-rw-rw- 1 0 0 3,2 makedevs.testdir/dev/ttyp2 +crw-rw-rw- 1 0 0 3,3 makedevs.testdir/dev/ttyp3 +crw-rw-rw- 1 0 0 3,4 makedevs.testdir/dev/ttyp4 +crw-rw-rw- 1 0 0 3,5 makedevs.testdir/dev/ttyp5 +crw-rw-rw- 1 0 0 3,6 makedevs.testdir/dev/ttyp6 +crw-rw-rw- 1 0 0 3,7 makedevs.testdir/dev/ttyp7 +crw-rw-rw- 1 0 0 3,8 makedevs.testdir/dev/ttyp8 +crw-rw-rw- 1 0 0 3,9 makedevs.testdir/dev/ttyp9 +crw-rw-rw- 1 0 0 1,9 makedevs.testdir/dev/urandom +crw-rw-rw- 1 0 0 1,5 makedevs.testdir/dev/zero +" \ + "" "" + +# clean up +rm -rf makedevs.testdir + +exit $FAILCOUNT diff --git a/testsuite/md5sum/md5sum-verifies-non-binary-file b/testsuite/md5sum/md5sum-verifies-non-binary-file new file mode 100644 index 0000000..8566a23 --- /dev/null +++ b/testsuite/md5sum/md5sum-verifies-non-binary-file @@ -0,0 +1,3 @@ +touch foo +md5sum foo > bar +busybox md5sum -c bar diff --git a/testsuite/mdev.tests b/testsuite/mdev.tests new file mode 100755 index 0000000..90379e6 --- /dev/null +++ b/testsuite/mdev.tests @@ -0,0 +1,143 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# ls -ln is showing date. Need to remove that, it's variable +# sed: (1) "maj, min" -> "maj,min" (2) coalesce spaces +# cut: remove date +FILTER_LS="sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-5,9-" +# cut: remove size+date +FILTER_LS2="sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-4,9-" + +# testing "test name" "options" "expected result" "file input" "stdin" + +rm -rf mdev.testdir +mkdir mdev.testdir +# We need mdev executable to be in chroot jail! +# (will still fail with dynamically linked one, though...) +cp ../busybox mdev.testdir/mdev +mkdir mdev.testdir/bin +cp ../busybox mdev.testdir/bin/sh 2>/dev/null # for testing cmd feature +mkdir mdev.testdir/etc +mkdir mdev.testdir/dev +mkdir -p mdev.testdir/sys/block/sda +echo "8:0" >mdev.testdir/sys/block/sda/dev + +# env - PATH=$PATH: on some systems chroot binary won't otherwise be found + +testing "mdev add /block/sda" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -ln mdev.testdir/dev | $FILTER_LS" \ +"\ +brw-rw---- 1 0 0 8,0 sda +" \ + "" "" + +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf +echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf +testing "mdev stops on first rule" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -ln mdev.testdir/dev | $FILTER_LS" \ +"\ +brw-rw-rw- 1 1 1 8,0 sda +" \ + "" "" + +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +echo "sda 0:0 444 >disk/scsiA" >mdev.testdir/etc/mdev.conf +testing "mdev move/symlink rule '>bar/baz'" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -lnR mdev.testdir/dev | $FILTER_LS2" \ +"\ +mdev.testdir/dev: +drwxr-xr-x 2 0 0 disk +lrwxrwxrwx 1 0 0 sda -> disk/scsiA + +mdev.testdir/dev/disk: +br--r--r-- 1 0 0 scsiA +" \ + "" "" + +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +echo "sda 0:0 444 >disk/" >mdev.testdir/etc/mdev.conf +testing "mdev move/symlink rule '>bar/'" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -lnR mdev.testdir/dev | $FILTER_LS2" \ +"\ +mdev.testdir/dev: +drwxr-xr-x 2 0 0 disk +lrwxrwxrwx 1 0 0 sda -> disk/sda + +mdev.testdir/dev/disk: +br--r--r-- 1 0 0 sda +" \ + "" "" + +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +# here we complicate things by having non-matching group 1 and using %0 +echo "s([0-9])*d([a-z]+) 0:0 644 >sd/%2_%0" >mdev.testdir/etc/mdev.conf +testing "mdev regexp substring match + replace" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -lnR mdev.testdir/dev | $FILTER_LS2" \ +"\ +mdev.testdir/dev: +drwxr-xr-x 2 0 0 sd +lrwxrwxrwx 1 0 0 sda -> sd/a_sda + +mdev.testdir/dev/sd: +brw-r--r-- 1 0 0 a_sda +" \ + "" "" + +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf +testing "mdev command" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -lnR mdev.testdir/dev | $FILTER_LS" \ +"\ +@echo TEST +mdev.testdir/dev: +brw-r--r-- 1 0 0 8,0 sda +" \ + "" "" + +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +echo "sda 0:0 644 =block/ @echo @echo TEST" >mdev.testdir/etc/mdev.conf +testing "mdev move and command" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -lnR mdev.testdir/dev | $FILTER_LS2" \ +"\ +@echo TEST +mdev.testdir/dev: +drwxr-xr-x 2 0 0 block + +mdev.testdir/dev/block: +brw-r--r-- 1 0 0 sda +" \ + "" "" + +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +echo "@8,0 :1 644" >mdev.testdir/etc/mdev.conf +testing "mdev #maj,min and no explicit uid" \ + "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -lnR mdev.testdir/dev | $FILTER_LS" \ +"\ +mdev.testdir/dev: +brw-r--r-- 1 0 1 8,0 sda +" \ + "" "" + +# clean up +rm -rf mdev.testdir + +exit $FAILCOUNT diff --git a/testsuite/mkdir/mkdir-makes-a-directory b/testsuite/mkdir/mkdir-makes-a-directory new file mode 100644 index 0000000..6ca5c4d --- /dev/null +++ b/testsuite/mkdir/mkdir-makes-a-directory @@ -0,0 +1,2 @@ +busybox mkdir foo +test -d foo diff --git a/testsuite/mkdir/mkdir-makes-parent-directories b/testsuite/mkdir/mkdir-makes-parent-directories new file mode 100644 index 0000000..992facb --- /dev/null +++ b/testsuite/mkdir/mkdir-makes-parent-directories @@ -0,0 +1,2 @@ +busybox mkdir -p foo/bar +test -d foo -a -d foo/bar diff --git a/testsuite/mkfs.minix.tests b/testsuite/mkfs.minix.tests new file mode 100755 index 0000000..90df931 --- /dev/null +++ b/testsuite/mkfs.minix.tests @@ -0,0 +1,22 @@ +#!/bin/sh + +# mkfs.minix tests. +# Copyright 2007 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" + +testing "mkfs.minix" \ + "dd if=/dev/zero of=input bs=1k count=1024 2>/dev/null; mkfs.minix input; md5sum +# Licensed under GPL v2, see file LICENSE for details. + +if [ -z "$TESTDIR" ] +then + echo 'Need $TESTDIR' + exit 1 +fi + +cd "$TESTDIR" + +. testing.sh + +# If we aren't PID 1, barf. + +#if [ $$ -ne 1 ] +#then +# echo "SKIPPED: mount test requires emulation environment" +# exit 0 +#fi + +# Run tests within the chroot environment. +dochroot bash rm ls ln cat ps mknod mkdir dd grep cmp diff tail \ + mkfs.ext2 mkfs.vfat mount umount losetup wc << EOF +#!/bin/bash + +. /testing.sh + +mknod /dev/loop0 b 7 0 +mknod /dev/loop1 b 7 1 + +# We need /proc to do much. Make sure we can mount it explicitly. + +testing "mount no proc [GNUFAIL]" "mount 2> /dev/null || echo yes" "yes\n" "" "" +testing "mount /proc" "mount -t proc /proc /proc && ls -d /proc/1" \ + "/proc/1\n" "" "" + +# Make sure the last thing in the list is /proc + +testing "mount list1" "mount | tail -n 1" "/proc on /proc type proc (rw)\n" \ + "" "" + + +# Create an ext2 image + +mkdir -p images/{ext2.dir,vfat.dir,test1,test2,test3} +dd if=/dev/zero of=images/ext2.img bs=1M count=1 2> /dev/null +mkfs.ext2 -F -b 1024 images/ext2.img > /dev/null 2> /dev/null +dd if=/dev/zero of=images/vfat.img bs=1M count=1 2> /dev/null +mkfs.vfat images/vfat.img > /dev/null + +# Test mount it + +testing "mount vfat image (explicitly autodetect type)" \ + "mount -t auto images/vfat.img images/vfat.dir && mount | tail -n 1 | grep -o 'vfat.dir type vfat'" \ + "vfat.dir type vfat\n" "" "" +testing "mount ext2 image (autodetect type)" \ + "mount images/ext2.img images/ext2.dir 2> /dev/null && mount | tail -n 1" \ + "/dev/loop1 on /images/ext2.dir type ext2 (rw)\n" "" "" +testing "mount remount ext2 image noatime" \ + "mount -o remount,noatime images/ext2.dir && mount | tail -n 1" \ + "/dev/loop1 on /images/ext2.dir type ext2 (rw,noatime)\n" "" "" +testing "mount remount ext2 image ro remembers noatime" \ + "mount -o remount,ro images/ext2.dir && mount | tail -n 1" \ + "/dev/loop1 on /images/ext2.dir type ext2 (ro,noatime)\n" "" "" + +umount -d images/vfat.dir +umount -d images/ext2.dir + +testing "mount umount freed loop device" \ + "mount images/ext2.img images/ext2.dir && mount | tail -n 1" \ + "/dev/loop0 on /images/ext2.dir type ext2 (rw)\n" "" "" + +testing "mount block device" \ + "mount -t ext2 /dev/loop0 images/test1 && mount | tail -n 1" \ + "/dev/loop0 on /images/test1 type ext2 (rw)\n" "" "" + +umount -d images/ext2.dir images/test1 + +testing "mount remount nonexistent directory" \ + "mount -o remount,noatime images/ext2.dir 2> /dev/null || echo yes" \ + "yes\n" "" "" + +# Fun with mount -a + +testing "mount -a no fstab" "mount -a 2>/dev/null || echo yes" "yes\n" "" "" + +umount /proc + +# The first field is space delimited, the rest tabs. + +cat > /etc/fstab << FSTAB +/proc /proc proc defaults 0 0 +# Autodetect loop, and provide flags with commas in them. +/images/ext2.img /images/ext2.dir ext2 noatime,nodev 0 0 +# autodetect filesystem, flags without commas. +/images/vfat.img /images/vfat.dir auto ro 0 0 +# A block device +/dev/loop2 /images/test1 auto defaults 0 0 +# tmpfs, filesystem specific flag. +walrus /images/test2 tmpfs size=42 0 0 +# Autodetect a bind mount. +/images/test2 /images/test3 auto defaults 0 0 +FSTAB + +# Put something on loop2. +mknod /dev/loop2 b 7 2 +cat images/ext2.img > images/ext2-2.img +losetup /dev/loop2 images/ext2-2.img + +testing "mount -a" "mount -a && echo hello > /images/test2/abc && cat /images/test3/abc && (mount | wc -l)" "hello\n8\n" "" "" + +testing "umount -a" "umount -a && ls /proc" "" "" "" + +#/bin/bash < /dev/tty > /dev/tty 2> /dev/tty +mknod /dev/console c 5 1 +/bin/bash < /dev/console > /dev/console 2> /dev/console +EOF + +exit 0 + +# Run some tests + +losetup nonexistent device (should return error 2) +losetup unbound loop device (should return error 1) +losetup bind file to loop device +losetup bound loop device (display) (should return error 0) +losetup filename (error) +losetup nofile (file not found) +losetup -d +losetup bind with offset +losetup -f (print first loop device) +losetup -f filename (associate file with first loop device) +losetup -o (past end of file) -f filename + +mount -a + with multiple entries in fstab + with duplicate entries in fstab + with relative paths in fstab + with user entries in fstab +mount -o async,sync,atime,noatime,dev,nodev,exec,noexec,loop,suid,nosuid,remount,ro,rw,bind,move +mount -r +mount -o rw -r +mount -w -o ro +mount -t auto + +mount with relative path in fstab +mount block device +mount char device +mount file (autoloop) +mount directory (autobind) + + +testing "umount with no /proc" +testing "umount curdir" + +# The basic tests. These should work even with the small busybox. + +testing "sort" "input" "a\nb\nc\n" "c\na\nb\n" "" +testing "sort #2" "input" "010\n1\n3\n" "3\n1\n010\n" "" +testing "sort stdin" "" "a\nb\nc\n" "" "b\na\nc\n" +testing "sort numeric" "-n input" "1\n3\n010\n" "3\n1\n010\n" "" +testing "sort reverse" "-r input" "wook\nwalrus\npoint\npabst\naargh\n" \ + "point\nwook\npabst\naargh\nwalrus\n" "" + +optional FEATURE_MOUNT_LOOP +testing "umount -D" + +optional FEATURE_MTAB_SUPPORT +optional FEATURE_MOUNT_NFS +# No idea what to test here. + +optional UMOUNT +optional FEATURE_UMOUNT_ALL +testing "umount -a" +testing "umount -r" +testing "umount -l" +testing "umount -f" + +exit $FAILCOUNT diff --git a/testsuite/mount.tests b/testsuite/mount.tests new file mode 100755 index 0000000..5374ecb --- /dev/null +++ b/testsuite/mount.tests @@ -0,0 +1,35 @@ +#!/bin/sh + +# Copyright 2007 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +test "`id -u`" = 0 || { + echo "SKIPPED: must be root to test this" + exit 0 +} + +dd if=/dev/zero of=mount.image1m count=1 bs=1M 2>/dev/null || exit 1 +mkfs.minix -v mount.image1m >/dev/null 2>&1 || exit 1 +testdir=$PWD/testdir +mkdir $testdir 2>/dev/null +umount -d $testdir 2>/dev/null + +# testing "test name" "command" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +testing "mount -o remount,mand" \ +"mount -o loop mount.image1m $testdir "\ +"&& grep -Fc $testdir file1 +echo file number two > file2 +ln -s file2 link1 +mkdir dir1 +touch --date='Sat Jan 29 21:24:08 PST 2000' dir1/file3 +mkdir there +busybox mv file1 file2 link1 dir1 there +test -f there/file1 +test -f there/file2 +test -f there/dir1/file3 +test -L there/link1 +test xfile2 = x`readlink there/link1` +test ! -e file1 +test ! -e file2 +test ! -e link1 +test ! -e dir1/file3 diff --git a/testsuite/mv/mv-follows-links b/testsuite/mv/mv-follows-links new file mode 100644 index 0000000..1fb355b --- /dev/null +++ b/testsuite/mv/mv-follows-links @@ -0,0 +1,4 @@ +touch foo +ln -s foo bar +busybox mv bar baz +test -f baz diff --git a/testsuite/mv/mv-moves-empty-file b/testsuite/mv/mv-moves-empty-file new file mode 100644 index 0000000..48afca4 --- /dev/null +++ b/testsuite/mv/mv-moves-empty-file @@ -0,0 +1,4 @@ +touch foo +busybox mv foo bar +test ! -e foo +test -f bar diff --git a/testsuite/mv/mv-moves-file b/testsuite/mv/mv-moves-file new file mode 100644 index 0000000..edb4c37 --- /dev/null +++ b/testsuite/mv/mv-moves-file @@ -0,0 +1,3 @@ +touch foo +busybox mv foo bar +test ! -f foo -a -f bar diff --git a/testsuite/mv/mv-moves-hardlinks b/testsuite/mv/mv-moves-hardlinks new file mode 100644 index 0000000..eaa8215 --- /dev/null +++ b/testsuite/mv/mv-moves-hardlinks @@ -0,0 +1,4 @@ +touch foo +ln foo bar +busybox mv bar baz +test ! -f bar -a -f baz diff --git a/testsuite/mv/mv-moves-large-file b/testsuite/mv/mv-moves-large-file new file mode 100644 index 0000000..77d088f --- /dev/null +++ b/testsuite/mv/mv-moves-large-file @@ -0,0 +1,4 @@ +dd if=/dev/zero of=foo seek=10k count=1 2>/dev/null +busybox mv foo bar +test ! -e foo +test -f bar diff --git a/testsuite/mv/mv-moves-small-file b/testsuite/mv/mv-moves-small-file new file mode 100644 index 0000000..065c7f1 --- /dev/null +++ b/testsuite/mv/mv-moves-small-file @@ -0,0 +1,4 @@ +echo I WANT > foo +busybox mv foo bar +test ! -e foo +test -f bar diff --git a/testsuite/mv/mv-moves-symlinks b/testsuite/mv/mv-moves-symlinks new file mode 100644 index 0000000..c413af0 --- /dev/null +++ b/testsuite/mv/mv-moves-symlinks @@ -0,0 +1,6 @@ +touch foo +ln -s foo bar +busybox mv bar baz +test -f foo +test ! -e bar +test -L baz diff --git a/testsuite/mv/mv-moves-unreadable-files b/testsuite/mv/mv-moves-unreadable-files new file mode 100644 index 0000000..bc9c313 --- /dev/null +++ b/testsuite/mv/mv-moves-unreadable-files @@ -0,0 +1,5 @@ +touch foo +chmod a-r foo +busybox mv foo bar +test ! -e foo +test -f bar diff --git a/testsuite/mv/mv-preserves-hard-links b/testsuite/mv/mv-preserves-hard-links new file mode 100644 index 0000000..b3ba3aa --- /dev/null +++ b/testsuite/mv/mv-preserves-hard-links @@ -0,0 +1,6 @@ +# FEATURE: CONFIG_FEATURE_PRESERVE_HARDLINKS +touch foo +ln foo bar +mkdir baz +busybox mv foo bar baz +test baz/foo -ef baz/bar diff --git a/testsuite/mv/mv-preserves-links b/testsuite/mv/mv-preserves-links new file mode 100644 index 0000000..ea565d2 --- /dev/null +++ b/testsuite/mv/mv-preserves-links @@ -0,0 +1,5 @@ +touch foo +ln -s foo bar +busybox mv bar baz +test -L baz +test xfoo = x`readlink baz` diff --git a/testsuite/mv/mv-refuses-mv-dir-to-subdir b/testsuite/mv/mv-refuses-mv-dir-to-subdir new file mode 100644 index 0000000..7c572c4 --- /dev/null +++ b/testsuite/mv/mv-refuses-mv-dir-to-subdir @@ -0,0 +1,23 @@ +echo file number one > file1 +echo file number two > file2 +ln -s file2 link1 +mkdir dir1 +touch --date='Sat Jan 29 21:24:08 PST 2000' dir1/file3 +mkdir there +busybox mv file1 file2 link1 dir1 there +test -f there/file1 +test -f there/file2 +test -f there/dir1/file3 +test -L there/link1 +test xfile2 = x`readlink there/link1` +test ! -e file1 +test ! -e file2 +test ! -e link1 +test ! -e dir1/file3 +set +e +busybox mv there there/dir1 +if [ $? != 0 ] ; then + exit 0; +fi + +exit 1; diff --git a/testsuite/mv/mv-removes-source-file b/testsuite/mv/mv-removes-source-file new file mode 100644 index 0000000..48afca4 --- /dev/null +++ b/testsuite/mv/mv-removes-source-file @@ -0,0 +1,4 @@ +touch foo +busybox mv foo bar +test ! -e foo +test -f bar diff --git a/testsuite/od.tests b/testsuite/od.tests new file mode 100755 index 0000000..69c2995 --- /dev/null +++ b/testsuite/od.tests @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" + +testing "od -b" \ + "od -b" \ +"\ +0000000 110 105 114 114 117 +0000006 +" \ + "" "HELLO" + +exit $FAILCOUNT diff --git a/testsuite/parse.tests b/testsuite/parse.tests new file mode 100755 index 0000000..f1ee7b8 --- /dev/null +++ b/testsuite/parse.tests @@ -0,0 +1,109 @@ +#!/bin/sh + +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +COLLAPSE=$(( 0x00010000)) +TRIM=$(( 0x00020000)) +GREEDY=$(( 0x00040000)) +MIN_DIE=$(( 0x00100000)) +KEEP_COPY=$((0x00200000)) +ESCAPE=$(( 0x00400000)) +NORMAL=$(( COLLAPSE | TRIM | GREEDY)) + +# testing "description" "command" "result" "infile" "stdin" + +testing "parse mdev.conf" \ + "parse -n 4 -m 3 -f $((NORMAL)) -" \ + "[sda][0:0][644][@echo @echo TEST]\n" \ + "-" \ + " sda 0:0 644 @echo @echo TEST # echo trap\n" + +testing "parse notrim" \ + "parse -n 4 -m 3 -f $((NORMAL - TRIM - COLLAPSE)) -" \ + "[][sda][0:0][644 @echo @echo TEST ]\n" \ + "-" \ + " sda 0:0 644 @echo @echo TEST \n" + +FILE=__parse +cat >$FILE <$FILE.res <$FILE.res <$FILE.res < /dev/null; echo \$?" \ + "0\n" "" "" +# We can get away with this because it says #!/bin/sh up top. + +testing "pidof this" "pidof pidof.tests | grep -o -w $$" "$$\n" "" "" + +optional FEATURE_PIDOF_SINGLE +testing "pidof -s" "pidof -s init" "1\n" "" "" + +optional FEATURE_PIDOF_OMIT +# This test fails now because process name matching logic has changed, +# but new logic is not "wrong" either... see find_pid_by_name.c comments +#testing "pidof -o %PPID" "pidof -o %PPID pidof.tests | grep -o -w $$" "" "" "" +testing "pidof -o %PPID NOP" "pidof -o %PPID -s init" "1\n" "" "" +testing "pidof -o init" "pidof -o 1 init | grep -o -w 1" "" "" "" + +exit $FAILCOUNT diff --git a/testsuite/printf.tests b/testsuite/printf.tests new file mode 100755 index 0000000..f9d1dec --- /dev/null +++ b/testsuite/printf.tests @@ -0,0 +1,108 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# Need this in order to not execute shell builtin +bb="busybox " + +# testing "test name" "command" "expected result" "file input" "stdin" + +testing "printf produces no further output 1" \ + "${bb}printf '\c' foo" \ + "" \ + "" "" + +testing "printf produces no further output 2" \ + "${bb}printf '%s\c' foo bar" \ + "foo" \ + "" "" + +testing "printf repeatedly uses pattern for each argv" \ + "${bb}printf '%s\n' foo \$HOME" \ + "foo\n$HOME\n" \ + "" "" + +testing "printf understands %b escaped_string" \ + "${bb}printf '%b' 'a\tb' 'c\\d\n' 2>&1; echo \$?" \ + "a\tbc\\d\n""0\n" \ + "" "" + +testing "printf understands %d '\"x' \"'y\" \"'zTAIL\"" \ + "${bb}printf '%d\n' '\"x' \"'y\" \"'zTAIL\" 2>&1; echo \$?" \ + "120\n""121\n""122\n""0\n" \ + "" "" + +testing "printf understands %s '\"x' \"'y\" \"'zTAIL\"" \ + "${bb}printf '%s\n' '\"x' \"'y\" \"'zTAIL\" 2>&1; echo \$?" \ + "\"x\n""'y\n""'zTAIL\n""0\n" \ + "" "" + +testing "printf understands %23.12f" \ + "${bb}printf '|%23.12f|\n' 5.25 2>&1; echo \$?" \ + "| 5.250000000000|\n""0\n" \ + "" "" + +testing "printf understands %*.*f" \ + "${bb}printf '|%*.*f|\n' 23 12 5.25 2>&1; echo \$?" \ + "| 5.250000000000|\n""0\n" \ + "" "" + +testing "printf understands %*f with negative width" \ + "${bb}printf '|%*f|\n' -23 5.25 2>&1; echo \$?" \ + "|5.250000 |\n""0\n" \ + "" "" + +testing "printf understands %.*f with negative precision" \ + "${bb}printf '|%.*f|\n' -12 5.25 2>&1; echo \$?" \ + "|5.250000|\n""0\n" \ + "" "" + +testing "printf understands %*.*f with negative width/precision" \ + "${bb}printf '|%*.*f|\n' -23 -12 5.25 2>&1; echo \$?" \ + "|5.250000 |\n""0\n" \ + "" "" + +testing "printf understands %zd" \ + "${bb}printf '%zd\n' -5 2>&1; echo \$?" \ + "-5\n""0\n" \ + "" "" + +testing "printf understands %ld" \ + "${bb}printf '%ld\n' -5 2>&1; echo \$?" \ + "-5\n""0\n" \ + "" "" + +testing "printf understands %Ld" \ + "${bb}printf '%Ld\n' -5 2>&1; echo \$?" \ + "-5\n""0\n" \ + "" "" + +# We are "more correct" here than bash/coreutils: they happily print -2 +# as if it is a huge unsigned number +testing "printf handles %u -N" \ + "${bb}printf '%u\n' 1 -2 3 2>&1; echo \$?" \ + "1\n""printf: -2: invalid number\n""0\n""3\n""0\n" \ + "" "" + +# Actually, we are wrong here: exit code should be 1 +testing "printf handles %d bad_input" \ + "${bb}printf '%d\n' 1 - 2 bad 3 123bad 4 2>&1; echo \$?" \ +"1\n""printf: -: invalid number\n""0\n"\ +"2\n""printf: bad: invalid number\n""0\n"\ +"3\n""printf: 123bad: invalid number\n""0\n"\ +"4\n""0\n" \ + "" "" + +testing "printf aborts on bare %" \ + "${bb}printf '%' a b c 2>&1; echo \$?" \ + "printf: %: invalid format\n""1\n" \ + "" "" + +testing "printf aborts on %r" \ + "${bb}printf '%r' a b c 2>&1; echo \$?" \ + "printf: %r: invalid format\n""1\n" \ + "" "" + +exit $FAILCOUNT diff --git a/testsuite/pwd/pwd-prints-working-directory b/testsuite/pwd/pwd-prints-working-directory new file mode 100644 index 0000000..8575347 --- /dev/null +++ b/testsuite/pwd/pwd-prints-working-directory @@ -0,0 +1 @@ +test $(pwd) = $(busybox pwd) diff --git a/testsuite/readlink.tests b/testsuite/readlink.tests new file mode 100755 index 0000000..0faa6ed --- /dev/null +++ b/testsuite/readlink.tests @@ -0,0 +1,32 @@ +#!/bin/sh + +# Readlink tests. +# Copyright 2006 by Natanael Copa +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +TESTDIR=readlink_testdir +TESTFILE="$TESTDIR/testfile" +TESTLINK="testlink" +FAILLINK="$TESTDIR/$TESTDIR/testlink" + +# create the dir and test files +mkdir -p "./$TESTDIR" +touch "./$TESTFILE" +ln -s "./$TESTFILE" "./$TESTLINK" + +testing "readlink on a file" "readlink ./$TESTFILE" "" "" "" +testing "readlink on a link" "readlink ./$TESTLINK" "./$TESTFILE\n" "" "" + +optional FEATURE_READLINK_FOLLOW + +testing "readlink -f on a file" "readlink -f ./$TESTFILE" "$PWD/$TESTFILE\n" "" "" +testing "readlink -f on a link" "readlink -f ./$TESTLINK" "$PWD/$TESTFILE\n" "" "" +testing "readlink -f on an invalid link" "readlink -f ./$FAILLINK" "" "" "" +testing "readlink -f on a wierd dir" "readlink -f $TESTDIR/../$TESTFILE" "$PWD/$TESTFILE\n" "" "" + + +# clean up +rm -r "$TESTLINK" "$TESTDIR" + diff --git a/testsuite/rm/rm-removes-file b/testsuite/rm/rm-removes-file new file mode 100644 index 0000000..46571a9 --- /dev/null +++ b/testsuite/rm/rm-removes-file @@ -0,0 +1,3 @@ +touch foo +busybox rm foo +test ! -f foo diff --git a/testsuite/rmdir/rmdir-removes-parent-directories b/testsuite/rmdir/rmdir-removes-parent-directories new file mode 100644 index 0000000..222f5de --- /dev/null +++ b/testsuite/rmdir/rmdir-removes-parent-directories @@ -0,0 +1,3 @@ +mkdir -p foo/bar +busybox rmdir -p foo/bar +test ! -d foo diff --git a/testsuite/runtest b/testsuite/runtest new file mode 100755 index 0000000..cade871 --- /dev/null +++ b/testsuite/runtest @@ -0,0 +1,164 @@ +#!/bin/sh + +# Usage: +# runtest [applet1] [applet2...] + +# Helper for helpers. Oh my... +test x"$ECHO" != x"" || { + ECHO="echo" + test x"`echo -ne`" = x"" || { + # Compile and use a replacement 'echo' which understands -e -n + ECHO="$PWD/echo-ne" + test -x "$ECHO" || { + gcc -Os -o "$ECHO" ../scripts/echo.c || exit 1 + } + } + export ECHO +} + +# Run one old-style test. +# Tests are stored in applet/testcase shell scripts. +# They are run using "sh -x -e applet/testcase". +# Option -e will make testcase stop on the first failed command. +run_applet_testcase() +{ + local applet="$1" + local testcase="$2" + + local status=0 + local uc_applet=$(echo "$applet" | tr a-z A-Z) + local testname="$testcase" + + testname="${testname##*/}" # take basename + if grep "^# CONFIG_$uc_applet is not set$" "$bindir/.config" >/dev/null; then + echo "UNTESTED: $testname" + return 0 + fi + + if grep "^# FEATURE: " "$testcase" >/dev/null; then + local feature=$(sed -ne 's/^# FEATURE: //p' "$testcase") + + if grep "^# $feature is not set$" "$bindir/.config" >/dev/null; then + echo "UNTESTED: $testname" + return 0 + fi + fi + + rm -rf ".tmpdir.$applet" + mkdir -p ".tmpdir.$applet" + cd ".tmpdir.$applet" || return 1 + +# echo "Running testcase $testcase" + d="$tsdir" \ + sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1 || status=$? + if [ $status -ne 0 ]; then + echo "FAIL: $testname" + if [ x"$VERBOSE" != x ]; then + cat "$testname.stdout.txt" + fi + else + echo "PASS: $testname" + fi + + cd .. + rm -rf ".tmpdir.$applet" + + return $status +} + +# Run all old-style tests for given applet +run_oldstyle_applet_tests() +{ + local applet="$1" + local status=0 + + for testcase in "$tsdir/$applet"/*; do + # switch on basename of $testcase + case "${testcase##*/}" in + .*) continue ;; # .svn, .git etc + *~) continue ;; # backup files + "CVS") continue ;; + \#*) continue ;; # CVS merge residues + *.mine) continue ;; # svn-produced junk + *.r[0-9]*) continue ;; # svn-produced junk + esac + run_applet_testcase "$applet" "$testcase" || status=1 + done + return $status +} + + + +lcwd=$(pwd) +[ x"$tsdir" != x ] || tsdir="$lcwd" +[ x"$bindir" != x ] || bindir="${lcwd%/*}" # one directory up from $lcwd +PATH="$bindir:$PATH" + +if [ x"$VERBOSE" = x ]; then + export VERBOSE= +fi + +if [ x"$1" = x"-v" ]; then + export VERBOSE=1 + shift +fi + +implemented=$( + "$bindir/busybox" 2>&1 | + while read line; do + if [ x"$line" = x"Currently defined functions:" ]; then + xargs | sed 's/,//g' + break + fi + done + ) + +applets="$implemented" +if [ $# -ne 0 ]; then + applets="$@" +fi + +# Populate a directory with links to all busybox applets + +LINKSDIR="$bindir/runtest-tempdir-links" +rm -rf "$LINKSDIR" 2>/dev/null +mkdir "$LINKSDIR" +for i in $implemented; do + ln -s "$bindir/busybox" "$LINKSDIR/$i" +done + +# Set up option flags so tests can be selective. +export OPTIONFLAGS=:$( + sed -nr 's/^CONFIG_//p' "$bindir/.config" | + sed 's/=.*//' | xargs | sed 's/ /:/g' + ) + +status=0 +for applet in $applets; do + # Any old-style tests for this applet? + if [ -d "$tsdir/$applet" ]; then + run_oldstyle_applet_tests "$applet" || status=1 + fi + + # Is this a new-style test? + if [ -f "$applet.tests" ]; then + if [ ! -h "$LINKSDIR/$applet" ]; then + # (avoiding bash'ism "${applet:0:4}") + if ! echo "$applet" | grep "^all_" >/dev/null; then + echo "SKIPPED: $applet (not built)" + continue + fi + fi +# echo "Running test $tsdir/$applet.tests" + PATH="$LINKSDIR:$tsdir:$bindir:$PATH" \ + "$tsdir/$applet.tests" || status=1 + fi +done + +# Leaving the dir makes it somewhat easier to run failed test by hand +#rm -rf "$LINKSDIR" + +if [ $status -ne 0 ] && [ x"$VERBOSE" = x ]; then + echo "Failures detected, running with -v (verbose) will give more info" +fi +exit $status diff --git a/testsuite/sed.tests b/testsuite/sed.tests new file mode 100755 index 0000000..9a7f886 --- /dev/null +++ b/testsuite/sed.tests @@ -0,0 +1,210 @@ +#!/bin/sh + +# SUSv3 compliant sed tests. +# Copyright 2005 by Rob Landley +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "description" "arguments" "result" "infile" "stdin" + +# Corner cases +testing "sed no files (stdin)" 'sed ""' "hello\n" "" "hello\n" +testing "sed explicit stdin" 'sed "" -' "hello\n" "" "hello\n" +testing "sed handles empty lines" "sed -e 's/\$/@/'" "@\n" "" "\n" +testing "sed stdin twice" 'sed "" - -' "hello" "" "hello" + +# Trailing EOF. +# Match $, at end of each file or all files? + +# -e corner cases +# without -e +# multiple -e +# interact with a +# -eee arg1 arg2 arg3 +# -f corner cases +# -e -f -e +# -n corner cases +# no newline at EOF? +# -r corner cases +# Just make sure it works. +# -i corner cases: +# sed -i - +# permissions +# -i on a symlink +# on a directory +# With $ last-line test +# Continue with \ +# End of script with trailing \ + +# command list +testing "sed accepts blanks before command" "sed -e '1 d'" "" "" "" +testing "sed accepts newlines in -e" "sed -e 'i\ +1 +a\ +3'" "1\n2\n3\n" "" "2\n" +testing "sed accepts multiple -e" "sed -e 'i\' -e '1' -e 'a\' -e '3'" \ + "1\n2\n3\n" "" "2\n" + +# substitutions +testing "sed -n" "sed -n -e s/foo/bar/ -e s/bar/baz/" "" "" "foo\n" +testing "sed s//p" "sed -e s/foo/bar/p -e s/bar/baz/p" "bar\nbaz\nbaz\n" \ + "" "foo\n" +testing "sed -n s//p" "sed -ne s/abc/def/p" "def\n" "" "abc\n" +testing "sed s//g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5,\n" \ + "" "12345\n" +testing "sed s arbitrary delimiter" "sed -e 's woo boing '" "boing\n" "" "woo\n" +testing "sed s chains" "sed -e s/foo/bar/ -e s/bar/baz/" "baz\n" "" "foo\n" +testing "sed s chains2" "sed -e s/foo/bar/ -e s/baz/nee/" "bar\n" "" "foo\n" +testing "sed s [delimiter]" "sed -e 's@[@]@@'" "onetwo" "" "one@two" +testing "sed s with \\t (GNU ext)" "sed 's/\t/ /'" "one two" "" "one\ttwo" + +# branch +testing "sed b (branch)" "sed -e 'b one;p;: one'" "foo\n" "" "foo\n" +testing "sed b (branch with no label jumps to end)" "sed -e 'b;p'" \ + "foo\n" "" "foo\n" + +# test and branch +testing "sed t (test/branch)" "sed -e 's/a/1/;t one;p;: one;p'" \ + "1\n1\nb\nb\nb\nc\nc\nc\n" "" "a\nb\nc\n" +testing "sed t (test/branch clears test bit)" "sed -e 's/a/b/;:loop;t loop'" \ + "b\nb\nc\n" "" "a\nb\nc\n" +testing "sed T (!test/branch)" "sed -e 's/a/1/;T notone;p;: notone;p'" \ + "1\n1\n1\nb\nb\nc\nc\n" "" "a\nb\nc\n" + +# Normal sed end-of-script doesn't print "c" because n flushed the pattern +# space. If n hits EOF, pattern space is empty when script ends. +# Query: how does this interact with no newline at EOF? +testing "sed n (flushes pattern space, terminates early)" "sed -e 'n;p'" \ + "a\nb\nb\nc\n" "" "a\nb\nc\n" +# N does _not_ flush pattern space, therefore c is still in there @ script end. +testing "sed N (doesn't flush pattern space when terminating)" "sed -e 'N;p'" \ + "a\nb\na\nb\nc\n" "" "a\nb\nc\n" +testing "sed address match newline" 'sed "/b/N;/b\\nc/i woo"' \ + "a\nwoo\nb\nc\nd\n" "" "a\nb\nc\nd\n" + +# Multiple lines in pattern space +testing "sed N (stops at end of input) and P (prints to first newline only)" \ + "sed -n 'N;P;p'" "a\na\nb\n" "" "a\nb\nc\n" + +# Hold space +testing "sed G (append hold space to pattern space)" 'sed G' "a\n\nb\n\nc\n\n" \ + "" "a\nb\nc\n" +#testing "sed g/G (swap/append hold and patter space)" +#testing "sed g (swap hold/pattern space)" + +testing "sed d ends script iteration" \ + "sed -e '/ook/d;s/ook/ping/p;i woot'" "" "" "ook\n" +testing "sed d ends script iteration (2)" \ + "sed -e '/ook/d;a\' -e 'bang'" "woot\nbang\n" "" "ook\nwoot\n" + +# Multiple files, with varying newlines and NUL bytes +testing "sed embedded NUL" "sed -e 's/woo/bang/'" "\0bang\0woo\0" "" \ + "\0woo\0woo\0" +testing "sed embedded NUL g" "sed -e 's/woo/bang/g'" "bang\0bang\0" "" \ + "woo\0woo\0" +echo -e "/woo/a he\0llo" > sed.commands +testing "sed NUL in command" "sed -f sed.commands" "woo\nhe\0llo\n" "" "woo" +rm sed.commands + +# sed has funky behavior with newlines at the end of file. Test lots of +# corner cases with the optional newline appending behavior. + +testing "sed normal newlines" "sed -e 's/woo/bang/' input -" "bang\nbang\n" \ + "woo\n" "woo\n" +testing "sed leave off trailing newline" "sed -e 's/woo/bang/' input -" \ + "bang\nbang" "woo\n" "woo" +testing "sed autoinsert newline" "sed -e 's/woo/bang/' input -" "bang\nbang" \ + "woo" "woo" +testing "sed empty file plus cat" "sed -e 's/nohit//' input -" "one\ntwo" \ + "" "one\ntwo" +testing "sed cat plus empty file" "sed -e 's/nohit//' input -" "one\ntwo" \ + "one\ntwo" "" +testing "sed append autoinserts newline" "sed -e '/woot/a woo' -" \ + "woot\nwoo\n" "" "woot" +testing "sed insert doesn't autoinsert newline" "sed -e '/woot/i woo' -" \ + "woo\nwoot" "" "woot" +testing "sed print autoinsert newlines" "sed -e 'p' -" "one\none" "" "one" +testing "sed print autoinsert newlines two files" "sed -e 'p' input -" \ + "one\none\ntwo\ntwo" "one" "two" +testing "sed noprint, no match, no newline" "sed -ne 's/woo/bang/' input" \ + "" "no\n" "" +testing "sed selective matches with one nl" "sed -ne 's/woo/bang/p' input -" \ + "a bang\nc bang\n" "a woo\nb no" "c woo\nd no" +testing "sed selective matches insert newline" \ + "sed -ne 's/woo/bang/p' input -" "a bang\nb bang\nd bang" \ + "a woo\nb woo" "c no\nd woo" +testing "sed selective matches noinsert newline" \ + "sed -ne 's/woo/bang/p' input -" "a bang\nb bang" "a woo\nb woo" \ + "c no\nd no" +testing "sed clusternewline" \ + "sed -e '/one/a 111' -e '/two/i 222' -e p input -" \ + "one\none\n111\n222\ntwo\ntwo" "one" "two" +testing "sed subst+write" \ + "sed -e 's/i/z/' -e 'woutputw' input -; echo -n X; cat outputw" \ + "thzngy\nagaznXthzngy\nagazn" "thingy" "again" +rm outputw +testing "sed trailing NUL" \ + "sed 's/i/z/' input -" \ + "a\0b\0\nc" "a\0b\0" "c" +testing "sed escaped newline in command" \ + "sed 's/a/z\\ +z/' input" \ + "z\nz" "a" "" + +# Test end-of-file matching behavior + +testing "sed match EOF" "sed -e '"'$p'"'" "hello\nthere\nthere" "" \ + "hello\nthere" +testing "sed match EOF two files" "sed -e '"'$p'"' input -" \ + "one\ntwo\nthree\nfour\nfour" "one\ntwo" "three\nfour" +# sed match EOF inline: gnu sed 4.1.5 outputs this: +#00000000 6f 6e 65 0a 6f 6f 6b 0a 6f 6f 6b 0a 74 77 6f 0a |one.ook.ook.two.| +#00000010 0a 74 68 72 65 65 0a 6f 6f 6b 0a 6f 6f 6b 0a 66 |.three.ook.ook.f| +#00000020 6f 75 72 |our| +# which looks buggy to me. +$ECHO -ne "three\nfour" > input2 +testing "sed match EOF inline" \ + "sed -e '"'$i ook'"' -i input input2 && cat input input2" \ + "one\nook\ntwothree\nook\nfour" "one\ntwo" "" +rm input2 + +# Test lie-to-autoconf + +testing "sed lie-to-autoconf" "sed --version | grep -o 'GNU sed version '" \ + "GNU sed version \n" "" "" + +# Jump to nonexistent label +testing "sed nonexistent label" "sed -e 'b walrus' 2> /dev/null || echo yes" \ + "yes\n" "" "" + +testing "sed backref from empty s uses range regex" \ + "sed -e '/woot/s//eep \0 eep/'" "eep woot eep" "" "woot" + +testing "sed backref from empty s uses range regex with newline" \ + "sed -e '/woot/s//eep \0 eep/'" "eep woot eep\n" "" "woot\n" + +# -i with no filename + +touch ./- # Detect gnu failure mode here. +testing "sed -i with no arg [GNUFAIL]" "sed -e '' -i 2> /dev/null || echo yes" \ + "yes\n" "" "" +rm ./- # Clean up + +testing "sed s/xxx/[/" "sed -e 's/xxx/[/'" "[\n" "" "xxx\n" + +# Ponder this a bit more, why "woo not found" from gnu version? +#testing "sed doesn't substitute in deleted line" \ +# "sed -e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n" + +# This makes both seds very unhappy. Why? +#testing "sed -g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5," \ +# "" "12345" + +# testing "description" "arguments" "result" "infile" "stdin" + +testing "sed n command must reset 'substituted' bit" \ + "sed 's/1/x/;T;n;: next;s/3/y/;t quit;n;b next;: quit;q'" \ + "0\nx\n2\ny\n" "" "0\n1\n2\n3\n" + +exit $FAILCOUNT diff --git a/testsuite/seq.tests b/testsuite/seq.tests new file mode 100755 index 0000000..ebb44e7 --- /dev/null +++ b/testsuite/seq.tests @@ -0,0 +1,36 @@ +#!/bin/sh + +# SUSv3 compliant seq tests. +# Copyright 2006 by Rob Landley +# Licensed under GPL v2, see file LICENSE for details. + +# AUDIT: Full SUSv3 coverage (except internationalization). + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +# Test exit status + +testing "seq (exit with error)" "seq 2> /dev/null || echo yes" "yes\n" "" "" +testing "seq (exit with error)" "seq 1 2 3 4 2> /dev/null || echo yes" \ + "yes\n" "" "" +testing "seq one argument" "seq 3" "1\n2\n3\n" "" "" +testing "seq two arguments" "seq 5 7" "5\n6\n7\n" "" "" +testing "seq two arguments reversed" "seq 7 5" "" "" "" +testing "seq two arguments equal" "seq 3 3" "3\n" "" "" +testing "seq two arguments equal, arbitrary negative step" "seq 1 -15 1" \ + "1\n" "" "" +testing "seq two arguments equal, arbitrary positive step" "seq 1 +15 1" \ + "1\n" "" "" +testing "seq count up by 2" "seq 4 2 8" "4\n6\n8\n" "" "" +testing "seq count down by 2" "seq 8 -2 4" "8\n6\n4\n" "" "" +testing "seq count wrong way #1" "seq 4 -2 8" "" "" "" +testing "seq count wrong way #2" "seq 8 2 4" "" "" "" +testing "seq count by .3" "seq 3 .3 4" "3\n3.3\n3.6\n3.9\n" "" "" +testing "seq count by -.9" "seq .7 -.9 -2.2" "0.7\n-0.2\n-1.1\n-2\n" "" "" +testing "seq count by zero" "seq 4 0 8 | head -n 10" "" "" "" + +exit $FAILCOUNT diff --git a/testsuite/sort.tests b/testsuite/sort.tests new file mode 100755 index 0000000..f700dc0 --- /dev/null +++ b/testsuite/sort.tests @@ -0,0 +1,119 @@ +#!/bin/bash + +# SUSv3 compliant sort tests. +# Copyright 2005 by Rob Landley +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# The basic tests. These should work even with the small busybox. + +testing "sort" "sort input" "a\nb\nc\n" "c\na\nb\n" "" +testing "sort #2" "sort input" "010\n1\n3\n" "3\n1\n010\n" "" +testing "sort stdin" "sort" "a\nb\nc\n" "" "b\na\nc\n" +testing "sort numeric" "sort -n input" "1\n3\n010\n" "3\n1\n010\n" "" +testing "sort reverse" "sort -r input" "wook\nwalrus\npoint\npabst\naargh\n" \ + "point\nwook\npabst\naargh\nwalrus\n" "" + +# These tests require the full option set. + +optional FEATURE_SORT_BIG +# Longish chunk of data re-used by the next few tests + +data="42 1 3 woot +42 1 010 zoology +egg 1 2 papyrus +7 3 42 soup +999 3 0 algebra +" + +# Sorting with keys + +testing "sort one key" "sort -k4,4 input" \ +"999 3 0 algebra +egg 1 2 papyrus +7 3 42 soup +42 1 3 woot +42 1 010 zoology +" "$data" "" + +testing "sort key range with numeric option" "sort -k2,3n input" \ +"42 1 010 zoology +42 1 3 woot +egg 1 2 papyrus +7 3 42 soup +999 3 0 algebra +" "$data" "" + +# Busybox is definitely doing this one wrong just now. FIXME + +testing "sort key range with numeric option and global reverse" \ +"sort -k2,3n -r input" \ +"egg 1 2 papyrus +42 1 3 woot +42 1 010 zoology +999 3 0 algebra +7 3 42 soup +" "$data" "" + +# + +testing "sort key range with multiple options" "sort -k2,3rn input" \ +"7 3 42 soup +999 3 0 algebra +42 1 010 zoology +42 1 3 woot +egg 1 2 papyrus +" "$data" "" + +testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\ +d 2 +b 2 +c 3 +" "\ +c 3 +b 2 +d 2 +" "" + +testing "sort with non-default leading delim 1" "sort -n -k2 -t/ input" "\ +/a/2 +/b/1 +" "\ +/a/2 +/b/1 +" "" + +testing "sort with non-default leading delim 2" "sort -n -k3 -t/ input" "\ +/b/1 +/a/2 +" "\ +/b/1 +/a/2 +" "" + +testing "sort with non-default leading delim 3" "sort -n -k3 -t/ input" "\ +//a/2 +//b/1 +" "\ +//a/2 +//b/1 +" "" + +testing "sort -u should consider field only when discarding" "sort -u -k2 input" "\ +a c +" "\ +a c +b c +" "" + +testing "sort -z outputs NUL terminated lines" "sort -z input" "\ +one\0three\0two\0\ +" "\ +one\0two\0three\0\ +" "" + +testing "sort key doesn't strip leading blanks, disables fallback global sort" \ +"sort -n -k2 -t ' '" " a \n 1 \n 2 \n" "" " 2 \n 1 \n a \n" + +exit $FAILCOUNT diff --git a/testsuite/start-stop-daemon.tests b/testsuite/start-stop-daemon.tests new file mode 100755 index 0000000..ba77cde --- /dev/null +++ b/testsuite/start-stop-daemon.tests @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "cmd" "expected result" "file input" "stdin" + +testing "start-stop-daemon -x without -a" \ + 'start-stop-daemon -S -x true 2>&1; echo $?' \ + "0\n" \ + "" "" + +testing "start-stop-daemon -a without -x" \ + 'start-stop-daemon -S -a false 2>&1; echo $?' \ + "1\n" \ + "" "" + +exit $FAILCOUNT diff --git a/testsuite/strings/strings-works-like-GNU b/testsuite/strings/strings-works-like-GNU new file mode 100644 index 0000000..2d64710 --- /dev/null +++ b/testsuite/strings/strings-works-like-GNU @@ -0,0 +1,9 @@ +rm -f foo bar +strings -af ../../busybox > foo +busybox strings -af ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi diff --git a/testsuite/sum.tests b/testsuite/sum.tests new file mode 100755 index 0000000..e537cf6 --- /dev/null +++ b/testsuite/sum.tests @@ -0,0 +1,24 @@ +#!/bin/sh + +# unit test for sum. +# Copyright 2007 by Bernhard Reutner-Fischer +# Licensed under GPL v2 or later, see file LICENSE for details. + +# AUDIT: Unit tests for sum + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +testing "sum -r file doesn't print file's name" \ + "sum -r $0 | grep -c $0 && echo wrongly_printed_filename || echo yes" \ + "0\nyes\n" "" "" +testing "sum -r file file does print both names" \ + "sum -r $0 $0 | grep -c $0 && echo yes || echo wrongly_omitted_filename" \ + "2\nyes\n" "" "" +testing "sum -s file does print file's name" \ + "sum -s $0 | grep -c $0 && echo yes || echo wrongly_omitted_filename" \ + "1\nyes\n" "" "" +exit $FAILCOUNT diff --git a/testsuite/tail/tail-n-works b/testsuite/tail/tail-n-works new file mode 100644 index 0000000..0e1319f --- /dev/null +++ b/testsuite/tail/tail-n-works @@ -0,0 +1,4 @@ +$ECHO -ne "abc\ndef\n123\n" >input +$ECHO -ne "def\n123\n" >logfile.ok +busybox tail -n 2 input > logfile.bb +cmp logfile.ok logfile.bb diff --git a/testsuite/tail/tail-works b/testsuite/tail/tail-works new file mode 100644 index 0000000..f3434d1 --- /dev/null +++ b/testsuite/tail/tail-works @@ -0,0 +1,4 @@ +$ECHO -ne "abc\ndef\n123\n" >input +$ECHO -ne "def\n123\n" >logfile.ok +busybox tail -2 input > logfile.bb +cmp logfile.ok logfile.bb diff --git a/testsuite/tar/tar-archives-multiple-files b/testsuite/tar/tar-archives-multiple-files new file mode 100644 index 0000000..245d9e9 --- /dev/null +++ b/testsuite/tar/tar-archives-multiple-files @@ -0,0 +1,6 @@ +# FEATURE: CONFIG_FEATURE_TAR_CREATE +touch foo bar +busybox tar cf foo.tar foo bar +rm foo bar +tar xf foo.tar +test -f foo -a -f bar diff --git a/testsuite/tar/tar-complains-about-missing-file b/testsuite/tar/tar-complains-about-missing-file new file mode 100644 index 0000000..26e8cbb --- /dev/null +++ b/testsuite/tar/tar-complains-about-missing-file @@ -0,0 +1,3 @@ +touch foo +tar cf foo.tar foo +! busybox tar xf foo.tar bar diff --git a/testsuite/tar/tar-demands-at-least-one-ctx b/testsuite/tar/tar-demands-at-least-one-ctx new file mode 100644 index 0000000..85e7f60 --- /dev/null +++ b/testsuite/tar/tar-demands-at-least-one-ctx @@ -0,0 +1 @@ +! busybox tar v diff --git a/testsuite/tar/tar-demands-at-most-one-ctx b/testsuite/tar/tar-demands-at-most-one-ctx new file mode 100644 index 0000000..130d0e7 --- /dev/null +++ b/testsuite/tar/tar-demands-at-most-one-ctx @@ -0,0 +1 @@ +! busybox tar tx diff --git a/testsuite/tar/tar-extracts-all-subdirs b/testsuite/tar/tar-extracts-all-subdirs new file mode 100644 index 0000000..886c37c --- /dev/null +++ b/testsuite/tar/tar-extracts-all-subdirs @@ -0,0 +1,12 @@ +# FEATURE: CONFIG_FEATURE_TAR_CREATE +mkdir -p foo/{1,2,3} +mkdir -p foo/1/{10,11} +mkdir -p foo/1/10/{100,101,102} +tar cf foo.tar -C foo . +rm -rf foo/* +busybox tar xf foo.tar -C foo ./1/10 +find foo | sort >logfile.bb +rm -rf foo/* +tar xf foo.tar -C foo ./1/10 +find foo | sort >logfile.gnu +cmp logfile.gnu logfile.bb diff --git a/testsuite/tar/tar-extracts-file b/testsuite/tar/tar-extracts-file new file mode 100644 index 0000000..ca72f24 --- /dev/null +++ b/testsuite/tar/tar-extracts-file @@ -0,0 +1,5 @@ +touch foo +tar cf foo.tar foo +rm foo +busybox tar xf foo.tar +test -f foo diff --git a/testsuite/tar/tar-extracts-from-standard-input b/testsuite/tar/tar-extracts-from-standard-input new file mode 100644 index 0000000..a30e9f0 --- /dev/null +++ b/testsuite/tar/tar-extracts-from-standard-input @@ -0,0 +1,5 @@ +touch foo +tar cf foo.tar foo +rm foo +cat foo.tar | busybox tar x +test -f foo diff --git a/testsuite/tar/tar-extracts-multiple-files b/testsuite/tar/tar-extracts-multiple-files new file mode 100644 index 0000000..7897d81 --- /dev/null +++ b/testsuite/tar/tar-extracts-multiple-files @@ -0,0 +1,6 @@ +touch foo bar +tar cf foo.tar foo bar +rm foo bar +busybox tar -xf foo.tar +test -f foo +test -f bar diff --git a/testsuite/tar/tar-extracts-to-standard-output b/testsuite/tar/tar-extracts-to-standard-output new file mode 100644 index 0000000..ca48e36 --- /dev/null +++ b/testsuite/tar/tar-extracts-to-standard-output @@ -0,0 +1,3 @@ +echo foo > foo +tar cf foo.tar foo +cat foo.tar | busybox tar Ox | cmp foo - diff --git a/testsuite/tar/tar-handles-cz-options b/testsuite/tar/tar-handles-cz-options new file mode 100644 index 0000000..5b55e46 --- /dev/null +++ b/testsuite/tar/tar-handles-cz-options @@ -0,0 +1,5 @@ +# FEATURE: CONFIG_FEATURE_TAR_CREATE +# FEATURE: CONFIG_FEATURE_TAR_GZIP +touch foo +busybox tar czf foo.tar.gz foo +gzip -d foo.tar.gz diff --git a/testsuite/tar/tar-handles-empty-include-and-non-empty-exclude-list b/testsuite/tar/tar-handles-empty-include-and-non-empty-exclude-list new file mode 100644 index 0000000..5033642 --- /dev/null +++ b/testsuite/tar/tar-handles-empty-include-and-non-empty-exclude-list @@ -0,0 +1,6 @@ +# FEATURE: CONFIG_FEATURE_TAR_FROM +# FEATURE: CONFIG_FEATURE_TAR_CREATE +touch foo +tar cf foo.tar foo +echo foo >foo.exclude +busybox tar xf foo.tar -X foo.exclude diff --git a/testsuite/tar/tar-handles-exclude-and-extract-lists b/testsuite/tar/tar-handles-exclude-and-extract-lists new file mode 100644 index 0000000..2de0f0e --- /dev/null +++ b/testsuite/tar/tar-handles-exclude-and-extract-lists @@ -0,0 +1,8 @@ +# FEATURE: CONFIG_FEATURE_TAR_FROM +# FEATURE: CONFIG_FEATURE_TAR_CREATE +touch foo bar baz +tar cf foo.tar foo bar baz +echo foo >foo.exclude +rm foo bar baz +busybox tar xf foo.tar foo bar -X foo.exclude +test ! -f foo -a -f bar -a ! -f baz diff --git a/testsuite/tar/tar-handles-multiple-X-options b/testsuite/tar/tar-handles-multiple-X-options new file mode 100644 index 0000000..155b27e --- /dev/null +++ b/testsuite/tar/tar-handles-multiple-X-options @@ -0,0 +1,10 @@ +# FEATURE: CONFIG_FEATURE_TAR_FROM +# FEATURE: CONFIG_FEATURE_TAR_CREATE +touch foo +touch bar +tar cf foo.tar foo bar +echo foo > foo.exclude +echo bar > bar.exclude +rm foo bar +busybox tar xf foo.tar -X foo.exclude -X bar.exclude +test ! -f foo -a ! -f bar diff --git a/testsuite/tar/tar-handles-nested-exclude b/testsuite/tar/tar-handles-nested-exclude new file mode 100644 index 0000000..39013a1 --- /dev/null +++ b/testsuite/tar/tar-handles-nested-exclude @@ -0,0 +1,9 @@ +# FEATURE: CONFIG_FEATURE_TAR_FROM +# FEATURE: CONFIG_FEATURE_TAR_CREATE +mkdir foo +touch foo/bar +tar cf foo.tar foo +rm -rf foo +echo foo/bar >foobar.exclude +busybox tar xf foo.tar foo -X foobar.exclude +test -d foo -a ! -f foo/bar diff --git a/testsuite/tar/tar_with_link_with_size b/testsuite/tar/tar_with_link_with_size new file mode 100644 index 0000000..5b61cc7 --- /dev/null +++ b/testsuite/tar/tar_with_link_with_size @@ -0,0 +1,29 @@ +# This tarball contains a softlink with size field != 0. +# If not ignored, it makes hext header to be skipped +# and data to be read as a header. +# GNU tar 1.15.1 has a bug here: tf won't work, but xf will. +tar1_bz2() +{ + $ECHO -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x14\x44\xe3\xdd\x00\x00" + $ECHO -ne "\x9a\xfb\x90\xca\x18\x00\xc0\x40\x03\xff\x80\x08\x00\x7b\xe3\xff" + $ECHO -ne "\x80\x04\x00\x00\x08\x30\x00\xd6\xb3\x09\x45\x19\x0d\x0d\x41\x84" + $ECHO -ne "\x1a\x68\xd0\x7a\x99\x90\x4a\x0a\x6d\x4c\xa3\x20\x7a\x41\xa0\x00" + $ECHO -ne "\x00\x55\x25\x34\x1a\x34\xd0\x00\x64\x64\x1a\x32\x3f\x76\x3c\x1c" + $ECHO -ne "\xd3\x3c\xa0\x84\x9b\x88\x05\x70\x90\xbb\x18\x28\x39\x29\xb3\x30" + $ECHO -ne "\xa8\x0a\x21\x70\x0c\x01\x32\x3b\xbe\xde\xd7\x13\x2e\xbd\x2a\x9c" + $ECHO -ne "\xa8\x42\x2a\x91\x15\xe2\xa1\xcd\x24\x37\x9c\x91\xaa\xc7\x14\xdb" + $ECHO -ne "\x4c\x08\xaa\xaf\x12\xeb\x6c\x37\x96\xb0\xa4\x25\x0c\xb4\x4b\xc5" + $ECHO -ne "\x52\x70\x3b\x25\x4c\x0e\x46\x67\x51\x54\x89\x13\x13\xf0\xa8\xe9" + $ECHO -ne "\x68\x4e\x8c\x81\xfc\x79\xe0\xb0\xd8\x79\x34\x94\x71\xa2\x0c\xbe" + $ECHO -ne "\x93\x61\x82\x95\x10\x88\xd1\xa6\x69\xaa\x38\x9c\xb6\xc2\xb2\x94" + $ECHO -ne "\x90\xc3\x82\x29\xe8\x8c\xb8\x95\x83\x32\x40\x61\x11\x11\xd3\xaa" + $ECHO -ne "\x3f\x8b\xb9\x22\x9c\x28\x48\x0a\x22\x71\xee\x80" +} +res1="\ +lrwxrwxrwx user/group 0 2008-07-19 15:02:37 firmware-372/sources/native/bin/chroot-setup.sh -> qemu-setup.sh +-rwxr-xr-x user/group 512 2008-07-19 15:02:37 firmware-372/sources/native/bin/qemu-setup.sh" + +export TZ=UTC-2 + +t=`tar1_bz2 | bunzip2 | busybox tar tvf -` +test x"$res1" = x"$t" diff --git a/testsuite/tar/tar_with_prefix_fields b/testsuite/tar/tar_with_prefix_fields new file mode 100644 index 0000000..1c7124d --- /dev/null +++ b/testsuite/tar/tar_with_prefix_fields @@ -0,0 +1,261 @@ +tar1_bz2() +{ + $ECHO -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x12\xd1\x86\x30\x00\x0c" + $ECHO -ne "\xb8\x7f\x80\xff\x50\x08\xa0\x5e\xff\xff\xfd\x7f\xff\xff\xee\xff" + $ECHO -ne "\xff\xff\xfa\x00\x08\x60\x0f\xc5\x3e\xf4\xdc\x00\x00\x59\x25\xbd" + $ECHO -ne "\xb8\x7a\x02\xb5\x82\x78\x25\xb0\x89\x54\x10\x11\x44\x8b\x36\x36" + $ECHO -ne "\xc8\x97\x0d\x34\x9a\x21\xa9\x36\xa9\xed\x32\x02\x8d\xa6\x81\x8a" + $ECHO -ne "\x79\x13\x4d\x1a\x03\x10\x69\xa0\xd3\x40\x64\x0f\x44\x68\x3d\x41" + $ECHO -ne "\x2a\x7a\x20\x09\xa1\x34\x9a\x09\xa4\xc8\xf5\x4f\x46\xa6\x86\x32" + $ECHO -ne "\x4c\x08\x00\x00\xd0\x06\x9a\x00\xd3\xd4\x11\x49\xa7\xb5\x20\x1a" + $ECHO -ne "\x7a\x80\x00\x00\x00\x00\xd0\x68\x00\x00\x00\x00\x00\x49\xa8\x89" + $ECHO -ne "\xa9\x31\x4f\x22\xa7\xea\x9b\x61\x53\xf4\x93\xf2\xa3\x47\xa4\xd3" + $ECHO -ne "\x41\xea\x06\x41\xa0\x0d\x00\x00\x00\x1e\xa0\x70\x34\xd3\x4d\x06" + $ECHO -ne "\x86\x86\x86\x46\x80\x64\x01\xa1\xa0\x34\xd1\x90\x00\x03\x09\x88" + $ECHO -ne "\x0d\x04\x89\x08\x00\x82\x7a\x4c\x42\x64\xc9\x3d\x1a\x29\xe9\xa2" + $ECHO -ne "\x3d\x46\x9e\x46\x9a\x13\x26\x9e\x53\x10\x01\x91\xea\x68\x19\xf0" + $ECHO -ne "\x73\xf2\xe0\xd1\x3c\x80\x01\xb1\x48\x44\x08\x9a\xba\xf3\x9e\x87" + $ECHO -ne "\xec\xc4\x4b\x02\x92\x80\x75\x00\x56\x42\x88\x10\x68\xcc\x06\x22" + $ECHO -ne "\x7c\x2b\xa7\xc8\x21\x91\x13\xe5\x72\xc0\xe6\x0c\x03\x10\xf2\x89" + $ECHO -ne "\x9c\x67\x6b\xc3\xe6\xae\x98\x85\x0a\x7f\x25\x2e\x3d\x84\x5b\xeb" + $ECHO -ne "\xf3\xff\xb3\x52\xf7\x6e\xf6\x92\xd6\x33\x5f\x4f\xd1\x3d\xb7\xc4" + $ECHO -ne "\x0d\x50\x02\x49\x01\xaf\xd0\x69\xbb\xd3\xe9\x63\x0a\x68\x36\x92" + $ECHO -ne "\xf2\x03\x1d\xf2\xe2\x35\xbc\x73\xd4\x44\xf6\xa0\xe0\x31\xd7\x7d" + $ECHO -ne "\x56\x96\xcb\x52\xfc\x79\xe0\xeb\xf7\x34\xd8\xda\x18\x72\x30\x94" + $ECHO -ne "\x53\x45\xf5\x54\x56\x6c\x0b\x50\xa0\xbc\xbd\xcc\xd8\x21\xab\x7b" + $ECHO -ne "\xa8\xa4\xe4\x78\x25\x73\xbf\x4b\x30\x38\x71\xe9\x3c\x14\x5d\xa3" + $ECHO -ne "\x12\x04\x6b\x37\x9d\xe5\xce\xa5\xd9\xd1\xa5\x69\x09\x08\xc4\x48" + $ECHO -ne "\x4b\x34\x58\x81\x15\x18\x88\xac\x11\x51\x88\x35\x0d\xd3\x13\x18" + $ECHO -ne "\x67\x73\x20\x5c\x28\x03\x26\xcd\x6d\x20\x90\xba\xa4\x12\xb3\x08" + $ECHO -ne "\x27\x74\x6a\x99\xdf\xb1\x20\x3d\x85\xe7\x5f\xab\x0e\x2e\xdc\x23" + $ECHO -ne "\x99\xe1\xef\x34\x68\xcd\xa9\xb0\xbf\xda\xec\x81\xdd\x66\xca\x21" + $ECHO -ne "\x13\x47\xd7\xca\x48\xcf\xeb\x25\xbb\x79\x6d\x40\xd0\xe4\x69\x3c" + $ECHO -ne "\x8f\x09\x1e\x7b\xaa\x4b\x91\x39\xac\xd6\xd2\x0c\x85\x1d\xf7\x70" + $ECHO -ne "\x1f\x1e\x58\xbb\x22\x11\x29\x39\x14\x4d\x58\x81\x9f\xd7\x1e\x22" + $ECHO -ne "\x21\x91\x0a\x40\xd1\x87\x29\x99\x93\xf4\xf3\x25\x48\xbb\xb4\x24" + $ECHO -ne "\x2a\x1c\xa7\x28\xc1\x68\x08\x25\x00\xaa\x3d\xee\xae\xc1\xe1\x4f" + $ECHO -ne "\xe6\x9a\x26\x6b\xcf\xb1\x3e\xb9\x85\x04\xf4\xef\xff\x7a\x2f\x2a" + $ECHO -ne "\x04\x08\xe0\x4c\xb8\xbd\x8b\x81\xbf\xa2\xbe\x82\x52\x9b\x40\x63" + $ECHO -ne "\xe6\xf3\xb3\xe4\xe6\xe5\x94\x4a\xdd\xc3\x1b\xaf\x61\xf3\xbf\x5b" + $ECHO -ne "\x6d\xaa\xaa\x27\xe8\x50\x8d\x23\x97\xa4\xbd\xc3\xd2\xe6\xb5\x66" + $ECHO -ne "\x9a\x1a\x8e\x45\x2a\xed\x0b\x79\xb8\x89\x38\x4a\x04\x85\x0d\x1e" + $ECHO -ne "\x2b\x77\x51\x91\x5f\x9f\xe0\x2a\x49\x56\xd3\xa1\xde\xf6\xd7\x88" + $ECHO -ne "\x5a\x61\xe5\x04\x54\xdf\xa3\x92\xeb\xbf\x75\x39\xce\xfa\xf5\xde" + $ECHO -ne "\x30\xd7\x56\xd1\x7d\x2c\xdf\xda\x3e\x1c\xc8\xc2\x93\x61\x21\x20" + $ECHO -ne "\xb2\x22\x6d\xbe\x39\x52\x64\xf6\xb3\x91\x21\x86\xdb\x67\x72\x8f" + $ECHO -ne "\x49\xad\xe4\x93\x39\x5c\x34\x8f\x58\xdb\x58\xd3\x3c\x1e\x4c\x6c" + $ECHO -ne "\xbb\x70\x6f\x42\xcf\x9e\xbf\xb1\xcb\xa9\x8d\x05\xe7\xea\xea\xd7" + $ECHO -ne "\x3c\x67\x31\x69\x44\x33\xa4\x92\x9c\x65\xa4\x89\x5a\xae\xcf\xc9" + $ECHO -ne "\x55\x43\x62\x6d\xbf\x05\x3c\xd1\x0f\x01\x4a\xb5\x1d\xbb\x2c\xfb" + $ECHO -ne "\xa6\xb7\xb3\xb1\x1d\x66\xd3\xeb\x22\xd0\xb5\x5a\x4b\xc4\x47\x47" + $ECHO -ne "\x5a\x49\x85\x18\xbc\x15\x39\x3b\x92\xee\x51\x98\x33\x34\x5d\xb5" + $ECHO -ne "\xbb\x8b\x94\x8c\xde\x8e\x3f\x3d\x09\x4f\xba\xd3\xf6\x79\x74\x8e" + $ECHO -ne "\x82\x0d\x56\x85\xa2\xc7\xc6\xa6\x89\x29\x26\xa3\x53\x5e\x52\xf5" + $ECHO -ne "\x56\x74\x8b\x17\x82\xed\x7a\x8b\x68\x61\xa5\xc9\x7c\xde\x9f\x68" + $ECHO -ne "\x27\x4d\xea\x65\x68\x6f\x7d\x5e\x88\x73\x87\x6c\x92\xf2\xa9\x15" + $ECHO -ne "\x4e\xee\x4d\x41\xbb\x98\x5d\x8a\xaf\xcb\x11\x7b\x2a\xce\xf4\x1e" + $ECHO -ne "\x3a\x28\x48\x14\xfe\x7f\x09\x45\x48\xf1\x5b\xc1\xcb\xcd\x91\xba" + $ECHO -ne "\x3b\xe2\x7d\x57\x85\x66\x68\xec\x51\x82\x97\x88\xeb\x94\x3b\x78" + $ECHO -ne "\x6c\xf4\xf1\x3e\x38\x8d\x22\x16\xab\x3b\x13\xb3\x1b\x39\x94\x0e" + $ECHO -ne "\xa8\x26\xb7\x8d\xe9\x7d\x66\x23\x4b\x65\x07\xb7\x2b\xc9\x96\xb6" + $ECHO -ne "\x99\x12\x22\xbc\x90\xda\x51\xbc\xfd\x97\xa5\x7d\xbc\x12\xa6\x72" + $ECHO -ne "\xd3\xe3\x8c\xc7\x58\xe1\xf8\x28\xf4\x46\x49\x14\xd0\x9d\xb6\xed" + $ECHO -ne "\xce\x99\xc6\xbc\xed\xa3\xab\xa0\x8c\x9d\xce\x1a\x1a\xc2\xe6\x77" + $ECHO -ne "\xba\xae\xba\xd6\xc9\xb2\xd1\x65\x24\x7b\x0d\xd4\xf2\xac\x28\xc3" + $ECHO -ne "\x1c\xbe\x4a\x54\xe3\x0f\x8d\xad\xb2\x37\x9e\x1f\x81\x72\x2d\xab" + $ECHO -ne "\x8f\xb1\xcd\xf7\xb4\x51\x2f\x1d\xf8\xad\x77\x14\x37\xd2\x1a\x9a" + $ECHO -ne "\xc0\xf2\x48\xc6\x4c\x8d\xd3\x8d\xf1\xd9\x2e\x2c\xdd\x7a\x98\x3c" + $ECHO -ne "\x24\x76\xb9\x9d\x27\xcd\x71\x7d\x6c\xc7\x1f\x0a\x74\x8a\x6e\x54" + $ECHO -ne "\xec\x5a\xa1\x77\x60\x80\xef\x00\xa4\x5f\x9e\x8b\x2f\x02\x72\x9c" + $ECHO -ne "\x46\xd8\x79\x92\x4c\x8f\x4e\x37\xed\x0c\x58\xab\x44\xee\x1d\xd1" + $ECHO -ne "\xa1\xb0\xa5\x1f\xaf\xb0\x39\x01\x26\xb2\x4a\x20\x68\x4a\x18\x23" + $ECHO -ne "\xc3\x03\x84\x22\x18\xdb\x6d\x83\x60\xc1\x12\x09\x21\x84\x22\x48" + $ECHO -ne "\x7f\x1e\x17\xf5\xbe\xce\x4c\x4f\x9f\x9f\xee\xf4\xfe\xef\x9a\x34" + $ECHO -ne "\x91\x8f\x36\x1d\xbc\x73\xd7\xeb\xc8\x2e\x81\x25\xfa\x18\x76\x35" + $ECHO -ne "\x1f\x16\xdb\x20\x4b\x74\x6d\x94\x4e\xe5\x36\xed\xf5\x5d\x59\xaf" + $ECHO -ne "\x46\x70\xea\x03\xac\x50\xbb\x26\xab\x39\x9a\x4b\x6b\x09\x8c\x6d" + $ECHO -ne "\x34\xcf\xed\xaa\xf7\x56\x40\xf2\xab\x07\xca\x22\x71\x97\xc7\x35" + $ECHO -ne "\xe8\x06\x90\x7b\xec\xc3\x9f\xa4\xde\xd9\xdb\x43\xf1\xd5\x06\x58" + $ECHO -ne "\x72\x9e\x1f\x08\xb6\xc2\x05\x0d\x25\xfe\x7a\x85\xe5\x10\x12\x68" + $ECHO -ne "\x18\x7e\x8c\xa0\xfa\xb4\xc4\xc7\x4e\xa9\xf2\x13\xd7\xc2\x52\xb5" + $ECHO -ne "\xe3\x72\x37\x31\x1e\x4f\x99\xfd\xac\x97\x08\x88\x71\x88\xeb\x1a" + $ECHO -ne "\xf9\xa1\x10\x9c\x44\x08\x56\x4a\x77\xaa\x0f\x19\x5f\x5f\xb3\x95" + $ECHO -ne "\xee\x9b\x9f\x5b\xb5\xc9\x0a\xf4\x28\x16\x25\x34\x6c\x72\xda\x92" + $ECHO -ne "\xb4\x2c\xbd\x5e\xb1\xe8\xe5\x0f\x68\xf3\x44\x8a\xd5\xfa\x73\x5c" + $ECHO -ne "\x89\x2e\x99\x7d\xed\xe3\x5b\x3f\x48\x97\xeb\xb6\x76\x5c\xa5\x9d" + $ECHO -ne "\xef\x12\x1e\x42\x89\x52\xad\x28\x90\xe5\x2b\x88\xa0\x4f\x11\x92" + $ECHO -ne "\xcd\xcc\x63\x40\x1a\xc7\x10\x0c\x2f\xcd\x01\xf2\x07\x38\xac\x14" + $ECHO -ne "\xe5\x90\xc0\x30\x21\xe2\xe3\x72\x0e\x3e\x04\xc8\x9e\xa7\x00\xdb" + $ECHO -ne "\x91\xdd\x9d\x80\xa4\x69\x2a\x48\x37\x97\xa4\x26\x5d\xae\x84\x1e" + $ECHO -ne "\x88\xf4\x83\x04\x24\xc9\x1f\x94\x61\x25\xf9\x82\xdd\xed\x2d\x96" + $ECHO -ne "\xad\x06\x45\xdd\x88\xd7\x50\x40\x14\xdc\x7c\xdb\x0f\x53\x96\x27" + $ECHO -ne "\xcb\x67\xac\xa6\xc1\x15\x2f\xc3\xdb\x2c\xca\x94\xb3\xf3\xd1\x6a" + $ECHO -ne "\xba\x34\x83\xd1\xcc\x40\x3e\x76\xa1\x69\x7f\x49\x33\xdc\xa7\x3c" + $ECHO -ne "\x6a\x67\x15\xab\xdb\x52\xa0\xb8\xa6\x1e\xce\xe3\xaf\xf4\xa2\x62" + $ECHO -ne "\x35\x0f\x03\x40\x8e\x20\x12\x9c\xb6\x34\x71\x3a\x15\x5d\xe5\x34" + $ECHO -ne "\xa8\xd4\x05\x99\x6b\x9a\xb6\x41\x0b\x78\xc4\xd8\xd9\x7a\x65\xdc" + $ECHO -ne "\xdb\xe3\x42\xd5\x66\xf9\xb4\x83\x7e\xc0\xf4\x01\xc4\xcc\x3b\x0e" + $ECHO -ne "\x15\xdc\x15\xc2\x3e\x04\x2f\xfc\x6b\x72\xeb\xf6\xaa\x16\x20\xde" + $ECHO -ne "\xd3\x3a\xb1\x10\xc6\x3c\xe8\x2b\xb8\xea\xda\x19\x6e\x36\xaa\xa4" + $ECHO -ne "\x23\x6d\xa0\x40\xd1\x5a\x0b\x7e\xa4\xd5\x2d\xcb\xa9\x15\x35\xba" + $ECHO -ne "\x93\x92\x45\x41\xb0\x1a\xd1\x13\x31\xb6\x44\x98\x78\x28\x15\xe4" + $ECHO -ne "\xae\xba\x58\xd1\x75\x36\x34\x1a\xd8\x28\xf1\x4a\x4c\xbc\x1b\xa8" + $ECHO -ne "\xf7\x57\x92\xbc\xe2\xb5\xda\xb6\xa6\x1d\x83\x37\x96\x43\x20\x84" + $ECHO -ne "\xcb\xb6\xd9\x3f\xeb\xfa\xa0\xfe\x9a\x7d\xee\x47\x98\xc4\xe7\xc4" + $ECHO -ne "\xbd\xc6\xf0\x6d\xb2\x26\x10\x1e\x78\xef\xf3\x28\x3e\x35\xe6\xe4" + $ECHO -ne "\xe6\xf3\x0f\x26\x34\x13\x85\xd0\xcf\x55\x0f\x8b\xd7\xe9\xf4\xdf" + $ECHO -ne "\x70\x68\xc0\xb5\x30\x3c\xb1\x01\xe8\x28\xae\x80\x26\x01\x8b\x15" + $ECHO -ne "\x0f\x80\x48\x18\x4b\xe2\xed\x59\x92\x31\xcf\xd2\x8f\x42\xbf\xee" + $ECHO -ne "\xbd\x07\x91\x24\xc6\x66\x5e\x8c\x9a\x48\x63\xe7\xac\x8a\x1e\xc5" + $ECHO -ne "\x69\x16\x8d\xac\x67\xdc\x75\x75\x82\xca\x19\x28\x36\x4d\x10\xf9" + $ECHO -ne "\x41\xcb\x15\x05\x64\xc7\xb0\xc3\x64\xf3\x48\x71\x60\xf2\xbd\xcc" + $ECHO -ne "\x37\xb1\x36\xbc\xa7\x2e\x6b\x20\x11\x51\x42\xe1\x8a\x29\xac\x44" + $ECHO -ne "\x8f\x63\x56\x23\xd4\xd4\x07\xb4\x60\xa4\xb8\xcd\xee\x49\xa5\x42" + $ECHO -ne "\xcc\x52\x00\x6f\xdc\x44\x20\x57\x7d\x36\xd7\x48\x1a\x22\x2c\xd0" + $ECHO -ne "\x19\x43\x51\x5e\x1c\x8c\x5f\x70\xc2\x6b\xcf\xea\xd4\x97\x61\x72" + $ECHO -ne "\x33\xc3\x9a\xd4\x06\xf1\x8a\x9a\xfe\x21\x83\x0b\xea\xf1\xfa\x2c" + $ECHO -ne "\x52\x23\x2c\xb8\xc1\xe6\xc8\x9d\x9c\x5f\x8f\xf2\x4a\x86\x76\x92" + $ECHO -ne "\x78\x0f\x7d\x9d\x09\x38\xce\xe1\x9a\xf3\x60\xed\x65\x0b\x1a\x68" + $ECHO -ne "\xa6\x52\x39\x18\x1e\x45\xe3\x5d\xe0\x7d\xfb\xc6\xcc\x44\x18\x93" + $ECHO -ne "\xe9\x71\xa8\x18\x0d\x74\x48\x8a\x18\x0b\x61\xbf\xe1\xa9\x0e\x4c" + $ECHO -ne "\xad\x1b\xaf\x1a\x37\x39\x92\x4d\xcc\x96\x87\x46\x0d\x83\x06\x33" + $ECHO -ne "\x53\x35\xd9\x2c\x36\x98\x28\x1c\x52\xb1\x89\x55\x56\xcc\x37\x20" + $ECHO -ne "\x89\x84\x0e\x3d\x27\x2f\xc6\xfa\x78\x04\xe1\xd5\xc6\x90\x49\x16" + $ECHO -ne "\xfe\x0a\x16\x6f\x11\x54\x42\x22\xa1\x90\x2d\x19\x91\x28\x05\xf2" + $ECHO -ne "\x30\x6c\x14\x16\xd6\x8a\xce\xf6\xcd\x7c\x64\x76\x42\xe9\x28\xe9" + $ECHO -ne "\x1c\xd1\xb8\x9e\xcd\x53\xb2\x6b\x8d\x57\x57\x2a\xb8\x59\x58\x8c" + $ECHO -ne "\xd3\x12\x57\xa6\xe3\x48\x70\xf5\x55\x0f\x76\xb5\x27\x08\xd1\xa0" + $ECHO -ne "\xf8\x60\x09\xa1\xf2\x30\x43\x4a\x30\x46\xf7\x96\x19\xe9\x3a\x44" + $ECHO -ne "\xc0\xd8\xa8\x51\xae\x50\x92\x81\x81\xda\x10\xd3\x18\x62\x94\xd0" + $ECHO -ne "\x9e\x54\x0b\x22\xcc\xd0\xfe\x0c\x36\x44\x4d\x4d\x40\x5c\xa8\x35" + $ECHO -ne "\xb6\x53\x9c\x36\x9c\x5a\x0e\x0e\xb0\x5c\x29\x2a\x35\x66\xaa\x3a" + $ECHO -ne "\xcb\x23\x7b\xbb\xc8\x60\xbc\xb4\x28\xf4\x6e\xfe\x86\xfc\x16\x85" + $ECHO -ne "\x0c\xe0\x1d\xcf\xfd\x12\x28\xc6\x60\xd0\xe6\x2f\x76\xf0\x1a\x5b" + $ECHO -ne "\xfa\xa6\xc6\xea\x58\xbb\x26\x37\x84\xdd\x85\xd5\x37\x82\x76\xd9" + $ECHO -ne "\x14\x7a\xca\xed\x13\x72\xc3\xe1\xb9\x69\x45\xd4\xec\x44\x94\x26" + $ECHO -ne "\x8e\x0b\x90\xb6\x8b\x1f\x1e\x01\x96\x5a\xb9\x51\xa6\x27\xa2\x9b" + $ECHO -ne "\x38\xd9\x25\x32\x9b\x54\xfc\x45\xd1\xa8\x59\x35\x1a\xb0\xb2\x1a" + $ECHO -ne "\xc8\x88\x15\x42\x98\x50\x99\x12\x9e\xf5\x59\xb2\x5c\xc5\xa7\x34" + $ECHO -ne "\x35\xca\xb3\xed\xdc\xc9\x9f\x3e\x77\x8f\x6c\xde\xc8\x41\x6a\xc5" + $ECHO -ne "\x24\x85\x04\xa1\x2f\xe3\x47\x8c\x47\xd4\xdb\x74\x8c\xb6\x4c\xef" + $ECHO -ne "\xed\xad\x9f\x86\x31\xd8\xc8\x07\xc5\x11\x1c\x39\x3a\xf8\x75\x73" + $ECHO -ne "\xae\x78\x7d\x1d\x36\x5b\xd1\x23\x5d\x84\x17\x5d\x4b\xac\xd3\x70" + $ECHO -ne "\x8a\x83\x48\x48\x83\x7b\x5c\x99\x9e\x56\xbb\xfc\x0c\x4b\x04\xcf" + $ECHO -ne "\x83\x5d\xf8\x31\x2c\xc4\x5c\xa1\x68\x6a\x56\xe1\x7f\xbe\xd6\x59" + $ECHO -ne "\x6c\x55\xb0\x63\x41\xeb\x88\x69\xb6\x9b\x50\xc4\x31\xea\xb0\xd7" + $ECHO -ne "\xe2\xfb\x7b\xeb\xbb\x52\xc4\x97\x23\xe9\x16\x29\x18\x50\x4d\x0e" + $ECHO -ne "\x68\x62\xfb\x3f\xd9\x07\xb9\x89\x4d\x58\x7c\x32\x6d\x12\x3e\x9b" + $ECHO -ne "\x3a\x14\xee\xac\x3c\x8d\x09\x62\x30\x8e\xe0\x86\x84\xb9\xf3\x0d" + $ECHO -ne "\xf8\xad\x42\xa6\xbb\x7d\xd1\xf2\xf3\xc0\xe2\x32\xc4\x40\xaa\x8a" + $ECHO -ne "\x2a\xe9\xa9\x45\x83\x23\xf6\x90\x05\x24\x59\x22\x84\x50\x82\xc0" + $ECHO -ne "\x58\x41\x42\x18\x91\x3d\xd8\x80\xb1\x26\x68\xb2\xa8\xc0\x21\x14" + $ECHO -ne "\x18\xdf\x3a\x86\x25\x85\x56\xab\x20\x38\xcd\xdc\x98\x6e\x07\xc4" + $ECHO -ne "\x6b\x16\x55\xe0\x41\xe0\x41\xda\x29\x62\x8d\xba\xce\xa2\xcb\xfc" + $ECHO -ne "\x70\x78\x99\xf9\x16\x0b\x5a\x0c\xc5\xad\x18\xeb\xf0\xb5\xc9\x25" + $ECHO -ne "\x82\x16\xe0\x5d\xc1\xc4\xc6\xf0\x84\x6a\x45\x7d\xdb\x28\x46\xab" + $ECHO -ne "\xef\x32\xc9\x49\x50\x51\x60\x77\x1c\xfd\x58\x9c\x01\x3b\x7a\xfa" + $ECHO -ne "\x49\x47\x3e\x87\x1c\x39\xa6\x6a\xa4\xb7\x39\x93\xac\xac\xb0\x39" + $ECHO -ne "\x2f\xbc\xab\x9b\x52\x96\x24\x46\xc1\x95\xe4\x31\x89\x37\x18\xc8" + $ECHO -ne "\x2c\x22\x32\x2a\x8f\xb6\x58\x77\x57\x77\x2f\x09\xd0\x7c\xed\x74" + $ECHO -ne "\xaa\x7c\x86\x25\x45\x0c\x43\x4d\x31\xb0\x63\x40\xcf\x86\xfe\x75" + $ECHO -ne "\x76\xe0\xee\x99\xb5\x71\xe2\x4e\xe5\xc1\xf9\x2e\x48\xe2\xa6\x1b" + $ECHO -ne "\x28\xa5\xa3\xbe\xff\x37\xd1\xdd\x66\xa2\xe8\xd3\x88\x4d\x13\xd5" + $ECHO -ne "\x68\x51\x27\x41\xc3\x6c\x1b\x48\x67\x6a\xdf\x25\x2a\x40\xa1\x87" + $ECHO -ne "\x1d\x54\xb7\xe3\x91\xc2\x6b\x5b\xb9\x8c\xd5\x10\x11\x10\x16\xab" + $ECHO -ne "\x6b\xbe\x65\x6b\x73\xa7\x35\xa1\x09\x60\x60\xed\x96\x39\xc9\x40" + $ECHO -ne "\x5d\xdc\xee\x60\x49\x0c\x68\x18\x34\xb2\x6f\x2a\x95\x14\x29\x95" + $ECHO -ne "\x5b\x59\xd2\x1f\x63\x2a\xbe\xfd\xae\x09\x5c\xee\x11\xb5\x29\x36" + $ECHO -ne "\xca\xdf\x28\x8c\x65\x42\x46\x74\x0c\x39\x68\x30\xac\x2c\x2f\xd0" + $ECHO -ne "\x9b\xb3\x92\x19\x90\xa1\x07\xcc\xf6\xde\x64\x5f\x6f\xd7\xb6\xcc" + $ECHO -ne "\xe0\x70\x0f\x0b\xd2\x0e\x77\xa1\x70\xe3\x56\x90\x4b\x28\x58\xd0" + $ECHO -ne "\xd1\xe1\x9d\x18\x98\xba\x6b\x36\x54\xa9\x54\x09\x63\x49\x18\x55" + $ECHO -ne "\x60\xba\x11\xb1\x0a\x14\x45\x1f\xae\x08\x50\x09\x33\x00\xa2\xb2" + $ECHO -ne "\x71\x81\x75\x89\xb7\xb9\x0c\x73\xc0\x4c\x32\x89\x72\xac\xa9\xa3" + $ECHO -ne "\x47\x5f\x7d\x4e\x1b\x4d\xb9\xea\x84\x45\x00\x37\x3c\xb3\x7b\xf8" + $ECHO -ne "\xe7\x0f\xaa\x33\x1a\x9b\xc2\x0c\x35\x8a\xd4\x04\x46\x42\xcb\xab" + $ECHO -ne "\xaa\xc7\xe5\xc9\x20\x6e\x21\xa6\x8c\xed\x61\x86\x42\x87\x03\x25" + $ECHO -ne "\xde\x2c\x4a\x85\xcb\xb4\x36\xc9\xd4\x72\x60\x62\xc2\x19\xd0\x30" + $ECHO -ne "\x16\x6d\x58\x61\x62\x16\xe8\xd2\x0e\xd0\xf3\xdb\x53\x37\x07\x37" + $ECHO -ne "\x40\xc3\xe5\x5b\x9d\x16\x45\x60\x8e\xfb\x12\xc4\x5f\x9f\xdd\xe1" + $ECHO -ne "\x45\x5d\x45\x36\x21\xa0\xc0\xb8\x11\x98\x0f\x64\x98\x67\x1c\x11" + $ECHO -ne "\xa9\xa1\x65\x10\xb9\x22\x12\x91\x10\x9b\x10\x6f\x95\x2e\x34\x91" + $ECHO -ne "\x64\x82\xa4\x05\x02\xfc\x4a\x9f\x9c\x4d\x6c\x8d\x67\x26\x90\x63" + $ECHO -ne "\x04\x12\x6f\x0e\x55\x3c\x8e\xf2\x8d\xb4\x6b\x3d\xac\xcf\x84\x2e" + $ECHO -ne "\x60\x0f\x40\x62\x88\x3a\xcf\xbd\xea\xad\x40\x4c\x29\xe1\xb5\xb6" + $ECHO -ne "\x3e\x15\x86\xd5\xbe\xad\x27\xde\x2b\x32\xef\xcf\x97\x88\x8b\x17" + $ECHO -ne "\x80\x43\x0e\x20\x79\x3b\x36\x73\xb8\xad\x12\x0e\x87\x59\x5f\xd3" + $ECHO -ne "\x3c\x8c\x84\xc8\x54\x2b\x94\xc9\x2e\x36\x8b\x32\x48\xf1\xe3\x08" + $ECHO -ne "\xf0\x36\xc0\xb8\xc2\xa2\xa9\xe2\x52\x02\xf1\x9b\xcb\xde\xcc\xb5" + $ECHO -ne "\x5a\x6c\x05\x06\x31\x44\x41\x88\xa3\x05\x04\x16\x0d\x4a\x85\x20" + $ECHO -ne "\x79\xda\x89\x82\x1d\x5f\x5a\x11\x88\x89\x06\x05\xf5\xf4\xed\x75" + $ECHO -ne "\x62\x39\x37\x69\x11\x32\x3e\x8d\xe4\x60\x62\x52\xc9\xad\x82\x9a" + $ECHO -ne "\x9a\x2f\x06\x41\x26\xb4\x48\x70\x39\x2b\x8a\xb1\x5a\x53\xc6\x48" + $ECHO -ne "\x57\x17\xf5\xd8\x5a\xc6\x19\x83\x06\x0b\x9b\x04\xb8\xf5\xaf\x23" + $ECHO -ne "\x45\x87\x48\x50\x6d\x16\xea\xb4\x20\xb8\x49\x92\x6b\x0c\x76\x14" + $ECHO -ne "\x48\x53\xa1\x29\x74\xf6\xd7\x49\x44\x39\xba\xbd\x63\xa6\xf2\x81" + $ECHO -ne "\x8f\x5b\x5e\x46\x0a\x34\x95\x31\xc0\xdd\x60\x50\xd6\x0a\xa6\x29" + $ECHO -ne "\x3d\x36\x3a\xc7\xb8\xcf\x25\x5e\xf7\x82\x55\x88\xc2\x8b\x30\xd2" + $ECHO -ne "\x97\x90\x49\x94\xde\xe5\xaa\xeb\x42\x8c\x94\x2a\xa0\x0d\x9b\xb5" + $ECHO -ne "\x59\xbe\xcb\x35\xa3\x37\x54\x76\x35\x98\xcb\x1f\x13\x3f\x4a\xd1" + $ECHO -ne "\x45\x87\x67\xed\x66\x02\x06\x49\x1c\x59\x51\x1f\x4d\x85\x03\x46" + $ECHO -ne "\x65\x86\x4e\x4c\x6a\xd2\x24\x31\x5b\x6a\x3b\x19\x49\xe1\x83\x14" + $ECHO -ne "\xc1\xf0\x56\x61\x93\x8b\x33\x13\x54\x6f\x78\x4c\xa0\x85\xf0\xb3" + $ECHO -ne "\x17\xaa\xf2\x67\x02\x0c\x31\xed\x5e\x98\x02\x28\xc4\xe5\x87\xa2" + $ECHO -ne "\x70\xd1\xd5\x9c\xf8\xec\x19\x88\xa9\x0d\x0e\x4a\xe3\x47\x83\x6e" + $ECHO -ne "\xf7\x70\x3e\xa4\xa9\xc0\x4c\xfa\x2b\x3b\xd7\x6f\x96\xc3\x6d\x6d" + $ECHO -ne "\x71\x2a\x8d\x62\xf1\xd3\xdd\xb0\x33\xd4\x67\x19\x0d\x30\x85\x3a" + $ECHO -ne "\x06\x04\x85\x00\x48\x5d\x53\x35\xa0\x31\x56\x84\x82\xa5\xac\x22" + $ECHO -ne "\x02\x44\xaf\x6d\xc0\x61\x59\x23\x96\x72\x5a\x81\x9e\x0c\xe5\x79" + $ECHO -ne "\xda\xd0\x42\x5c\x89\xa5\x00\xec\x56\x41\x64\x8a\x11\x60\x79\xb1" + $ECHO -ne "\xed\x55\x16\x54\xe6\x51\x03\x34\x14\x60\x31\xd2\xf0\x0b\xce\xf2" + $ECHO -ne "\x4e\x4c\x45\x8c\xeb\x2a\x82\x3a\xa8\x52\xce\x8f\x4e\xf1\x89\xea" + $ECHO -ne "\x44\x91\x66\xdd\x6b\x49\xa3\x83\x0b\x19\x0e\x66\x5f\x02\x22\x58" + $ECHO -ne "\xe7\xc0\xa8\xce\x55\x48\xa6\x04\xf3\x03\xac\x62\xb2\xc0\xaa\xa0" + $ECHO -ne "\x09\xae\x5b\x96\xd0\xdd\xa9\x1f\xfb\x2d\x3d\xf5\x02\xe1\x86\x02" + $ECHO -ne "\x3e\xda\xd0\x5d\xba\x16\x39\xcd\x75\xa2\x47\x26\x74\x25\xa8\x5e" + $ECHO -ne "\xf3\x36\x0c\x37\x19\x17\x06\x66\xd0\x0b\x42\x41\x0a\xa0\xde\x93" + $ECHO -ne "\xd7\xb4\x9f\xfb\xc7\x4f\x65\x54\xda\xb8\x8b\x23\xde\x9c\x57\xcf" + $ECHO -ne "\x2d\x2a\x12\xda\xcc\xf6\x73\x83\x02\x4c\x0e\x42\x88\xda\x27\xb9" + $ECHO -ne "\xcb\x04\xb6\x07\x26\x78\xa1\xa1\x09\xa3\x6a\x86\xbd\x9d\xd4\xf9" + $ECHO -ne "\xc0\x81\xa6\x49\xa9\x72\xeb\x56\xbd\xf9\xea\x89\x4f\xae\x72\x28" + $ECHO -ne "\xb6\x57\x35\xbe\x94\xad\xc0\xff\x1e\xf2\x35\x24\xa0\x45\xd5\x09" + $ECHO -ne "\xc0\xe0\x10\xd0\x17\x90\xe2\xff\x8b\xb9\x22\x9c\x28\x48\x09\x68" + $ECHO -ne "\xc3\x18\x00" +} + +tar2_bz2() +{ + $ECHO -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x16\x08\xfd\x60\x00\x00" + $ECHO -ne "\x01\xff\x80\x48\x80\x00\xa0\x40\x03\xff\xc0\x72\x00\x89\x40\xff" + $ECHO -ne "\xe7\xdf\xc0\x20\x00\x92\x11\x53\xf5\x13\xd3\x53\x7a\x41\xa8\xf2" + $ECHO -ne "\x9a\x60\x21\x9a\x40\xf4\x9b\xd2\x0d\x09\xa5\x3c\xa6\x4f\x44\xf5" + $ECHO -ne "\x34\x34\xd1\xb5\x01\xa0\x3d\x41\xa4\xe1\xeb\x4c\x5a\x01\x47\x3b" + $ECHO -ne "\xd1\x67\x1a\x4c\x3b\x21\x84\x23\x2c\x5c\xf7\xe0\xbd\x2a\xa4\xea" + $ECHO -ne "\xdc\xdb\x71\x80\x26\x98\x21\x0e\x76\x21\x30\xce\xe4\xad\x8c\xb5" + $ECHO -ne "\x68\x62\x35\xa1\xfd\x8e\x7b\x51\x70\x96\xb1\x2c\xa2\x99\x6c\xa1" + $ECHO -ne "\xc2\xcd\xea\xa7\x5e\x6b\x91\x4f\x73\x96\xe4\x48\x3c\xe7\x8c\x0f" + $ECHO -ne "\x03\x64\x5b\x7a\x43\xc1\x68\x86\x41\x83\x46\x0b\xba\xaa\x6a\x9b" + $ECHO -ne "\x59\x34\xf1\x1c\x08\x69\x1d\x41\xfb\x4a\x96\x1b\x14\x9e\x32\x89" + $ECHO -ne "\x69\x5f\x63\x9a\x22\xe4\x96\x34\xff\x12\x20\xd0\x25\x70\xdc\x5d" + $ECHO -ne "\xc9\x14\xe1\x42\x40\x58\x23\xf5\x80" +} + +# NB: tar emits "tar: short read" on stderr because these test tars are +# also lacking proper terminating zeroed blocks. But exitcode is 0. +# This is intended. + +export TZ=UTC-1 + +# Case 1: long name, with path in prefix field +res1='-rw-r--r-- fm3/users 9869 2007-03-12 10:44:54 VirtualBox-1.5.6_OSE/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/public/ipcITransactionService.idl' +t=`tar1_bz2 | bunzip2 | busybox tar tvf -` +test x"$res1" = x"$t" +t=`tar1_bz2 | bunzip2 | busybox tar tv` +test x"$res1" = x"$t" + +# Case 2: long dir name, with ENTIRE path in prefix field (name = "") +res2='drwxr-xr-x fm3/users 0 2008-02-19 16:33:20 VirtualBox-1.5.6_OSE/src/VBox/Additions/linux/x11include/4.3/programs/Xserver/hw/xfree86/xf24_32bpp/' +t=`tar2_bz2 | bunzip2 | busybox tar tvf -` +test x"$res2" = x"$t" +t=`tar2_bz2 | bunzip2 | busybox tar tv` +test x"$res2" = x"$t" diff --git a/testsuite/taskset.tests b/testsuite/taskset.tests new file mode 100755 index 0000000..4599364 --- /dev/null +++ b/testsuite/taskset.tests @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copyright 2006 Bernhard Reutner-Fischer +# Licensed under GPL v2 or later, see file LICENSE for details. + +. testing.sh +a="taskset" + +# testing "test name" "opts" "expected result" "file inp" "stdin" +testing "taskset (get from pid 1)" "$a -p 1 >/dev/null;echo \$?" "0\n" "" "" +testing "taskset (invalid pid)" "$a -p 0 >/dev/null 2>&1;echo \$?" "1\n" "" "" +testing "taskset (set_aff, needs CAP_SYS_NICE)" \ + "$a 0x1 $SHELL -c $a\ -p\ \$$\|grep\ \"current\ affinity\ mask:\ 1\" >/dev/null;echo \$?" \ + "0\n" "" "" + +unset a +exit $FAILCOUNT diff --git a/testsuite/tee/tee-appends-input b/testsuite/tee/tee-appends-input new file mode 100644 index 0000000..cff20bf --- /dev/null +++ b/testsuite/tee/tee-appends-input @@ -0,0 +1,5 @@ +echo i\'m a little teapot >foo +cp foo bar +echo i\'m a little teapot >>foo +echo i\'m a little teapot | busybox tee -a bar >/dev/null +cmp foo bar diff --git a/testsuite/tee/tee-tees-input b/testsuite/tee/tee-tees-input new file mode 100644 index 0000000..26e2173 --- /dev/null +++ b/testsuite/tee/tee-tees-input @@ -0,0 +1,3 @@ +echo i\'m a little teapot >foo +echo i\'m a little teapot | busybox tee bar >baz +cmp foo bar && cmp foo baz diff --git a/testsuite/test.tests b/testsuite/test.tests new file mode 100755 index 0000000..d4be949 --- /dev/null +++ b/testsuite/test.tests @@ -0,0 +1,69 @@ +#!/bin/sh + +# Copyright 2007 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "command" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +# Need to call 'busybox test', otherwise shell builtin is used + +testing "test: should be false (1)" \ + "busybox test; echo \$?" \ + "1\n" \ + "" "" + +testing "test '': should be false (1)" \ + "busybox test ''; echo \$?" \ + "1\n" \ + "" "" + +testing "test a: should be true (0)" \ + "busybox test a; echo \$?" \ + "0\n" \ + "" "" + +testing "test --help: should be true (0)" \ + "busybox test --help; echo \$?" \ + "0\n" \ + "" "" + +testing "test -f: should be true (0)" \ + "busybox test -f; echo \$?" \ + "0\n" \ + "" "" + +testing "test ! -f: should be false (1)" \ + "busybox test ! -f; echo \$?" \ + "1\n" \ + "" "" + +testing "test a = a: should be true (0)" \ + "busybox test a = a; echo \$?" \ + "0\n" \ + "" "" + +testing "test -lt = -gt: should be false (1)" \ + "busybox test -lt = -gt; echo \$?" \ + "1\n" \ + "" "" + +testing "test -f = a -o b: should be true (0)" \ + "busybox test -f = a -o b; echo \$?" \ + "0\n" \ + "" "" + +testing "test ! a = b -a ! c = c: should be false (1)" \ + "busybox test ! a = b -a ! c = c; echo \$?" \ + "1\n" \ + "" "" + +testing "test ! a = b -a ! c = d: should be true (0)" \ + "busybox test ! a = b -a ! c = d; echo \$?" \ + "0\n" \ + "" "" + +exit $FAILCOUNT diff --git a/testsuite/testing.sh b/testsuite/testing.sh new file mode 100755 index 0000000..a57c4d6 --- /dev/null +++ b/testsuite/testing.sh @@ -0,0 +1,154 @@ +# Simple test harness infrastructurei for BusyBox +# +# Copyright 2005 by Rob Landley +# +# License is GPLv2, see LICENSE in the busybox tarball for full license text. + +# This file defines two functions, "testing" and "optional" +# and a couple more... + +# The following environment variables may be set to enable optional behavior +# in "testing": +# VERBOSE - Print the diff -u of each failed test case. +# DEBUG - Enable command tracing. +# SKIP - do not perform this test (this is set by "optional") +# +# The "testing" function takes five arguments: +# $1) Test description +# $2) Command(s) to run. May have pipes, redirects, etc +# $3) Expected result on stdout +# $4) Data to be written to file "input" +# $5) Data to be written to stdin +# +# The exit value of testing is the exit value of $2 it ran. +# +# The environment variable "FAILCOUNT" contains a cumulative total of the +# number of failed tests. + +# The "optional" function is used to skip certain tests, ala: +# optional CONFIG_FEATURE_THINGY +# +# The "optional" function checks the environment variable "OPTIONFLAGS", +# which is either empty (in which case it always clears SKIP) or +# else contains a colon-separated list of features (in which case the function +# clears SKIP if the flag was found, or sets it to 1 if the flag was not found). + +export FAILCOUNT=0 +export SKIP= + +# Helper functions + +optional() +{ + option=`echo ":$OPTIONFLAGS:" | grep ":$1:"` + # Not set? + if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ] + then + SKIP= + return + fi + SKIP=1 +} + +# The testing function + +testing() +{ + NAME="$1" + [ -n "$1" ] || NAME="$2" + + if [ $# -ne 5 ] + then + echo "Test $NAME has wrong number of arguments (must be 5) ($# $*)" >&2 + exit 1 + fi + + [ -z "$DEBUG" ] || set -x + + if [ -n "$SKIP" ] + then + echo "SKIPPED: $NAME" + return 0 + fi + + $ECHO -ne "$3" > expected + $ECHO -ne "$4" > input + [ -z "$VERBOSE" ] || echo "echo '$5' | $2" + $ECHO -ne "$5" | eval "$2" > actual + RETVAL=$? + + if cmp expected actual >/dev/null 2>/dev/null + then + echo "PASS: $NAME" + else + FAILCOUNT=$(($FAILCOUNT + 1)) + echo "FAIL: $NAME" + [ -z "$VERBOSE" ] || diff -u expected actual + fi + rm -f input expected actual + + [ -z "$DEBUG" ] || set +x + + return $RETVAL +} + +# Recursively grab an executable and all the libraries needed to run it. +# Source paths beginning with / will be copied into destpath, otherwise +# the file is assumed to already be there and only its library dependencies +# are copied. + +mkchroot() +{ + [ $# -lt 2 ] && return + + $ECHO -n . + + dest=$1 + shift + for i in "$@" + do + #bashism: [ "${i:0:1}" == "/" ] || i=$(which $i) + i=$(which $i) # no-op for /bin/prog + [ -f "$dest/$i" ] && continue + if [ -e "$i" ] + then + d=`echo "$i" | grep -o '.*/'` && + mkdir -p "$dest/$d" && + cat "$i" > "$dest/$i" && + chmod +x "$dest/$i" + else + echo "Not found: $i" + fi + mkchroot "$dest" $(ldd "$i" | egrep -o '/.* ') + done +} + +# Set up a chroot environment and run commands within it. +# Needed commands listed on command line +# Script fed to stdin. + +dochroot() +{ + mkdir tmpdir4chroot + mount -t ramfs tmpdir4chroot tmpdir4chroot + mkdir -p tmpdir4chroot/{etc,sys,proc,tmp,dev} + cp -L testing.sh tmpdir4chroot + + # Copy utilities from command line arguments + + $ECHO -n "Setup chroot" + mkchroot tmpdir4chroot $* + echo + + mknod tmpdir4chroot/dev/tty c 5 0 + mknod tmpdir4chroot/dev/null c 1 3 + mknod tmpdir4chroot/dev/zero c 1 5 + + # Copy script from stdin + + cat > tmpdir4chroot/test.sh + chmod +x tmpdir4chroot/test.sh + chroot tmpdir4chroot /test.sh + umount -l tmpdir4chroot + rmdir tmpdir4chroot +} diff --git a/testsuite/touch/touch-creates-file b/testsuite/touch/touch-creates-file new file mode 100644 index 0000000..4b49354 --- /dev/null +++ b/testsuite/touch/touch-creates-file @@ -0,0 +1,2 @@ +busybox touch foo +test -f foo diff --git a/testsuite/touch/touch-does-not-create-file b/testsuite/touch/touch-does-not-create-file new file mode 100644 index 0000000..8852592 --- /dev/null +++ b/testsuite/touch/touch-does-not-create-file @@ -0,0 +1,2 @@ +busybox touch -c foo +test ! -f foo diff --git a/testsuite/touch/touch-touches-files-after-non-existent-file b/testsuite/touch/touch-touches-files-after-non-existent-file new file mode 100644 index 0000000..a869ec2 --- /dev/null +++ b/testsuite/touch/touch-touches-files-after-non-existent-file @@ -0,0 +1,3 @@ +touch -t 198001010000 bar +busybox touch -c foo bar +test x"`find bar -mtime -1`" = xbar diff --git a/testsuite/tr/tr-d-alnum-works b/testsuite/tr/tr-d-alnum-works new file mode 100644 index 0000000..d440f8f --- /dev/null +++ b/testsuite/tr/tr-d-alnum-works @@ -0,0 +1,4 @@ +echo testing | tr -d '[[:alnum:]]' > logfile.gnu +echo testing | busybox tr -d '[[:alnum:]]' > logfile.bb + +diff -u logfile.gnu logfile.bb diff --git a/testsuite/tr/tr-d-works b/testsuite/tr/tr-d-works new file mode 100644 index 0000000..a86bfbd --- /dev/null +++ b/testsuite/tr/tr-d-works @@ -0,0 +1,4 @@ +echo testing | tr -d aeiou > logfile.gnu +echo testing | busybox tr -d aeiou > logfile.bb + +diff -u logfile.gnu logfile.bb diff --git a/testsuite/tr/tr-non-gnu b/testsuite/tr/tr-non-gnu new file mode 100644 index 0000000..ffa6951 --- /dev/null +++ b/testsuite/tr/tr-non-gnu @@ -0,0 +1 @@ +echo fdhrnzvfu bffvsentr | busybox tr '[a-z]' '[n-z][a-m]' diff --git a/testsuite/tr/tr-rejects-wrong-class b/testsuite/tr/tr-rejects-wrong-class new file mode 100644 index 0000000..9753936 --- /dev/null +++ b/testsuite/tr/tr-rejects-wrong-class @@ -0,0 +1,19 @@ +echo t12esting | tr -d '[[:alpha:]]' > logfile.gnu +echo t12esting | tr -d '[:alpha:]' >> logfile.gnu +echo t12esting | tr -d '[[:alpha:]' >> logfile.gnu +echo t12esting | tr -d '[[:alpha:' >> logfile.gnu +echo t12esting | tr -d '[[:alpha' >> logfile.gnu +echo t12esting | tr -d '[:alpha:]' >> logfile.gnu +echo t12esting | tr -d '[:alpha:' >> logfile.gnu +echo t12esting | tr -d '[:alpha' >> logfile.gnu + +echo t12esting | busybox tr -d '[[:alpha:]]' > logfile.bb +echo t12esting | busybox tr -d '[:alpha:]' >> logfile.bb +echo t12esting | busybox tr -d '[[:alpha:]' >> logfile.bb +echo t12esting | busybox tr -d '[[:alpha:' >> logfile.bb +echo t12esting | busybox tr -d '[[:alpha' >> logfile.bb +echo t12esting | busybox tr -d '[:alpha:]' >> logfile.bb +echo t12esting | busybox tr -d '[:alpha:' >> logfile.bb +echo t12esting | busybox tr -d '[:alpha' >> logfile.bb + +diff -u logfile.gnu logfile.bb diff --git a/testsuite/tr/tr-works b/testsuite/tr/tr-works new file mode 100644 index 0000000..2c0a9d1 --- /dev/null +++ b/testsuite/tr/tr-works @@ -0,0 +1,26 @@ +run_tr () +{ + echo -n "echo '$1' | tr '$2' '$3': " + echo "$1" | $bb tr "$2" "$3" + echo +} +tr_test () +{ + run_tr "cbaab" abc zyx + run_tr "TESTING A B C" '[A-Z]' '[a-z]' + run_tr "abc[]" "a[b" AXB + run_tr abc '[:alpha:]' A-ZA-Z + run_tr abc56 '[:alnum:]' A-ZA-Zxxxxxxxxxx + run_tr 012 '[:digit:]' abcdefghi + run_tr abc56 '[:lower:]' '[:upper:]' + run_tr " " '[:space:]' 12345 + run_tr " " '[:blank:]' 12 + run_tr 'a b' '[= =]' X + run_tr "[:" '[:' ab + run_tr " .,:" '[:punct:]' 12 + run_tr " .,:" '[:cntrl:]' 12 +} + +bb= tr_test > logfile.gnu +bb=busybox tr_test > logfile.bb +diff -u logfile.gnu logfile.bb diff --git a/testsuite/true/true-is-silent b/testsuite/true/true-is-silent new file mode 100644 index 0000000..1d1bdb2 --- /dev/null +++ b/testsuite/true/true-is-silent @@ -0,0 +1 @@ +busybox true 2>&1 | cmp - /dev/null diff --git a/testsuite/true/true-returns-success b/testsuite/true/true-returns-success new file mode 100644 index 0000000..cdf2d55 --- /dev/null +++ b/testsuite/true/true-returns-success @@ -0,0 +1 @@ +busybox true diff --git a/testsuite/umlwrapper.sh b/testsuite/umlwrapper.sh new file mode 100755 index 0000000..e55e4db --- /dev/null +++ b/testsuite/umlwrapper.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Wrapper for User Mode Linux emulation environment + +RUNFILE="$(pwd)/${1}.testroot" +if [ -z "$RUNFILE" ] || [ ! -x "$RUNFILE" ] +then + echo "Can't run '$RUNFILE'" + exit 1 +fi + +shift + +if [ -z $(which linux) ] +then + echo "No User Mode Linux." + exit 1; +fi + +linux rootfstype=hostfs rw init="$RUNFILE" TESTDIR=`pwd` PATH="$PATH" $* quiet diff --git a/testsuite/unexpand/unexpand-works-like-GNU b/testsuite/unexpand/unexpand-works-like-GNU new file mode 100644 index 0000000..a525836 --- /dev/null +++ b/testsuite/unexpand/unexpand-works-like-GNU @@ -0,0 +1,52 @@ +rm -f foo bar +echo " y" | unexpand ../../busybox > foo +echo " y" | busybox unexpand ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi +rm -f foo bar +echo " y" | unexpand ../../busybox > foo +echo " y" | busybox unexpand ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi +echo " y y" | unexpand ../../busybox > foo +echo " y y" | busybox unexpand ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi +rm -f foo bar +echo " y y" | unexpand ../../busybox > foo +echo " y y" | busybox unexpand ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi +echo " y y" | unexpand -a ../../busybox > foo +echo " y y" | busybox unexpand -a ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi +rm -f foo bar +echo " y y" | unexpand -a ../../busybox > foo +echo " y y" | busybox unexpand -a ../../busybox > bar +set +e +test ! -f foo -a -f bar +if [ $? = 0 ] ; then + set -e + diff -q foo bar +fi diff --git a/testsuite/uniq.tests b/testsuite/uniq.tests new file mode 100755 index 0000000..8961d66 --- /dev/null +++ b/testsuite/uniq.tests @@ -0,0 +1,87 @@ +#!/bin/sh + +# SUSv3 compliant uniq tests. +# Copyright 2005 by Rob Landley +# Licensed under GPL v2, see file LICENSE for details. + +# AUDIT: Full SUSv3 coverage (except internationalization). + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +# Test exit status + +testing "uniq (exit with error)" "uniq nonexistent 2> /dev/null || echo yes" \ + "yes\n" "" "" +testing "uniq (exit success)" "uniq /dev/null && echo yes" "yes\n" "" "" + +# Test various data sources and destinations + +testing "uniq (default to stdin)" "uniq" "one\ntwo\nthree\n" "" \ + "one\ntwo\ntwo\nthree\nthree\nthree\n" +testing "uniq - (specify stdin)" "uniq -" "one\ntwo\nthree\n" "" \ + "one\ntwo\ntwo\nthree\nthree\nthree\n" +testing "uniq input (specify file)" "uniq input" "one\ntwo\nthree\n" \ + "one\ntwo\ntwo\nthree\nthree\nthree\n" "" + +testing "uniq input outfile (two files)" "uniq input actual > /dev/null" \ + "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" "" +testing "uniq (stdin) outfile" "uniq - actual" \ + "one\ntwo\nthree\n" "" "one\ntwo\ntwo\nthree\nthree\nthree\n" +# Note: SUSv3 doesn't seem to require support for "-" output, but we do anyway. +testing "uniq input - (specify stdout)" "uniq input -" \ + "one\ntwo\nthree\n" "one\ntwo\ntwo\nthree\nthree\nthree\n" "" + + +#-f skip fields +#-s skip chars +#-c occurrences +#-d dups only +#-u +#-w max chars + +# Test various command line options + +# Leading whitespace is a minor technical violation of the spec, +# but since gnu does it... +testing "uniq -c (occurrence count)" "uniq -c | sed 's/^[ \t]*//'" \ + "1 one\n2 two\n3 three\n" "" \ + "one\ntwo\ntwo\nthree\nthree\nthree\n" +testing "uniq -d (dups only) " "uniq -d" "two\nthree\n" "" \ + "one\ntwo\ntwo\nthree\nthree\nthree\n" + +testing "uniq -f -s (skip fields and chars)" "uniq -f2 -s 3" \ +"cc dd ee8 +aa bb cc9 +" "" \ +"cc dd ee8 +bb cc dd8 +aa bb cc9 +" +testing "uniq -w (compare max characters)" "uniq -w 2" \ +"cc1 +" "" \ +"cc1 +cc2 +cc3 +" + +testing "uniq -s -w (skip fields and compare max chars)" \ +"uniq -s 2 -w 2" \ +"aaccaa +" "" \ +"aaccaa +aaccbb +bbccaa +" + +# -d is "Suppress the writing fo lines that are not repeated in the input." +# -u is "Suppress the writing of lines that are repeated in the input." +# Therefore, together this means they should produce no output. +testing "uniq -u and -d produce no output" "uniq -d -u" "" "" \ + "one\ntwo\ntwo\nthree\nthree\nthree\n" + +exit $FAILCOUNT diff --git a/testsuite/unzip.tests b/testsuite/unzip.tests new file mode 100755 index 0000000..975079d --- /dev/null +++ b/testsuite/unzip.tests @@ -0,0 +1,38 @@ +#!/bin/sh + +# Tests for unzip. +# Copyright 2006 Rob Landley +# Copyright 2006 Glenn McGrath +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" +# file input will be file called "input" +# test can create a file "actual" instead of writing to stdout + +# Create a scratch directory + +mkdir temp +cd temp + +# Create test file to work with. + +mkdir foo +touch foo/bar +zip foo.zip foo foo/bar > /dev/null +rm -f foo/bar +rmdir foo + +# Test that unzipping just foo doesn't create bar. +testing "unzip (subdir only)" "unzip -q foo.zip foo/ && test -d foo && test ! -f foo/bar && echo yes" "yes\n" "" "" + +rmdir foo +rm foo.zip + +# Clean up scratch directory. + +cd .. +rm -rf temp + +exit $FAILCOUNT diff --git a/testsuite/uptime/uptime-works b/testsuite/uptime/uptime-works new file mode 100644 index 0000000..80e5787 --- /dev/null +++ b/testsuite/uptime/uptime-works @@ -0,0 +1,2 @@ +busybox uptime + diff --git a/testsuite/uuencode.tests b/testsuite/uuencode.tests new file mode 100755 index 0000000..cb658db --- /dev/null +++ b/testsuite/uuencode.tests @@ -0,0 +1,28 @@ +#!/bin/sh + +# unit test for uuencode to test functionality. +# Copyright 2006 by Erik Hovland +# Licensed under GPL v2, see file LICENSE for details. + +# AUDIT: Unit tests for uuencode + +. testing.sh + +# testing "test name" "options" "expected result" "file input" "stdin" +# file input will be file called "input" +# 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" \ + "" "The fast grey fox jumped over the lazy brown dog.\n" +testing "uuencode correct base64 encoding" "uuencode -m bb_uuenc_test.out" \ +"begin-base64 644 bb_uuenc_test.out\nVGhlIGZhc3QgZ3JleSBmb3gganVtcGVkIG92ZXIgdGhlIGxhenkgYnJvd24g\nZG9nLgo=\n====\n" \ + "" "The fast grey fox jumped over the lazy brown dog.\n" +exit $FAILCOUNT diff --git a/testsuite/wc/wc-counts-all b/testsuite/wc/wc-counts-all new file mode 100644 index 0000000..7083645 --- /dev/null +++ b/testsuite/wc/wc-counts-all @@ -0,0 +1,2 @@ +# 1 line, 4 words, 20 chars. +test "`echo i\'m a little teapot | busybox wc | sed 's/ */ /g' | sed 's/^ //'`" = '1 4 20' diff --git a/testsuite/wc/wc-counts-characters b/testsuite/wc/wc-counts-characters new file mode 100644 index 0000000..7558646 --- /dev/null +++ b/testsuite/wc/wc-counts-characters @@ -0,0 +1 @@ +test `echo i\'m a little teapot | busybox wc -c` -eq 20 diff --git a/testsuite/wc/wc-counts-lines b/testsuite/wc/wc-counts-lines new file mode 100644 index 0000000..5be6ed0 --- /dev/null +++ b/testsuite/wc/wc-counts-lines @@ -0,0 +1 @@ +test `echo i\'m a little teapot | busybox wc -l` -eq 1 diff --git a/testsuite/wc/wc-counts-words b/testsuite/wc/wc-counts-words new file mode 100644 index 0000000..331650e --- /dev/null +++ b/testsuite/wc/wc-counts-words @@ -0,0 +1 @@ +test `echo i\'m a little teapot | busybox wc -w` -eq 4 diff --git a/testsuite/wc/wc-prints-longest-line-length b/testsuite/wc/wc-prints-longest-line-length new file mode 100644 index 0000000..78831fc --- /dev/null +++ b/testsuite/wc/wc-prints-longest-line-length @@ -0,0 +1 @@ +test `echo i\'m a little teapot | busybox wc -L` -eq 19 diff --git a/testsuite/wget/wget--O-overrides--P b/testsuite/wget/wget--O-overrides--P new file mode 100644 index 0000000..fdb5d47 --- /dev/null +++ b/testsuite/wget/wget--O-overrides--P @@ -0,0 +1,3 @@ +mkdir foo +busybox wget -q -O index.html -P foo http://www.google.com/ +test -s index.html diff --git a/testsuite/wget/wget-handles-empty-path b/testsuite/wget/wget-handles-empty-path new file mode 100644 index 0000000..5b59183 --- /dev/null +++ b/testsuite/wget/wget-handles-empty-path @@ -0,0 +1 @@ +busybox wget http://www.google.com diff --git a/testsuite/wget/wget-retrieves-google-index b/testsuite/wget/wget-retrieves-google-index new file mode 100644 index 0000000..7be9a80 --- /dev/null +++ b/testsuite/wget/wget-retrieves-google-index @@ -0,0 +1,2 @@ +busybox wget -q -O foo http://www.google.com/ +test -s foo diff --git a/testsuite/wget/wget-supports--P b/testsuite/wget/wget-supports--P new file mode 100644 index 0000000..9b4d095 --- /dev/null +++ b/testsuite/wget/wget-supports--P @@ -0,0 +1,3 @@ +mkdir foo +busybox wget -q -P foo http://www.google.com/ +test -s foo/index.html diff --git a/testsuite/which/which-uses-default-path b/testsuite/which/which-uses-default-path new file mode 100644 index 0000000..63ceb9f --- /dev/null +++ b/testsuite/which/which-uses-default-path @@ -0,0 +1,4 @@ +BUSYBOX=$(type -p busybox) +SAVED_PATH=$PATH +unset PATH +$BUSYBOX which ls diff --git a/testsuite/xargs.tests b/testsuite/xargs.tests new file mode 100755 index 0000000..3652449 --- /dev/null +++ b/testsuite/xargs.tests @@ -0,0 +1,29 @@ +#!/bin/sh +# Copyright 2008 by Denys Vlasenko +# Licensed under GPL v2, see file LICENSE for details. + +. testing.sh + +# testing "test name" "command" "expected result" "file input" "stdin" + +testing "xargs -E _ stops on underscore" \ + "xargs -E _" \ + "a\n" \ + "" "a\n_\nb\n" + +testing "xargs -E ''" \ + "xargs -E ''" \ + "a _ b\n" \ + "" "a\n_\nb\n" + +testing "xargs -e without param" \ + "xargs -e" \ + "a _ b\n" \ + "" "a\n_\nb\n" + +testing "xargs does not stop on underscore ('new' GNU behavior)" \ + "xargs" \ + "a _ b\n" \ + "" "a\n_\nb\n" + +exit $FAILCOUNT diff --git a/testsuite/xargs/xargs-works b/testsuite/xargs/xargs-works new file mode 100644 index 0000000..c95869e --- /dev/null +++ b/testsuite/xargs/xargs-works @@ -0,0 +1,4 @@ +[ -n "$d" ] || d=.. +find "$d" -name \*works -type f | xargs md5sum > logfile.gnu +find "$d" -name \*works -type f | busybox xargs md5sum > logfile.bb +diff -u logfile.gnu logfile.bb -- cgit v1.2.3