Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com> |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 4 | # Licensed under GPLv2, see file LICENSE in this source tree. |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 5 | |
Mike Frysinger | caa7940 | 2009-11-04 18:41:22 -0500 | [diff] [blame] | 6 | . ./testing.sh |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 7 | |
Denis Vlasenko | bd28f6b | 2008-07-19 08:15:13 +0000 | [diff] [blame] | 8 | # testing "test name" "command" "expected result" "file input" "stdin" |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 9 | # file input will be file called "input" |
| 10 | # test can create a file "actual" instead of writing to stdout |
| 11 | |
| 12 | # Need to call 'busybox test', otherwise shell builtin is used |
| 13 | |
Denis Vlasenko | bd28f6b | 2008-07-19 08:15:13 +0000 | [diff] [blame] | 14 | testing "test: should be false (1)" \ |
| 15 | "busybox test; echo \$?" \ |
| 16 | "1\n" \ |
| 17 | "" "" |
| 18 | |
| 19 | testing "test '': should be false (1)" \ |
| 20 | "busybox test ''; echo \$?" \ |
| 21 | "1\n" \ |
| 22 | "" "" |
| 23 | |
Denys Vlasenko | d23f64e | 2009-07-17 00:59:26 +0200 | [diff] [blame] | 24 | testing "test !: should be true (0)" \ |
| 25 | "busybox test !; echo \$?" \ |
| 26 | "0\n" \ |
| 27 | "" "" |
| 28 | |
Denis Vlasenko | bd28f6b | 2008-07-19 08:15:13 +0000 | [diff] [blame] | 29 | testing "test a: should be true (0)" \ |
| 30 | "busybox test a; echo \$?" \ |
| 31 | "0\n" \ |
| 32 | "" "" |
| 33 | |
| 34 | testing "test --help: should be true (0)" \ |
| 35 | "busybox test --help; echo \$?" \ |
| 36 | "0\n" \ |
| 37 | "" "" |
| 38 | |
| 39 | testing "test -f: should be true (0)" \ |
| 40 | "busybox test -f; echo \$?" \ |
| 41 | "0\n" \ |
| 42 | "" "" |
| 43 | |
| 44 | testing "test ! -f: should be false (1)" \ |
| 45 | "busybox test ! -f; echo \$?" \ |
| 46 | "1\n" \ |
| 47 | "" "" |
| 48 | |
| 49 | testing "test a = a: should be true (0)" \ |
| 50 | "busybox test a = a; echo \$?" \ |
| 51 | "0\n" \ |
| 52 | "" "" |
| 53 | |
| 54 | testing "test -lt = -gt: should be false (1)" \ |
| 55 | "busybox test -lt = -gt; echo \$?" \ |
| 56 | "1\n" \ |
| 57 | "" "" |
| 58 | |
Denys Vlasenko | d23f64e | 2009-07-17 00:59:26 +0200 | [diff] [blame] | 59 | testing "test a -a !: should be true (0)" \ |
| 60 | "busybox test a -a !; echo \$?" \ |
| 61 | "0\n" \ |
| 62 | "" "" |
| 63 | |
Denis Vlasenko | bd28f6b | 2008-07-19 08:15:13 +0000 | [diff] [blame] | 64 | testing "test -f = a -o b: should be true (0)" \ |
| 65 | "busybox test -f = a -o b; echo \$?" \ |
| 66 | "0\n" \ |
| 67 | "" "" |
| 68 | |
| 69 | testing "test ! a = b -a ! c = c: should be false (1)" \ |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 70 | "busybox test ! a = b -a ! c = c; echo \$?" \ |
| 71 | "1\n" \ |
Denis Vlasenko | bd28f6b | 2008-07-19 08:15:13 +0000 | [diff] [blame] | 72 | "" "" |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 73 | |
Denis Vlasenko | bd28f6b | 2008-07-19 08:15:13 +0000 | [diff] [blame] | 74 | testing "test ! a = b -a ! c = d: should be true (0)" \ |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 75 | "busybox test ! a = b -a ! c = d; echo \$?" \ |
| 76 | "0\n" \ |
Denis Vlasenko | bd28f6b | 2008-07-19 08:15:13 +0000 | [diff] [blame] | 77 | "" "" |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 78 | |
Denys Vlasenko | 98654b9 | 2014-07-01 14:16:28 +0200 | [diff] [blame] | 79 | testing "test '!' = '!': should be true (0)" \ |
| 80 | "busybox test '!' = '!'; echo \$?" \ |
| 81 | "0\n" \ |
| 82 | "" "" |
| 83 | |
| 84 | testing "test '(' = '(': should be true (0)" \ |
| 85 | "busybox test '(' = '('; echo \$?" \ |
| 86 | "0\n" \ |
| 87 | "" "" |
| 88 | |
| 89 | testing "test '!' '!' = '!': should be false (1)" \ |
| 90 | "busybox test '!' '!' = '!'; echo \$?" \ |
| 91 | "1\n" \ |
| 92 | "" "" |
| 93 | |
| 94 | testing "test '!' '(' = '(': should be false (1)" \ |
| 95 | "busybox test '!' '(' = '('; echo \$?" \ |
| 96 | "1\n" \ |
| 97 | "" "" |
| 98 | |
Denis Vlasenko | 1e2a7e4 | 2008-02-09 05:48:42 +0000 | [diff] [blame] | 99 | exit $FAILCOUNT |