Mercurial > hg > toybox
view 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 |
line wrap: on
line source
#!/bin/bash [ -f testing.sh ] && . testing.sh # This one's tricky both because echo is a shell builtin (so $PATH is # irrelevant) and because the "result" field is parsed with echo -e. # To make it work, "$CMD" is an explicit path to the command being tested, # so "result" keeps using the shell builtin but we test the one in toybox. CMD="$(which echo)" #testing "name" "command" "result" "infile" "stdin" testing "echo" "$CMD && echo yes" "\nyes\n" "" "" testing "echo 1 2 3" "$CMD one two three" "one two three\n" "" "" testing "echo with spaces" "$CMD 'one two three'" \ "one two three\n" "" "" testing "echo -n" "$CMD -n" "" "" "" testing "echo -n one" "$CMD -n one" "one" "" "" testing "echo one -n" "$CMD one -n" "one -n\n" "" "" testing "echo -en" "$CMD -en 'one\ntwo'" "one\ntwo" "" "" testing "echo --hello" "$CMD --hello" "--hello\n" "" "" testing "echo -e all" "$CMD -e '\a\b\c\f\n\r\t\v\\\0123'" \ "\a\b\c\f\n\r\t\v\\\0123\n" "" "" testing "echo -nex hello" "$CMD -nex hello" "-nex hello\n" "" "" # Octal formatting tests testing "echo -e octal values" \ "$CMD -ne '\01234 \0060 \060 \0130\0131\0132 \077\012'" \ "S4 0 0 XYZ ?\n" "" "" # Hexadecimal value tests testing "echo -e hexadecimal values" \ "$CMD -ne '\x534 \x30 \x58\x59\x5a \x3F\x0A'"\ "S4 0 XYZ ?\n" "" "" testing "echo -e \p" "$CMD -e '\\p'" "\\p\n" "" ""