--- /dev/null
+(* 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
--- /dev/null
+00000000 00 |. |
--- /dev/null
+00000000 cc 40 |.@ |
--- /dev/null
+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[....<K..S...|
+00000040 de 1b 84 0d aa 10 34 97 b6 81 07 fb c9 8f 9d 6c |......4........l|
+00000050 b9 ee 51 91 00 08 94 f7 75 49 4a 02 f1 73 ed 2e |..Q.....uIJ..s..|
+00000060 49 e5 e1 db 17 55 cd 97 2f 8c eb fb d6 a7 3c ea |I....U../.....<.|
+00000070 41 be e6 56 fc b9 29 e8 10 47 b6 32 f6 |A..V..)..G.2. |
--- /dev/null
+00000000 4f a0 |O. |
--- /dev/null
+00000000 77 a0 |w. |
--- /dev/null
+00000000 c3 0f d4 81 b8 02 c0 88 93 89 bf ff 92 67 cc a2 |.............g..|
+00000010
--- /dev/null
+00000000 d1 3c 3b 9b 47 94 89 52 90 b0 f1 a9 f7 c7 d8 6f |.<;.G..R.......o|
+00000010
--- /dev/null
+00000000 64 f0 |d. |
--- /dev/null
+00000000 27 5c |'\ |
--- /dev/null
+00000000 19 54 |.T |
--- /dev/null
+00000000 ba 09 |.. |
--- /dev/null
+00000000 80 |. |
--- /dev/null
+00000000 eb d6 25 f8 21 d6 a5 3d cb 06 3d fe f2 3a b0 a5 |..%.!..=..=..:..|
+00000010 de 9a 4b cc fb 3a f1 b1 4a |..K..:..J |
--- /dev/null
+00000000 e0 |. |
--- /dev/null
+00000000 4c c2 1f 46 |L..F |
--- /dev/null
+00000000 0d b7 5b ed |..[. |
--- /dev/null
+00000000 a7 64 a0 cd 00 |.d... |
--- /dev/null
+00000000 8f 1f bb a8 80 |..... |
--- /dev/null
+00000000 00 |. |
--- /dev/null
+00000000 4c ea de d4 3a e4 |L...:. |
--- /dev/null
+00000000 3f de 0b 20 f3 9f |?.. .. |
--- /dev/null
+00000000 68 7d c3 25 2d b3 80 |h}.%-.. |
--- /dev/null
+00000000 d0 |. |
--- /dev/null
+00000000 34 3e ad b3 6c 82 c0 |4>..l.. |
--- /dev/null
+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... |
--- /dev/null
+00000000 e0 |. |
--- /dev/null
+00000000 fd 99 44 37 d6 b2 9e 14 |..D7.... |
--- /dev/null
+00000000 02 6b 77 6f f6 f0 4d c8 |.kwo..M. |
--- /dev/null
+00000000 be 50 66 8c a3 d7 8e e3 80 |.Pf...... |
--- /dev/null
+00000000 65 fd ed ab 1e f9 bb b6 40 |e.......@ |
--- /dev/null
+00000000 a3 28 db b6 d5 7f fe 43 40 |.(.....C@ |
--- /dev/null
+00000000 6c |l |
--- /dev/null
+00000000 59 |Y |
--- /dev/null
+00000000 33 00 |3. |
--- /dev/null
+[
\ No newline at end of file
--- /dev/null
+ÌD
\ No newline at end of file
--- /dev/null
+O©
\ No newline at end of file
--- /dev/null
+w
\ No newline at end of file
--- /dev/null
+Ã\ fÔ\81¸\ 2À\88\93\89¿ÿ\92gÌ¢
\ No newline at end of file
--- /dev/null
+Ñ<;\9bG\94\89R\90°ñ©÷ÇØo
\ No newline at end of file
--- /dev/null
+dõ
\ No newline at end of file
--- /dev/null
+'_
\ No newline at end of file
--- /dev/null
+\19U
\ No newline at end of file
--- /dev/null
+º
\ No newline at end of file
--- /dev/null
+°
\ No newline at end of file
--- /dev/null
+ëÖ%ø!Ö¥=Ë\ 6=þò:°¥Þ\9aKÌû:ñ±J
\ No newline at end of file
--- /dev/null
+ä
\ No newline at end of file
--- /dev/null
+LÂ\1fG
\ No newline at end of file
--- /dev/null
+\r·[í
\ No newline at end of file
--- /dev/null
+§d Í\7f
\ No newline at end of file
--- /dev/null
+\8f\1fȬ
\ No newline at end of file
--- /dev/null
+\ f
\ No newline at end of file
--- /dev/null
+LêÞÔ:ä
\ No newline at end of file
--- /dev/null
+?Þ\v ó\9f
\ No newline at end of file
--- /dev/null
+h}Ã%-³«
\ No newline at end of file
--- /dev/null
+×
\ No newline at end of file
--- /dev/null
+4>³l\82É
\ No newline at end of file
--- /dev/null
+ã
\ No newline at end of file
--- /dev/null
+ý\99D7Ö²\9e\15
\ No newline at end of file
--- /dev/null
+\ 2kwoöðMÈ
\ No newline at end of file
--- /dev/null
+¾Pf\8c£×\8eã®
\ No newline at end of file
--- /dev/null
+eýí«\1eù»¶q
\ No newline at end of file
--- /dev/null
+£(Û¶Õ\7fþC\
\ No newline at end of file
--- /dev/null
+m
\ No newline at end of file
--- /dev/null
+Y
\ No newline at end of file
--- /dev/null
+3[
\ No newline at end of file