Skip to content

Commit

Permalink
Source files for brogen to generate good and bad streams.
Browse files Browse the repository at this point in the history
gen is a shell script that runs all of the source files through
brogen and deb.
  • Loading branch information
madler committed Dec 31, 2015
1 parent affce9a commit 1ea13ee
Show file tree
Hide file tree
Showing 28 changed files with 239 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bad/bitseof.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# premature end of input when getting bits in metadata header
w last m 6
12 changes: 12 additions & 0 deletions bad/codelenover.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# oversubscribed complex code length code
w last m 6
types 1
types 1
types 1
b 2 0 b 4 2
b 2 0
b 1 0 b 1 0
b 2 0
len 2
len 1
len 1
27 changes: 27 additions & 0 deletions bad/codelenunder.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# incomplete complex code length code
w last m 6
types 1
types 1
types 1
b 2 0 b 4 2
b 2 0
b 1 0 b 1 0
b 2 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
len 0
2 changes: 2 additions & 0 deletions bad/end.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# leftover bits in last byte at end of stream not all zero
w e -1 bound 0x7f
4 changes: 4 additions & 0 deletions bad/highsymbol.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# provided symbol exceeds alphabet size in a simple code
w last m 6
types 3
s 0 1 3 6
11 changes: 11 additions & 0 deletions bad/incomplete.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# incomplete complex code
w last m 6
types 3 # five symbols
b 2 2 # complex code, skip 2
len 1 # len 3 (0)
len 1 # len 4 (1)
b 1 0 # all five symbols are three bits
b 1 0
b 1 0
b 1 0
b 1 0
2 changes: 2 additions & 0 deletions bad/metadataeof.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# premature end of input in metadata
w e 1
2 changes: 2 additions & 0 deletions bad/metadatafill.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# bits skipped to get to byte boundary for metadata not all zeros
w e bound 0x7f
16 changes: 16 additions & 0 deletions bad/mlenovercopy.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Request a longer copy than the remaining metablock size
w last m 2 # metablock size 2
types 1 # NBLTYPESL
types 1 # NBLTYPESI
types 1 # NBLTYPESD
b 2 0 b 4 0 # NPOSTFIX = 0, NDIRECT = 0
b 2 0 # context mode for the single literal block type
types 1 # NTREESL
types 1 # NTREESD
s 0 1 8 0 # literal code with one symbol (0)
s 1 1 10 136 # IaC code with one symbol (136)
s 2 1 6 16 # one distance code (16)
p 1 136 # insert 1 literal, copy 2 bytes
p 0 0 # literal 0
p 2 16 # distance 1 + 1 extra bit
b 1 0 # distance 1
16 changes: 16 additions & 0 deletions bad/mlenoverdict.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Request a static dictionary word longer than the metablock size
w 10 last m 6 # window size = 1024 - 16 = 1008
types 1 # NBLTYPESL
types 1 # NBLTYPESI
types 1 # NBLTYPESD
b 2 0 b 4 0 # NPOSTFIX = 0, NDIRECT = 0
b 2 0 # context mode for the single literal block type
types 1 # NTREESL
types 1 # NTREESD
s 0 1 8 0 # literal code with one symbol (0), not used
s 1 2 10 128 196 # IaC code with two symbols (128 and 196)
s 2 1 6 35 # one distance code (35 -> 3069 + 0..1023)
p 1 196 # insert 0 literals, copy 22 + 0..7 bytes
b 3 2 # copy length 24
p 2 35 # distance code 35 (nothing actually emitted)
b 10 803 # at max 3871 -> index 31, transform 120, length 24+3 = 27
13 changes: 13 additions & 0 deletions bad/mlenoverinsert.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Request more literals than the remaining metablock size
w last m 1 # metablock size 1
types 1 # NBLTYPESL
types 1 # NBLTYPESI
types 1 # NBLTYPESD
b 2 0 b 4 0 # NPOSTFIX = 0, NDIRECT = 0
b 2 0 # context mode for the single literal block type
types 1 # NTREESL
types 1 # NTREESD
s 0 1 8 0 # literal code with one symbol (0)
s 1 1 10 144 # IaC code with one symbol (144)
s 2 1 6 35 # one distance code (35)
p 1 144 # insert 2 literals, copy 2 bytes
16 changes: 16 additions & 0 deletions bad/notransform.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Request a static dictionary word with a transform > 120
w 10 last m 6 # window size = 1024 - 16 = 1008
types 1 # NBLTYPESL
types 1 # NBLTYPESI
types 1 # NBLTYPESD
b 2 0 b 4 0 # NPOSTFIX = 0, NDIRECT = 0
b 2 0 # context mode for the single literal block type
types 1 # NTREESL
types 1 # NTREESD
s 0 1 8 0 # literal code with one symbol (0), not used
s 1 2 10 128 196 # IaC code with two symbols (128 and 196)
s 2 1 6 35 # one distance code (35 -> 3069 + 0..1023)
p 1 196 # insert 0 literals, copy 22 + 0..7 bytes
b 3 2 # copy length 24
p 2 35 # distance code 35 (nothing actually emitted)
b 10 804 # gives distance 3873 == (121 << 5) + 1
9 changes: 9 additions & 0 deletions bad/oversubscribed.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# oversubscribed complex code
w last m 6
types 3 # five symbols
b 2 0 # complex code, skip 0
len 1 # len 1 (0)
len 1 # len 2 (1)
b 1 1 # 2 bits
b 1 0 # 1 bit
b 1 0 # 1 bit
11 changes: 11 additions & 0 deletions bad/prefixeof.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# premature end of input when decoding a prefix code
w last m 6
types 1
types 1
types 1
b 2 0 b 4 2
b 2 0
b 1 0 b 1 0
s 0 3 8 "abn"
s 1 1 10 153
s 2 1 7 17
2 changes: 2 additions & 0 deletions bad/reserved.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# reserved bit in metadata block set
w b 4 0xe
13 changes: 13 additions & 0 deletions bad/runlength.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# context map run length too long
w last m 6
types 1 # NBLTYPESL
types 1 # NBLTYPESI
types 1 # NBLTYPESD
b 2 0 b 4 2 # NPOSTFIX = 0, NDIRECT = 2
b 2 0 # context mode for the single literal block type
types 1 # NTREESL (no context map)
types 2 # NTREESD (not 1 -- followed by context map)
b 5 1 # RLEMAX = 1
s 0 3 2 0 1 2 # codes for 0, repeat (1), 1 (2)
p 0 1 b 1 1 # 3 zeros (ok so far -- there are four entries)
p 0 1 b 1 1 # 3 zeros (whoops, too many)
16 changes: 16 additions & 0 deletions bad/staticlong.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Request a static dictionary word with a copy length > 24
w 10 last m 6 # window size = 1024 - 16 = 1008
types 1 # NBLTYPESL
types 1 # NBLTYPESI
types 1 # NBLTYPESD
b 2 0 b 4 0 # NPOSTFIX = 0, NDIRECT = 0
b 2 0 # context mode for the single literal block type
types 1 # NTREESL
types 1 # NTREESD
s 0 1 8 0 # literal code with one symbol (0), not used
s 1 2 10 128 196 # IaC code with two symbols (128 and 196)
s 2 1 6 31 # one distance code (31 -> 765 + 0..255)
p 1 196 # insert 0 literals, copy 22 + 0..7 bytes
b 3 7 # make that 29 bytes, 29 is greater than 24
p 2 31 # distance code 31 (nothing actually emitted)
b 8 244 # gives distance 1009, past end of 1008 window
15 changes: 15 additions & 0 deletions bad/staticshort.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Request a static dictionary word with a copy length < 4
w 10 last m 6 # window size = 1024 - 16 = 1008
types 1 # NBLTYPESL
types 1 # NBLTYPESI
types 1 # NBLTYPESD
b 2 0 b 4 0 # NPOSTFIX = 0, NDIRECT = 0
b 2 0 # context mode for the single literal block type
types 1 # NTREESL
types 1 # NTREESD
s 0 1 8 0 # literal code with one symbol (0), not used
s 1 2 10 128 196 # IaC code with two symbols (128 and 196)
s 2 1 6 31 # one distance code (31 -> 765 + 0..255)
p 1 128 # insert 0 literals, copy 2 bytes (2 is less than 4)
p 2 31 # distance code 31 (nothing actually emitted)
b 8 244 # gives distance 1009, past end of 1008 window
11 changes: 11 additions & 0 deletions bad/toomany16.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# too many repeats of last non-zero length (instruction 16)
w last m 6
types 3
b 2 3 # complex code, skip 3
len 0
len 0
len 0
len 1 # instruction 16 (0)
len 0
len 1 # instruction 17 (1)
b 1 0 b 2 3
11 changes: 11 additions & 0 deletions bad/toomany17.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# too many repeats of zeros (instruction 17)
w last m 6
types 3
b 2 3 # complex code, skip 3
len 0
len 0
len 0
len 1 # instruction 16 (0)
len 0
len 1 # instruction 17 (1)
b 1 1 b 3 7
2 changes: 2 additions & 0 deletions bad/unceof.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# stream ends prematurely in uncompressed data
w u
2 changes: 2 additions & 0 deletions bad/uncfill.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# bits skipped to get to uncompressed data byte boundary are not all zeros
w u bound 0x7f
2 changes: 2 additions & 0 deletions bad/wbits.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# invalid number of window bits (reserved value for later expansion)
b 7 0x11
2 changes: 2 additions & 0 deletions bad/xsmetalen.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# excess metadata length bytes (last byte all zeros)
w b 22 0x26
2 changes: 2 additions & 0 deletions bad/xsmlen.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# excess meta-block nybbles for the length (last nybble all zeros)
w b 23 0x2
13 changes: 13 additions & 0 deletions gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
for x in bad/*
do
printf "%s - " $x
./brogen < $x | ./deb -v 2>&1 | grep error
done
echo
for x in good/*
do
echo $x
./brogen < $x | ./deb -v 2>&1 | grep error
done
rm -f deb.out
2 changes: 2 additions & 0 deletions good/lastempty.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# shortest valid complete stream with a last empty block (one byte, 0x06)
w e -1
3 changes: 3 additions & 0 deletions good/lastzerometa.gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# a last empty block with length 0 metadata allowed
# (could just have no metadata)
w last e 0

0 comments on commit 1ea13ee

Please sign in to comment.