blob: d4be949ecabe844e4e37fe9e9507fa5506df2dfb [file] [log] [blame]
Denis Vlasenko1e2a7e42008-02-09 05:48:42 +00001#!/bin/sh
2
3# Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com>
4# Licensed under GPL v2, see file LICENSE for details.
5
6. testing.sh
7
Denis Vlasenkobd28f6b2008-07-19 08:15:13 +00008# testing "test name" "command" "expected result" "file input" "stdin"
Denis Vlasenko1e2a7e42008-02-09 05:48:42 +00009# 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 Vlasenkobd28f6b2008-07-19 08:15:13 +000014testing "test: should be false (1)" \
15 "busybox test; echo \$?" \
16 "1\n" \
17 "" ""
18
19testing "test '': should be false (1)" \
20 "busybox test ''; echo \$?" \
21 "1\n" \
22 "" ""
23
24testing "test a: should be true (0)" \
25 "busybox test a; echo \$?" \
26 "0\n" \
27 "" ""
28
29testing "test --help: should be true (0)" \
30 "busybox test --help; echo \$?" \
31 "0\n" \
32 "" ""
33
34testing "test -f: should be true (0)" \
35 "busybox test -f; echo \$?" \
36 "0\n" \
37 "" ""
38
39testing "test ! -f: should be false (1)" \
40 "busybox test ! -f; echo \$?" \
41 "1\n" \
42 "" ""
43
44testing "test a = a: should be true (0)" \
45 "busybox test a = a; echo \$?" \
46 "0\n" \
47 "" ""
48
49testing "test -lt = -gt: should be false (1)" \
50 "busybox test -lt = -gt; echo \$?" \
51 "1\n" \
52 "" ""
53
54testing "test -f = a -o b: should be true (0)" \
55 "busybox test -f = a -o b; echo \$?" \
56 "0\n" \
57 "" ""
58
59testing "test ! a = b -a ! c = c: should be false (1)" \
Denis Vlasenko1e2a7e42008-02-09 05:48:42 +000060 "busybox test ! a = b -a ! c = c; echo \$?" \
61 "1\n" \
Denis Vlasenkobd28f6b2008-07-19 08:15:13 +000062 "" ""
Denis Vlasenko1e2a7e42008-02-09 05:48:42 +000063
Denis Vlasenkobd28f6b2008-07-19 08:15:13 +000064testing "test ! a = b -a ! c = d: should be true (0)" \
Denis Vlasenko1e2a7e42008-02-09 05:48:42 +000065 "busybox test ! a = b -a ! c = d; echo \$?" \
66 "0\n" \
Denis Vlasenkobd28f6b2008-07-19 08:15:13 +000067 "" ""
Denis Vlasenko1e2a7e42008-02-09 05:48:42 +000068
69exit $FAILCOUNT