Skip to content

Commit

Permalink
Merge pull request #264 from pspacek/fix-large-binary-tests
Browse files Browse the repository at this point in the history
Use valid DNS queries as largest UDP and TCP test payloads
  • Loading branch information
jelu authored May 27, 2024
2 parents 591f37e + 1ef5b41 commit 406c187
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ CLEANFILES = test*.log test*.trs \

TESTS = test1.sh test2.sh test3.sh test4.sh test5.sh test6.sh test7.sh

largesttcp.blob:
$(srcdir)/gen-largest-blob.py 20065 65503 $(srcdir)/largesttcp.blob

largestudp.blob:
$(srcdir)/gen-largest-blob.py 20065 65475 $(srcdir)/largestudp.blob

EXTRA_DIST = $(TESTS) \
datafile datafile2 updatefile datafile3 datafile4 datafile5 datafile6 \
empty.blob emptypayload.blob largesttcp.blob largestudp.blob \
Expand Down
12 changes: 12 additions & 0 deletions src/test/gen-largest-blob.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3

import sys
import dns.message
import struct

m = dns.message.make_query('.', 'TYPE666')
m.id = int(sys.argv[1])
m.use_edns(0, options=[dns.edns.GenericOption(dns.edns.OptionType.PADDING, '\x00' * int(sys.argv[2]))])
binary = m.to_wire(max_size=65535)
binary = struct.pack('>H', len(binary)) + binary
open(sys.argv[3], 'wb').write(binary)
Binary file modified src/test/largesttcp.blob
Binary file not shown.
Binary file modified src/test/largestudp.blob
Binary file not shown.

0 comments on commit 406c187

Please sign in to comment.