diff options
author | Elliott Hughes <enh@google.com> | 2016-02-18 21:11:07 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-02-19 11:54:06 -0600 |
commit | 577b7cabd4bae054e314484249f28088b5f385ab (patch) | |
tree | 31599e39ad9b50922657ee1c01549de6cee1c310 /tests/xxd.test | |
parent | 42cad120baa22bc043bcce6f5aac74fa26a01aef (diff) | |
download | toybox-577b7cabd4bae054e314484249f28088b5f385ab.tar.gz |
Add xxd -p and -r.
SELinux denials include hex-encoded paths in the log messages; xxd -r -p is
a convenient way to decode them.
The heuristics are a little weird to my mind, but match the documentation
and observed behavior.
Diffstat (limited to 'tests/xxd.test')
-rw-r--r-- | tests/xxd.test | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/xxd.test b/tests/xxd.test index e036865a..68f52be4 100644 --- a/tests/xxd.test +++ b/tests/xxd.test @@ -25,4 +25,23 @@ testing "xxd -c 8 -g 4 file1" "xxd -c 8 -g 4 file1" \ testing "xxd -c 8 -g 3 file1" "xxd -c 8 -g 3 file1" \ "00000000: 746869 732069 7320 this is \n00000008: 736f6d 652074 6578 some tex\n00000010: 740a t.\n" "" "" +testing "xxd -p" "xxd -p file1" "7468697320697320736f6d6520746578740a\n" "" "" + +testing "xxd -r" "xxd file1 | xxd -r" "this is some text\n" "" "" +testing "xxd -r -p" "xxd -p file1 | xxd -r -p" "this is some text\n" "" "" + +testing "xxd -r garbage" "echo '0000: 68 65 6c6c 6fxxxx' | xxd -r -" "hello" "" "" + +# -r will only read -c bytes (default 16) before skipping to the next line, +# ignoring the rest. +testing "xxd -r long" \ + "echo '0000: 40404040404040404040404040404040404040404040404040404040404040404040404040404040' | xxd -r -" \ + "@@@@@@@@@@@@@@@@" "" "" + +# -r -p ignores the usual -p 30-byte/line limit (or any limit set by -c) and +# will take as many bytes as you give it. +testing "xxd -r -p long" \ + "echo '40404040404040404040404040404040404040404040404040404040404040404040404040404040' | xxd -r -p -" \ + "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" "" "" + rm file1 file2 |