annotate scripts/test/wc.test @ 1087:b73a61542297 draft

I've finally gotten 'cpio' into a shape where it could be useable. This version can archive and extract directories, sockets, FIFOs, devices, symlinks, and regular files. Supported options are -iot, -H FMT (which is a dummy right now). It only writes newc, and could read newc or newcrc. This does NOT implement -d, which essentially is equivalent to mkdir -p $(dirname $FILE) for every file that needs it. Hard links are not supported, though it would be easy to add them given a hash table or something like that. I also have not implemented the "<n> blocks" output on stderr. If desired, I can add it pretty simply. There is one assumption this makes: that the mode of a file, as mode_t, is bitwise equivalent to the mode as defined for the cpio format. This is true of Linux, but is not mandated by POSIX. If it is compiled for a system where that is false, the archives will not be portable.
author Isaac Dunham <ibid.ag@gmail.com>
date Mon, 14 Oct 2013 11:15:22 -0500
parents cfdaead45479
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
682
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
1 #!/bin/bash
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
2
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
4
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
5 #testing "name" "command" "result" "infile" "stdin"
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
6
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
7 cat >file1 <<EOF
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
8 some words .
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
9
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
10 some
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
11 lines
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
12 EOF
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
13
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
14 testing "wc" "wc >/dev/null && echo yes" "yes\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
15 testing "wc empty file" "wc" "0 0 0\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
16 testing "wc standard input" "wc" "1 3 5\n" "" "a b\nc"
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
17 testing "wc -c" "wc -c file1" "26 file1\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
18 testing "wc -l" "wc -l file1" "4 file1\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
19 testing "wc -w" "wc -w file1" "5 file1\n" "" ""
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
20 testing "wc format" "wc file1" "4 5 26 file1\n" "" ""
686
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
21 testing "wc multiple files" "wc input - file1" \
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
22 "1 2 3 input\n0 2 3 -\n4 5 26 file1\n5 9 32 total\n" "a\nb" "a b"
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
23
710
cfdaead45479 Make internalization support optional
Felix Janda <felix.janda@posteo.de>
parents: 686
diff changeset
24 optional TOYBOX_I18N
cfdaead45479 Make internalization support optional
Felix Janda <felix.janda@posteo.de>
parents: 686
diff changeset
25
686
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
26 #Tests for wc -m
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
27 if printf "%s" "$LANG" | grep -q UTF-8
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
28 then
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
29
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
30 printf " " > file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
31 for i in $(seq 1 8192)
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
32 do
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
33 printf "ü" >> file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
34 done
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
35 testing "wc -m" "wc -m file1" "8193 file1\n" "" ""
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
36 printf " " > file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
37 for i in $(seq 1 8192)
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
38 do
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
39 printf "ü" >> file1
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
40 done
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
41 testing "wc -m (invalid chars)" "wc -m file1" "8193 file1\n" "" ""
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
42 testing "wc -mlw" "wc -mlw input" "1 2 11 input\n" "hello, 世界!\n" ""
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
43
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
44 else
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
45 printf "skipping tests for wc -m"
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
46 fi
9414be56b1db wc -m only cares about counting characters. Attached is a try on implementing it and some test cases for it. The test cases are only for UTF-8 locales.
Felix Janda <felix.janda@posteo.de>
parents: 682
diff changeset
47
682
7894d4afc39c attached are some simple tests for dirname and wc and a fix for a small typo in another test script.
Felix Janda <felix.janda@posteo.de>
parents:
diff changeset
48 rm file1