aboutsummaryrefslogtreecommitdiff
path: root/tests/curl_test_data.py
diff options
context:
space:
mode:
authorMax Dymond <cmeister2@gmail.com>2017-08-27 15:57:05 +0100
committerDaniel Stenberg <daniel@haxx.se>2017-09-01 11:22:51 +0200
commitefeb4a317616b0437a26277945bd300eaffe96d7 (patch)
tree86f46482f6f9a4eb98fcad25eeb06ea0027b01dc /tests/curl_test_data.py
parent222e65fd783bec974b99345e0d618d4e627304de (diff)
ossfuzz: moving towards the ideal integration
- Start with the basic code from the ossfuzz project. - Rewrite fuzz corpora to be binary files full of Type-Length-Value data, and write a glue layer in the fuzzing function to convert corpora into CURL options. - Have supporting functions to generate corpora from existing tests - Integrate with Makefile.am
Diffstat (limited to 'tests/curl_test_data.py')
-rwxr-xr-xtests/curl_test_data.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/curl_test_data.py b/tests/curl_test_data.py
index bfe1287d8..21747407d 100755
--- a/tests/curl_test_data.py
+++ b/tests/curl_test_data.py
@@ -24,12 +24,15 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
-import xml.etree.ElementTree as ET
+import re
import logging
log = logging.getLogger(__name__)
+REPLY_DATA = re.compile("<reply>\s*<data>(.*?)</data>", re.MULTILINE | re.DOTALL)
+
+
class TestData(object):
def __init__(self, data_folder):
self.data_folder = data_folder
@@ -39,15 +42,17 @@ class TestData(object):
filename = os.path.join(self.data_folder,
"test{0}".format(test_number))
- # The user should handle the exception from failing to find the file.
- tree = ET.parse(filename)
+ log.debug("Parsing file %s", filename)
+
+ with open(filename, "rb") as f:
+ contents = f.read().decode("utf-8")
- # We need the <reply><data> text.
- reply = tree.find("reply")
- data = reply.find("data")
+ m = REPLY_DATA.search(contents)
+ if not m:
+ raise Exception("Couldn't find a <reply><data> section")
- # Return the text contents of the data
- return data.text
+ # Left-strip the data so we don't get a newline before our data.
+ return m.group(1).lstrip()
if __name__ == '__main__':