annotate tests/printf.test @ 1766:190ecf70fbe5 draft

Fix an obvious typo in Makefile.
author Elliott Hughes <enh@google.com>
date Sat, 28 Mar 2015 13:13:42 -0500
parents 114fb916e04e
children 12fa15de1cd4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1364
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
1 #!/bin/bash
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
2
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
3 # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
4 # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
5
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
6 [ -f testing.sh ] && . testing.sh
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
7
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
8 #testing "name" "command" "result" "infile" "stdin"
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
9
1648
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
10 # Disable shell builtin
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
11 PRINTF="$(which printf)"
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
12
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
13 testing "printf text" "$PRINTF TEXT" "TEXT" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
14 testing "printf escapes" "$PRINTF 'one\ntwo\n\v\t\r\f\e\b\athree'" \
1647
35c035b7e3e0 More printf cleanup, and test suite entries.
Rob Landley <rob@landley.net>
parents: 1485
diff changeset
15 "one\ntwo\n\v\t\r\f\e\b\athree" "" ""
1648
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
16 testing "printf %b escapes" "$PRINTF %b 'one\ntwo\n\v\t\r\f\e\b\athree'" \
1647
35c035b7e3e0 More printf cleanup, and test suite entries.
Rob Landley <rob@landley.net>
parents: 1485
diff changeset
17 "one\ntwo\n\v\t\r\f\e\b\athree" "" ""
1648
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
18 testing "printf null" "$PRINTF 'x\0y' | od -An -tx1" ' 78 00 79\n' "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
19 testing "printf trailing slash" "$PRINTF 'abc\'" 'abc\' "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
20 testing "printf octal" "$PRINTF ' \1\002\429\045x'" ' \001\002"9%x' "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
21 testing "printf not octal" "$PRINTF '\9'" '\9' "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
22 testing "printf hex" "$PRINTF 'A\x1b\x2B\x3Q\xa' | od -An -tx1" \
1647
35c035b7e3e0 More printf cleanup, and test suite entries.
Rob Landley <rob@landley.net>
parents: 1485
diff changeset
23 ' 41 1b 2b 03 51 0a\n' "" ""
1649
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
24 testing "printf %x" "$PRINTF '%x\n' 0x2a" "2a\n" "" ""
1647
35c035b7e3e0 More printf cleanup, and test suite entries.
Rob Landley <rob@landley.net>
parents: 1485
diff changeset
25
1648
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
26 testing "printf %d 42" "$PRINTF %d 42" "42" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
27 testing "printf %d 0x2a" "$PRINTF %d 0x2a" "42" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
28 testing "printf %d 052" "$PRINTF %d 052" "42" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
29
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
30 testing "printf %s width precision" \
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
31 "$PRINTF '%3s,%.3s,%10s,%10.3s' abcde fghij klmno pqrst" \
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
32 "abcde,fgh, klmno, pqr" "" ""
1647
35c035b7e3e0 More printf cleanup, and test suite entries.
Rob Landley <rob@landley.net>
parents: 1485
diff changeset
33
1649
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
34 # posix: "The format operand shall be reused as often as necessary to satisfy
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
35 # the argument operands."
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
36
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
37 testing "printf extra args" "$PRINTF 'abc%s!%ddef\n' X 42 ARG 36" \
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
38 "abcX!42def\nabcARG!36def\n" "" ""
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
39
1651
114fb916e04e One more bugfix for printf.c, with test suite entry. (Make %-3d etc work.)
Rob Landley <rob@landley.net>
parents: 1649
diff changeset
40 testing "printf '%3c'" "$PRINTF '%3c' x" " x" "" ""
114fb916e04e One more bugfix for printf.c, with test suite entry. (Make %-3d etc work.)
Rob Landley <rob@landley.net>
parents: 1649
diff changeset
41 testing "printf '%-3c'" "$PRINTF '%-3c' x" "x " "" ""
114fb916e04e One more bugfix for printf.c, with test suite entry. (Make %-3d etc work.)
Rob Landley <rob@landley.net>
parents: 1649
diff changeset
42 testing "printf '%+d'" "$PRINTF '%+d' 5" "+5" "" ""
114fb916e04e One more bugfix for printf.c, with test suite entry. (Make %-3d etc work.)
Rob Landley <rob@landley.net>
parents: 1649
diff changeset
43
1649
66bb2847993d More half-finished cleanup of printf.c, and more test suite entries.
Rob Landley <rob@landley.net>
parents: 1648
diff changeset
44
1364
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
45 testing "printf '%5d%4d' 1 21 321 4321 54321" \
1648
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
46 "$PRINTF '%5d%4d' 1 21 321 4321 54321" " 1 21 321432154321 0" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
47 testing "printf '%c %c' 78 79" "$PRINTF '%c %c' 78 79" "7 7" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
48 testing "printf '%d %d' 78 79" "$PRINTF '%d %d' 78 79" "78 79" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
49 testing "printf '%f %f' 78 79" "$PRINTF '%f %f' 78 79" \
1364
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
50 "78.000000 79.000000" "" ""
1648
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
51 testing "printf 'f f' 78 79" "$PRINTF 'f f' 78 79" "f f" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
52 testing "printf '%i %i' 78 79" "$PRINTF '%i %i' 78 79" "78 79" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
53 testing "printf '%o %o' 78 79" "$PRINTF '%o %o' 78 79" "116 117" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
54 testing "printf '%u %u' 78 79" "$PRINTF '%u %u' 78 79" "78 79" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
55 testing "printf '%u %u' -1 -2" "$PRINTF '%u %u' -1 -2" \
1364
94677e7b6d97 I have developed few testsuite for toybox commands - ls, ln, rm, mv, printf, dd, renice.
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
56 "18446744073709551615 18446744073709551614" "" ""
1648
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
57 testing "printf '%x %X' 78 79" "$PRINTF '%x %X' 78 79" "4e 4F" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
58 testing "printf '%g %G' 78 79" "$PRINTF '%g %G' 78 79" "78 79" "" ""
d27136a0811b Since "printf" is a shell builtin, printf.test wasn't actually testing anything.
Rob Landley <rob@landley.net>
parents: 1647
diff changeset
59 testing "printf '%s %s' 78 79" "$PRINTF '%s %s' 78 79" "78 79" "" ""