annotate scripts/test/echo.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 f062652562bd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
294
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
2
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
4
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
5 # This one's tricky both because echo is a shell builtin (so $PATH is
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
6 # irrelevant) and because the "result" field is parsed with echo -e.
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
7 # To make it work, "$CMD" is an explicit path to the command being tested,
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
8 # so "result" keeps using the shell builtin but we test the one in toybox.
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
9
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
10 CMD="$(which echo)"
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
11
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
12 #testing "name" "command" "result" "infile" "stdin"
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
13
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
14 testing "echo" "$CMD && echo yes" "\nyes\n" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
15 testing "echo 1 2 3" "$CMD one two three" "one two three\n" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
16 testing "echo with spaces" "$CMD 'one two three'" \
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
17 "one two three\n" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
18 testing "echo -n" "$CMD -n" "" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
19 testing "echo -n one" "$CMD -n one" "one" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
20 testing "echo one -n" "$CMD one -n" "one -n\n" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
21 testing "echo -en" "$CMD -en 'one\ntwo'" "one\ntwo" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
22 testing "echo --hello" "$CMD --hello" "--hello\n" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
23 testing "echo -e all" "$CMD -e '\a\b\c\f\n\r\t\v\\\0123'" \
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
24 "\a\b\c\f\n\r\t\v\\\0123\n" "" ""
3de1ea4d6b56 Fix command line option parsing so "echo -xen" actually prints "-xen". Add
Rob Landley <rob@landley.net>
parents:
diff changeset
25 testing "echo -nex hello" "$CMD -nex hello" "-nex hello\n" "" ""
449
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
26
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
27 # Octal formatting tests
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
28 testing "echo -e octal values" \
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
29 "$CMD -ne '\01234 \0060 \060 \0130\0131\0132 \077\012'" \
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
30 "S4 0 0 XYZ ?\n" "" ""
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
31
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
32 # Hexadecimal value tests
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
33 testing "echo -e hexadecimal values" \
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
34 "$CMD -ne '\x534 \x30 \x58\x59\x5a \x3F\x0A'"\
d3544d2cdb26 Fix overflow in octal formatting in echo, add support for hexadecimal input, add tests for octal and hexadecimal formatting
Elie De Brauwer <eliedebrauwer@gmail.com>
parents: 294
diff changeset
35 "S4 0 XYZ ?\n" "" ""
508
f062652562bd Cleanup pass, and support unrecognized slash chars ala "echo -e \p".
Rob Landley <rob@landley.net>
parents: 449
diff changeset
36
f062652562bd Cleanup pass, and support unrecognized slash chars ala "echo -e \p".
Rob Landley <rob@landley.net>
parents: 449
diff changeset
37 testing "echo -e \p" "$CMD -e '\\p'" "\\p\n" "" ""