From 86502a23458f9e93c8241735649ac2edd7fbc68a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 27 Aug 2008 12:58:25 +0000 Subject: [PATCH] Test the hexdump function. --- tests/80_hexdump.ml | 58 +++++++++++++++++++++++++++++++++++++ tests/80_testdata/hex1.expected | 1 + tests/80_testdata/hex10.expected | 1 + tests/80_testdata/hex1000.expected | 8 +++++ tests/80_testdata/hex11.expected | 1 + tests/80_testdata/hex12.expected | 1 + tests/80_testdata/hex127.expected | 2 ++ tests/80_testdata/hex128.expected | 2 ++ tests/80_testdata/hex13.expected | 1 + tests/80_testdata/hex14.expected | 1 + tests/80_testdata/hex15.expected | 1 + tests/80_testdata/hex16.expected | 1 + tests/80_testdata/hex2.expected | 1 + tests/80_testdata/hex200.expected | 2 ++ tests/80_testdata/hex3.expected | 1 + tests/80_testdata/hex31.expected | 1 + tests/80_testdata/hex32.expected | 1 + tests/80_testdata/hex33.expected | 1 + tests/80_testdata/hex34.expected | 1 + tests/80_testdata/hex4.expected | 1 + tests/80_testdata/hex47.expected | 1 + tests/80_testdata/hex48.expected | 1 + tests/80_testdata/hex49.expected | 1 + tests/80_testdata/hex5.expected | 1 + tests/80_testdata/hex50.expected | 1 + tests/80_testdata/hex500.expected | 4 +++ tests/80_testdata/hex6.expected | 1 + tests/80_testdata/hex63.expected | 1 + tests/80_testdata/hex64.expected | 1 + tests/80_testdata/hex65.expected | 1 + tests/80_testdata/hex66.expected | 1 + tests/80_testdata/hex67.expected | 1 + tests/80_testdata/hex7.expected | 1 + tests/80_testdata/hex8.expected | 1 + tests/80_testdata/hex9.expected | 1 + tests/80_testdata/rnd1 | 1 + tests/80_testdata/rnd10 | 1 + tests/80_testdata/rnd1000 | Bin 0 -> 125 bytes tests/80_testdata/rnd11 | 1 + tests/80_testdata/rnd12 | 1 + tests/80_testdata/rnd127 | 1 + tests/80_testdata/rnd128 | 1 + tests/80_testdata/rnd13 | 1 + tests/80_testdata/rnd14 | 1 + tests/80_testdata/rnd15 | 1 + tests/80_testdata/rnd16 | 1 + tests/80_testdata/rnd2 | 1 + tests/80_testdata/rnd200 | 1 + tests/80_testdata/rnd3 | 1 + tests/80_testdata/rnd31 | 1 + tests/80_testdata/rnd32 | 1 + tests/80_testdata/rnd33 | 1 + tests/80_testdata/rnd34 | 1 + tests/80_testdata/rnd4 | 1 + tests/80_testdata/rnd47 | 1 + tests/80_testdata/rnd48 | 1 + tests/80_testdata/rnd49 | 1 + tests/80_testdata/rnd5 | 1 + tests/80_testdata/rnd50 | 1 + tests/80_testdata/rnd500 | Bin 0 -> 63 bytes tests/80_testdata/rnd6 | 1 + tests/80_testdata/rnd63 | 1 + tests/80_testdata/rnd64 | 1 + tests/80_testdata/rnd65 | 1 + tests/80_testdata/rnd66 | 1 + tests/80_testdata/rnd67 | 1 + tests/80_testdata/rnd7 | 1 + tests/80_testdata/rnd8 | 1 + tests/80_testdata/rnd9 | 1 + 69 files changed, 137 insertions(+) create mode 100644 tests/80_hexdump.ml create mode 100644 tests/80_testdata/hex1.expected create mode 100644 tests/80_testdata/hex10.expected create mode 100644 tests/80_testdata/hex1000.expected create mode 100644 tests/80_testdata/hex11.expected create mode 100644 tests/80_testdata/hex12.expected create mode 100644 tests/80_testdata/hex127.expected create mode 100644 tests/80_testdata/hex128.expected create mode 100644 tests/80_testdata/hex13.expected create mode 100644 tests/80_testdata/hex14.expected create mode 100644 tests/80_testdata/hex15.expected create mode 100644 tests/80_testdata/hex16.expected create mode 100644 tests/80_testdata/hex2.expected create mode 100644 tests/80_testdata/hex200.expected create mode 100644 tests/80_testdata/hex3.expected create mode 100644 tests/80_testdata/hex31.expected create mode 100644 tests/80_testdata/hex32.expected create mode 100644 tests/80_testdata/hex33.expected create mode 100644 tests/80_testdata/hex34.expected create mode 100644 tests/80_testdata/hex4.expected create mode 100644 tests/80_testdata/hex47.expected create mode 100644 tests/80_testdata/hex48.expected create mode 100644 tests/80_testdata/hex49.expected create mode 100644 tests/80_testdata/hex5.expected create mode 100644 tests/80_testdata/hex50.expected create mode 100644 tests/80_testdata/hex500.expected create mode 100644 tests/80_testdata/hex6.expected create mode 100644 tests/80_testdata/hex63.expected create mode 100644 tests/80_testdata/hex64.expected create mode 100644 tests/80_testdata/hex65.expected create mode 100644 tests/80_testdata/hex66.expected create mode 100644 tests/80_testdata/hex67.expected create mode 100644 tests/80_testdata/hex7.expected create mode 100644 tests/80_testdata/hex8.expected create mode 100644 tests/80_testdata/hex9.expected create mode 100644 tests/80_testdata/rnd1 create mode 100644 tests/80_testdata/rnd10 create mode 100644 tests/80_testdata/rnd1000 create mode 100644 tests/80_testdata/rnd11 create mode 100644 tests/80_testdata/rnd12 create mode 100644 tests/80_testdata/rnd127 create mode 100644 tests/80_testdata/rnd128 create mode 100644 tests/80_testdata/rnd13 create mode 100644 tests/80_testdata/rnd14 create mode 100644 tests/80_testdata/rnd15 create mode 100644 tests/80_testdata/rnd16 create mode 100644 tests/80_testdata/rnd2 create mode 100644 tests/80_testdata/rnd200 create mode 100644 tests/80_testdata/rnd3 create mode 100644 tests/80_testdata/rnd31 create mode 100644 tests/80_testdata/rnd32 create mode 100644 tests/80_testdata/rnd33 create mode 100644 tests/80_testdata/rnd34 create mode 100644 tests/80_testdata/rnd4 create mode 100644 tests/80_testdata/rnd47 create mode 100644 tests/80_testdata/rnd48 create mode 100644 tests/80_testdata/rnd49 create mode 100644 tests/80_testdata/rnd5 create mode 100644 tests/80_testdata/rnd50 create mode 100644 tests/80_testdata/rnd500 create mode 100644 tests/80_testdata/rnd6 create mode 100644 tests/80_testdata/rnd63 create mode 100644 tests/80_testdata/rnd64 create mode 100644 tests/80_testdata/rnd65 create mode 100644 tests/80_testdata/rnd66 create mode 100644 tests/80_testdata/rnd67 create mode 100644 tests/80_testdata/rnd7 create mode 100644 tests/80_testdata/rnd8 create mode 100644 tests/80_testdata/rnd9 diff --git a/tests/80_hexdump.ml b/tests/80_hexdump.ml new file mode 100644 index 0000000..0c0ec8d --- /dev/null +++ b/tests/80_hexdump.ml @@ -0,0 +1,58 @@ +(* Test hexdump. + * $Id$ + *) + +open Printf + +open Bitstring + +let (//) = Filename.concat + +let testdata = "tests" // "80_testdata" ;; +Sys.chdir testdata ;; + +let diff = Bitstring_config.diff + +let () = + let files = Sys.readdir "." in + let files = Array.to_list files in + let files = List.filter ( + fun filename -> + String.length filename > 3 && + filename.[0] = 'r' && filename.[1] = 'n' && filename.[2] = 'd' + ) files in + let files = List.map ( + fun filename -> + let n = String.sub filename 3 (String.length filename - 3) in + let n = int_of_string n in + let bits = bitstring_of_file filename in + (* 'bitstring_of_file' loads whole bytes. Truncate it to + * the real bit-length. + *) + let bits = takebits n bits in + + filename, n, bits + ) files in + + (* Hexdump the bits, then compare using external 'diff' program. *) + List.iter ( + fun (filename, n, bits) -> + let output_filename = sprintf "hex%d.actual" n in + let chan = open_out output_filename in + hexdump_bitstring chan bits; + close_out chan + ) files; + + List.iter ( + fun (filename, n, bits) -> + let actual_filename = sprintf "hex%d.actual" n in + let expected_filename = sprintf "hex%d.expected" n in + let cmd = + sprintf "%s -u %s %s" + (Filename.quote diff) + (Filename.quote expected_filename) + (Filename.quote actual_filename) in + if Sys.command cmd <> 0 then ( + exit 1 + ) + ) files diff --git a/tests/80_testdata/hex1.expected b/tests/80_testdata/hex1.expected new file mode 100644 index 0000000..aab2998 --- /dev/null +++ b/tests/80_testdata/hex1.expected @@ -0,0 +1 @@ +00000000 00 |. | diff --git a/tests/80_testdata/hex10.expected b/tests/80_testdata/hex10.expected new file mode 100644 index 0000000..35d015b --- /dev/null +++ b/tests/80_testdata/hex10.expected @@ -0,0 +1 @@ +00000000 cc 40 |.@ | diff --git a/tests/80_testdata/hex1000.expected b/tests/80_testdata/hex1000.expected new file mode 100644 index 0000000..9cb787e --- /dev/null +++ b/tests/80_testdata/hex1000.expected @@ -0,0 +1,8 @@ +00000000 8e 73 d4 ea e8 ce 66 ef ac 06 e2 fe 01 95 40 65 |.s....f.......@e| +00000010 8b 6a b1 1b 1f 5a 0c 86 09 af d9 11 79 1f 9d ee |.j...Z......y...| +00000020 94 86 2d d2 9e a9 02 46 f1 0e d4 99 ac 5b 28 60 |..-....F.....[(`| +00000030 70 21 6f 5b 9b 99 85 bb 3c 4b fa 83 53 f6 c6 fb |p!o[......l.. | diff --git a/tests/80_testdata/hex500.expected b/tests/80_testdata/hex500.expected new file mode 100644 index 0000000..1baa114 --- /dev/null +++ b/tests/80_testdata/hex500.expected @@ -0,0 +1,4 @@ +00000000 c7 ad 45 e8 53 ef 72 1b c0 46 17 14 40 a9 1a d0 |..E.S.r..F..@...| +00000010 3e d3 36 58 08 d7 89 68 b0 4b ac b4 54 04 00 5d |>.6X...h.K..T..]| +00000020 45 89 97 21 23 be a5 8d 36 0d 11 ea 1e 5d bb 90 |E..!#...6....]..| +00000030 71 f1 cd e2 3c fe 27 a5 b5 92 7c 58 a1 a2 80 |q...<.'...|X... | diff --git a/tests/80_testdata/hex6.expected b/tests/80_testdata/hex6.expected new file mode 100644 index 0000000..47c5fe8 --- /dev/null +++ b/tests/80_testdata/hex6.expected @@ -0,0 +1 @@ +00000000 e0 |. | diff --git a/tests/80_testdata/hex63.expected b/tests/80_testdata/hex63.expected new file mode 100644 index 0000000..a14f5a0 --- /dev/null +++ b/tests/80_testdata/hex63.expected @@ -0,0 +1 @@ +00000000 fd 99 44 37 d6 b2 9e 14 |..D7.... | diff --git a/tests/80_testdata/hex64.expected b/tests/80_testdata/hex64.expected new file mode 100644 index 0000000..230322e --- /dev/null +++ b/tests/80_testdata/hex64.expected @@ -0,0 +1 @@ +00000000 02 6b 77 6f f6 f0 4d c8 |.kwo..M. | diff --git a/tests/80_testdata/hex65.expected b/tests/80_testdata/hex65.expected new file mode 100644 index 0000000..7c4fe88 --- /dev/null +++ b/tests/80_testdata/hex65.expected @@ -0,0 +1 @@ +00000000 be 50 66 8c a3 d7 8e e3 80 |.Pf...... | diff --git a/tests/80_testdata/hex66.expected b/tests/80_testdata/hex66.expected new file mode 100644 index 0000000..884f006 --- /dev/null +++ b/tests/80_testdata/hex66.expected @@ -0,0 +1 @@ +00000000 65 fd ed ab 1e f9 bb b6 40 |e.......@ | diff --git a/tests/80_testdata/hex67.expected b/tests/80_testdata/hex67.expected new file mode 100644 index 0000000..3fed293 --- /dev/null +++ b/tests/80_testdata/hex67.expected @@ -0,0 +1 @@ +00000000 a3 28 db b6 d5 7f fe 43 40 |.(.....C@ | diff --git a/tests/80_testdata/hex7.expected b/tests/80_testdata/hex7.expected new file mode 100644 index 0000000..d1ef7d7 --- /dev/null +++ b/tests/80_testdata/hex7.expected @@ -0,0 +1 @@ +00000000 6c |l | diff --git a/tests/80_testdata/hex8.expected b/tests/80_testdata/hex8.expected new file mode 100644 index 0000000..cdd9041 --- /dev/null +++ b/tests/80_testdata/hex8.expected @@ -0,0 +1 @@ +00000000 59 |Y | diff --git a/tests/80_testdata/hex9.expected b/tests/80_testdata/hex9.expected new file mode 100644 index 0000000..6496fba --- /dev/null +++ b/tests/80_testdata/hex9.expected @@ -0,0 +1 @@ +00000000 33 00 |3. | diff --git a/tests/80_testdata/rnd1 b/tests/80_testdata/rnd1 new file mode 100644 index 0000000..8e2f0be --- /dev/null +++ b/tests/80_testdata/rnd1 @@ -0,0 +1 @@ +[ \ No newline at end of file diff --git a/tests/80_testdata/rnd10 b/tests/80_testdata/rnd10 new file mode 100644 index 0000000..54d0b58 --- /dev/null +++ b/tests/80_testdata/rnd10 @@ -0,0 +1 @@ +ÌD \ No newline at end of file diff --git a/tests/80_testdata/rnd1000 b/tests/80_testdata/rnd1000 new file mode 100644 index 0000000000000000000000000000000000000000..781a0546a5bac9e30e8d07887548dc14779dd528 GIT binary patch literal 125 zcmV-@0D}LHbJXhS&Svkd2IBq!l|W^SYOxz1S`3B>uh|iKAD!-$hAq;bsRBmv4%C^f zTPR>~A#YoonT5MNOZtOT_Qw0(8-xw25Hy#zfd~7^kDY9}?op8d2$c7ANlF6obL}ok f<>A{GRn3<#jO+W>r#$LGzUEf^xhd!nN47HduYy4< literal 0 HcmV?d00001 diff --git a/tests/80_testdata/rnd11 b/tests/80_testdata/rnd11 new file mode 100644 index 0000000..2bce407 --- /dev/null +++ b/tests/80_testdata/rnd11 @@ -0,0 +1 @@ +O© \ No newline at end of file diff --git a/tests/80_testdata/rnd12 b/tests/80_testdata/rnd12 new file mode 100644 index 0000000..cf09d25 --- /dev/null +++ b/tests/80_testdata/rnd12 @@ -0,0 +1 @@ +w  \ No newline at end of file diff --git a/tests/80_testdata/rnd127 b/tests/80_testdata/rnd127 new file mode 100644 index 0000000..6637abe --- /dev/null +++ b/tests/80_testdata/rnd127 @@ -0,0 +1 @@ +Ãԁ¸Àˆ“‰¿ÿ’gÌ¢ \ No newline at end of file diff --git a/tests/80_testdata/rnd128 b/tests/80_testdata/rnd128 new file mode 100644 index 0000000..7b36816 --- /dev/null +++ b/tests/80_testdata/rnd128 @@ -0,0 +1 @@ +Ñ<;›G”‰R°ñ©÷ÇØo \ No newline at end of file diff --git a/tests/80_testdata/rnd13 b/tests/80_testdata/rnd13 new file mode 100644 index 0000000..18a5ed0 --- /dev/null +++ b/tests/80_testdata/rnd13 @@ -0,0 +1 @@ +dõ \ No newline at end of file diff --git a/tests/80_testdata/rnd14 b/tests/80_testdata/rnd14 new file mode 100644 index 0000000..a68aa4a --- /dev/null +++ b/tests/80_testdata/rnd14 @@ -0,0 +1 @@ +'_ \ No newline at end of file diff --git a/tests/80_testdata/rnd15 b/tests/80_testdata/rnd15 new file mode 100644 index 0000000..ffb0f65 --- /dev/null +++ b/tests/80_testdata/rnd15 @@ -0,0 +1 @@ +U \ No newline at end of file diff --git a/tests/80_testdata/rnd16 b/tests/80_testdata/rnd16 new file mode 100644 index 0000000..8720f0d --- /dev/null +++ b/tests/80_testdata/rnd16 @@ -0,0 +1 @@ +º \ No newline at end of file diff --git a/tests/80_testdata/rnd2 b/tests/80_testdata/rnd2 new file mode 100644 index 0000000..8b0e2fb --- /dev/null +++ b/tests/80_testdata/rnd2 @@ -0,0 +1 @@ +° \ No newline at end of file diff --git a/tests/80_testdata/rnd200 b/tests/80_testdata/rnd200 new file mode 100644 index 0000000..d2e6ab5 --- /dev/null +++ b/tests/80_testdata/rnd200 @@ -0,0 +1 @@ +ëÖ%ø!Ö¥=Ë=þò:°¥ÞšKÌû:ñ±J \ No newline at end of file diff --git a/tests/80_testdata/rnd3 b/tests/80_testdata/rnd3 new file mode 100644 index 0000000..1bbf238 --- /dev/null +++ b/tests/80_testdata/rnd3 @@ -0,0 +1 @@ +ä \ No newline at end of file diff --git a/tests/80_testdata/rnd31 b/tests/80_testdata/rnd31 new file mode 100644 index 0000000..7b1c3c1 --- /dev/null +++ b/tests/80_testdata/rnd31 @@ -0,0 +1 @@ +LÂG \ No newline at end of file diff --git a/tests/80_testdata/rnd32 b/tests/80_testdata/rnd32 new file mode 100644 index 0000000..d0474e6 --- /dev/null +++ b/tests/80_testdata/rnd32 @@ -0,0 +1 @@ + ·[í \ No newline at end of file diff --git a/tests/80_testdata/rnd33 b/tests/80_testdata/rnd33 new file mode 100644 index 0000000..6aeef33 --- /dev/null +++ b/tests/80_testdata/rnd33 @@ -0,0 +1 @@ +§d Í \ No newline at end of file diff --git a/tests/80_testdata/rnd34 b/tests/80_testdata/rnd34 new file mode 100644 index 0000000..667590e --- /dev/null +++ b/tests/80_testdata/rnd34 @@ -0,0 +1 @@ +»¨­ \ No newline at end of file diff --git a/tests/80_testdata/rnd4 b/tests/80_testdata/rnd4 new file mode 100644 index 0000000..c30d058 --- /dev/null +++ b/tests/80_testdata/rnd4 @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/80_testdata/rnd47 b/tests/80_testdata/rnd47 new file mode 100644 index 0000000..78758d7 --- /dev/null +++ b/tests/80_testdata/rnd47 @@ -0,0 +1 @@ +LêÞÔ:ä \ No newline at end of file diff --git a/tests/80_testdata/rnd48 b/tests/80_testdata/rnd48 new file mode 100644 index 0000000..4d3be69 --- /dev/null +++ b/tests/80_testdata/rnd48 @@ -0,0 +1 @@ +?Þ óŸ \ No newline at end of file diff --git a/tests/80_testdata/rnd49 b/tests/80_testdata/rnd49 new file mode 100644 index 0000000..83bac49 --- /dev/null +++ b/tests/80_testdata/rnd49 @@ -0,0 +1 @@ +h}Ã%-³« \ No newline at end of file diff --git a/tests/80_testdata/rnd5 b/tests/80_testdata/rnd5 new file mode 100644 index 0000000..3416407 --- /dev/null +++ b/tests/80_testdata/rnd5 @@ -0,0 +1 @@ +× \ No newline at end of file diff --git a/tests/80_testdata/rnd50 b/tests/80_testdata/rnd50 new file mode 100644 index 0000000..839affd --- /dev/null +++ b/tests/80_testdata/rnd50 @@ -0,0 +1 @@ +4>­³l‚É \ No newline at end of file diff --git a/tests/80_testdata/rnd500 b/tests/80_testdata/rnd500 new file mode 100644 index 0000000000000000000000000000000000000000..2c2bf658beb2b1371d07b261f59930304e2f91f0 GIT binary patch literal 63 zcmV-F0Kosptwrcl?{XW!Mi&%7sT$Be(>7QL*NJGbORTh11OQz{iI*WGzNL*e4H4=d VUAvHR@y+5q{wJlil6+X9qJ@sF9g6?} literal 0 HcmV?d00001 diff --git a/tests/80_testdata/rnd6 b/tests/80_testdata/rnd6 new file mode 100644 index 0000000..2105af1 --- /dev/null +++ b/tests/80_testdata/rnd6 @@ -0,0 +1 @@ +ã \ No newline at end of file diff --git a/tests/80_testdata/rnd63 b/tests/80_testdata/rnd63 new file mode 100644 index 0000000..7fe322d --- /dev/null +++ b/tests/80_testdata/rnd63 @@ -0,0 +1 @@ +ý™D7Ö²ž \ No newline at end of file diff --git a/tests/80_testdata/rnd64 b/tests/80_testdata/rnd64 new file mode 100644 index 0000000..00e38d7 --- /dev/null +++ b/tests/80_testdata/rnd64 @@ -0,0 +1 @@ +kwoöðMÈ \ No newline at end of file diff --git a/tests/80_testdata/rnd65 b/tests/80_testdata/rnd65 new file mode 100644 index 0000000..53ad3f0 --- /dev/null +++ b/tests/80_testdata/rnd65 @@ -0,0 +1 @@ +¾PfŒ£×Žã® \ No newline at end of file diff --git a/tests/80_testdata/rnd66 b/tests/80_testdata/rnd66 new file mode 100644 index 0000000..9898b0a --- /dev/null +++ b/tests/80_testdata/rnd66 @@ -0,0 +1 @@ +eýí«ù»¶q \ No newline at end of file diff --git a/tests/80_testdata/rnd67 b/tests/80_testdata/rnd67 new file mode 100644 index 0000000..f1a9266 --- /dev/null +++ b/tests/80_testdata/rnd67 @@ -0,0 +1 @@ +£(Û¶ÕþC\ \ No newline at end of file diff --git a/tests/80_testdata/rnd7 b/tests/80_testdata/rnd7 new file mode 100644 index 0000000..08b9811 --- /dev/null +++ b/tests/80_testdata/rnd7 @@ -0,0 +1 @@ +m \ No newline at end of file diff --git a/tests/80_testdata/rnd8 b/tests/80_testdata/rnd8 new file mode 100644 index 0000000..24de910 --- /dev/null +++ b/tests/80_testdata/rnd8 @@ -0,0 +1 @@ +Y \ No newline at end of file diff --git a/tests/80_testdata/rnd9 b/tests/80_testdata/rnd9 new file mode 100644 index 0000000..aa5fbfc --- /dev/null +++ b/tests/80_testdata/rnd9 @@ -0,0 +1 @@ +3[ \ No newline at end of file -- 1.8.3.1