1*cf5a6c84SAndroid Build Coastguard Worker#!/bin/bash 2*cf5a6c84SAndroid Build Coastguard Worker 3*cf5a6c84SAndroid Build Coastguard Worker[ -f testing.sh ] && . testing.sh 4*cf5a6c84SAndroid Build Coastguard Worker 5*cf5a6c84SAndroid Build Coastguard Worker#testing "name" "command" "result" "infile" "stdin" 6*cf5a6c84SAndroid Build Coastguard Worker 7*cf5a6c84SAndroid Build Coastguard Workerecho "this is some text" > file1 8*cf5a6c84SAndroid Build Coastguard Workerecho -n > file2 9*cf5a6c84SAndroid Build Coastguard Worker 10*cf5a6c84SAndroid Build Coastguard Worker# Note that the xxd in vim-common on Ubuntu 14 uses %07x for the file offset. 11*cf5a6c84SAndroid Build Coastguard Worker 12*cf5a6c84SAndroid Build Coastguard Workertestcmd "file1" "file1" \ 13*cf5a6c84SAndroid Build Coastguard Worker "00000000: 7468 6973 2069 7320 736f 6d65 2074 6578 this is some tex\n00000010: 740a t.\n" \ 14*cf5a6c84SAndroid Build Coastguard Worker "" "" 15*cf5a6c84SAndroid Build Coastguard Workertestcmd "file1 -l" "-l 2 file1" \ 16*cf5a6c84SAndroid Build Coastguard Worker "00000000: 7468 th\n" \ 17*cf5a6c84SAndroid Build Coastguard Worker "" "" 18*cf5a6c84SAndroid Build Coastguard Workertestcmd "-" "-" \ 19*cf5a6c84SAndroid Build Coastguard Worker "00000000: 6865 6c6c 6f hello\n" "" "hello" 20*cf5a6c84SAndroid Build Coastguard Workertestcmd "no args" "" \ 21*cf5a6c84SAndroid Build Coastguard Worker "00000000: 776f 726c 64 world\n" "" "world" 22*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c 8 -g 4 file1" "-c 8 -g 4 file1" \ 23*cf5a6c84SAndroid Build Coastguard Worker "00000000: 74686973 20697320 this is \n00000008: 736f6d65 20746578 some tex\n00000010: 740a t.\n" "" "" 24*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c 8 -g 3 file1" "-c 8 -g 3 file1" \ 25*cf5a6c84SAndroid Build Coastguard Worker "00000000: 746869 732069 7320 this is \n00000008: 736f6d 652074 6578 some tex\n00000010: 740a t.\n" "" "" 26*cf5a6c84SAndroid Build Coastguard Worker 27*cf5a6c84SAndroid Build Coastguard Workertestcmd "-i" "-i - < file1" " 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x73, 0x6f, 0x6d, 0x65,\n 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a\n" "" "" 28*cf5a6c84SAndroid Build Coastguard Worker 29*cf5a6c84SAndroid Build Coastguard Workertestcmd "-o 0x8000" "-o 0x8000 file1" "00008000: 7468 6973 2069 7320 736f 6d65 2074 6578 this is some tex\n00008010: 740a t.\n" "" "" 30*cf5a6c84SAndroid Build Coastguard Worker 31*cf5a6c84SAndroid Build Coastguard Workertestcmd "-p" "-p file1" "7468697320697320736f6d6520746578740a\n" "" "" 32*cf5a6c84SAndroid Build Coastguard Worker 33*cf5a6c84SAndroid Build Coastguard Worker# TODO: remove toyonly when distro catches up 34*cf5a6c84SAndroid Build Coastguard Workertoyonly testcmd "-pc0" "-pc0" \ 35*cf5a6c84SAndroid Build Coastguard Worker "73686f77203830206865782064696769747320776974686f757420776f72647772617070696e670a\n" \ 36*cf5a6c84SAndroid Build Coastguard Worker "" "show 80 hex digits without wordwrapping\n" 37*cf5a6c84SAndroid Build Coastguard Workertoyonly testcmd "-pc0 long" "-pc0 | wc -c" "97787\n" "" "$(seq 1 10000)" 38*cf5a6c84SAndroid Build Coastguard Worker 39*cf5a6c84SAndroid Build Coastguard Workertestcmd "-s" "-s 13 file1" \ 40*cf5a6c84SAndroid Build Coastguard Worker "0000000d: 7465 7874 0a text.\n" "" "" 41*cf5a6c84SAndroid Build Coastguard Worker 42*cf5a6c84SAndroid Build Coastguard Workertestcmd "-r" "-r" "this is some text\n" "" \ 43*cf5a6c84SAndroid Build Coastguard Worker ' 00000000: 7468 6973 2069 7320 736f 6d65 2074 6578 this is some tex\n00000010: 740a t.\n' 44*cf5a6c84SAndroid Build Coastguard Worker 45*cf5a6c84SAndroid Build Coastguard Worker# This isn't documented, but "real" xxd supports this input format too. 46*cf5a6c84SAndroid Build Coastguard Workertestcmd "-r no colon" "-r" "this is some text\n" "" \ 47*cf5a6c84SAndroid Build Coastguard Worker ' 00000000 7468 6973 2069 7320 736f 6d65 2074 6578 this is some tex\n00000010: 740a t.\n' 48*cf5a6c84SAndroid Build Coastguard Worker 49*cf5a6c84SAndroid Build Coastguard Workertoyonly testcmd "-r -i" "-ri" "this is some text\n" "" \ 50*cf5a6c84SAndroid Build Coastguard Worker '0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x73, 0x6f, 0x6d, 0x65,\n 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a\n' 51*cf5a6c84SAndroid Build Coastguard Worker 52*cf5a6c84SAndroid Build Coastguard Worker# This isn't documented, but "real" xxd supports this input format too. 53*cf5a6c84SAndroid Build Coastguard Workertoyonly testcmd "-r -i no commas" "-ri" "this is some text\n" "" \ 54*cf5a6c84SAndroid Build Coastguard Worker '0x74 0x68 0x69 0x73 0x20 0x69 0x73 0x20 0x73 0x6f 0x6d 0x65\n 0x20 0x74 0x65 0x78 0x74 0x0a\n' 55*cf5a6c84SAndroid Build Coastguard Worker 56*cf5a6c84SAndroid Build Coastguard Workertestcmd "-r garbage" '-r -' 'hello' '' '0000: 68 65 6c6c 6fxxxx\n' 57*cf5a6c84SAndroid Build Coastguard Worker 58*cf5a6c84SAndroid Build Coastguard Worker# -r will only read -c bytes (default 16) before skipping to the next line, 59*cf5a6c84SAndroid Build Coastguard Worker# ignoring the rest. 60*cf5a6c84SAndroid Build Coastguard Workertestcmd "-r long" '-r -' "@@@@@@@@@@@@@@@@" "" \ 61*cf5a6c84SAndroid Build Coastguard Worker '0000: 40404040404040404040404040404040404040404040404040404040404040404040404040404040\r' 62*cf5a6c84SAndroid Build Coastguard Worker 63*cf5a6c84SAndroid Build Coastguard Worker# -r -p ignores the usual -p 30-byte/line limit (or any limit set by -c) and 64*cf5a6c84SAndroid Build Coastguard Worker# will take as many bytes as you give it. 65*cf5a6c84SAndroid Build Coastguard Workertestcmd "-r -p long" '-r -p -' "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" "" \ 66*cf5a6c84SAndroid Build Coastguard Worker '40404040404040404040404040404040404040404040404040404040404040404040404040404040\n' 67*cf5a6c84SAndroid Build Coastguard Worker 68*cf5a6c84SAndroid Build Coastguard Workertestcmd "-r unnecessary output seeks" '-r | xxd' \ 69*cf5a6c84SAndroid Build Coastguard Worker "00000000: 0100 0000 0000 0000 0000 0000 0000 00ff ................\n" '' \ 70*cf5a6c84SAndroid Build Coastguard Worker '00000000: 0100 0000 0000 0000 0000 0000 0000 00ff deadbeef........\n' 71*cf5a6c84SAndroid Build Coastguard Worker 72*cf5a6c84SAndroid Build Coastguard Worker# Little-endian, testing both the "EOF in first word on line" and "EOF in word 73*cf5a6c84SAndroid Build Coastguard Worker# mid-line" cases. 74*cf5a6c84SAndroid Build Coastguard Workertestcmd "LE partial" "-e -" \ 75*cf5a6c84SAndroid Build Coastguard Worker "00000000: 6568 he\n" "" "he" 76*cf5a6c84SAndroid Build Coastguard Workertestcmd "LE partial mid-line" "-e -" \ 77*cf5a6c84SAndroid Build Coastguard Worker "00000000: 6c6c6568 6f hello\n" "" "hello" 78*cf5a6c84SAndroid Build Coastguard Worker 79*cf5a6c84SAndroid Build Coastguard Workerrm file1 file2 80