[Toybox] [PATCH 5/8] Add new toy - test

Georgi Chorbadzhiyski gf at unixsol.org
Tue Apr 24 02:26:22 PDT 2012


Attached is the script I have used for testing the test toy.

-- 
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
-------------- next part --------------
#!/bin/sh

function t_ext() {
	/usr/bin/test $@
	echo $?
}

function t_toybox() {
	./toybox test $@
	echo $?
}

function t() {
	[ $TOYBOX = 0 ] && t_ext $@
	[ $TOYBOX = 1 ] && t_toybox $@
}

function do_test {
	echo 't -b /dev/sda1'
	t -b /dev/ttyp2
	echo 't -b /dev/jb1a'
	t -b /dev/jb1a

	echo 't -c /etc/passwd'
	t -c /etc/passwd
	echo 't -c /dev/tty'
	t -c /dev/tty

	echo 't -d /etc/passwd'
	t -d /etc/passwd
	echo 't -d /etc'
	t -d /etc

	echo 't -e noexist'
	t -e noexist
	echo 't -e /etc/passwd'
	t -e /etc/passwd

	echo 't -f noexist'
	t -f noexist
	echo 't -f /dev/tty'
	t -f /dev/tty
	echo 't -f /etc/passwd'
	t -f /etc/passwd

	echo 't -g /etc/passwd'
	t -g /etc/passwd
	echo 't -g /bin/ps'
	t -g /not_exist

	echo 't -n ""'
	t -n ""
	echo 't -n "hello"'
	t -n "hello"

	echo 't -p /etc/passwd'
	t -p /etc/passwd

	echo 't -r noexist'
	t -r noexist
	echo 't -r /etc/master.passwd'
	t -r /etc/master.passwd
	echo 't -r /etc/passwd'
	t -r /etc/passwd

	echo 't -s noexist'
	t -s noexist
	echo 't -s /dev/null'
	t -s /dev/null
	echo 't -s /etc/passwd'
	t -s /etc/passwd

	echo 't -t 20'
	t -t 20
	echo 't -t 0'
	t -t 0

	echo 't -u /etc/passwd'
	t -u /etc/passwd
	echo 't -u /bin/sh'
	t -u /bin/sh

	echo 't -w noexist'
	t -w noexist
	echo 't -w /etc/passwd'
	t -w /etc/passwd
	echo 't -w /dev/null'
	t -w /dev/null

	echo 't -x noexist'
	t -x noexist
	echo 't -x /bin/ps'
	t -x /bin/ps
	echo 't -x /etc/motd'
	t -x /etc/motd

	echo 't -z ""'
	t -z ""
	echo 't -z "foo"'
	t -z "foo"

	echo 't "foo"'
	t "foo"
	echo 't ""'
	t ""

	echo 't "hello" = "hello"'
	t "hello" = "hello"
	echo 't "hello" = "goodbye"'
	t "hello" = "goodbye"

	echo 't "hello" != "hello"'
	t "hello" != "hello"
	echo 't "hello" != "goodbye"'
	t "hello" != "goodbye"

	echo 't 200 -eq 200'
	t 200 -eq 200
	echo 't 34 -eq 222'
	t 34 -eq 222

	echo 't 200 -ne 200'
	t 200 -ne 200
	echo 't 34 -ne 222'
	t 34 -ne 222

	echo 't 200 -gt 200'
	t 200 -gt 200
	echo 't 340 -gt 222'
	t 340 -gt 222

	echo 't 200 -ge 200'
	t 200 -ge 200
	echo 't 34 -ge 222'
	t 34 -ge 222

	echo 't 200 -lt 200'
	t 200 -lt 200
	echo 't 34 -lt 222'
	t 34 -lt 222

	echo 't 200 -le 200'
	t 200 -le 200
	echo 't 340 -le 222'
	t 340 -le 222

	echo 't 700 -le 1000 -a -n "1" -a "20" = "20"'
	t 700 -le 1000 -a -n "1" -a "20" = "20"
	echo 't ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)'
	t ! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)
}

TOYBOX=0
do_test > test_test.ext

TOYBOX=1
do_test > test_test.toybox

diff -uw test_test.ext test_test.toybox
[ $? = 0 ] && echo "OK" || echo "ERROR"


More information about the Toybox mailing list