|
@@ -1,5 +1,6 @@
|
|
|
import sys
|
|
|
from io import BytesIO
|
|
|
+from test_utils import is_expected_exception
|
|
|
|
|
|
import atheris
|
|
|
|
|
@@ -7,18 +8,11 @@ with atheris.instrument_imports():
|
|
|
from dulwich.config import ConfigFile
|
|
|
|
|
|
|
|
|
-def is_expected_error(error_list, error_msg):
|
|
|
- for error in error_list:
|
|
|
- if error in error_msg:
|
|
|
- return True
|
|
|
- return False
|
|
|
-
|
|
|
-
|
|
|
def TestOneInput(data):
|
|
|
try:
|
|
|
ConfigFile.from_file(BytesIO(data))
|
|
|
except ValueError as e:
|
|
|
- expected_errors = [
|
|
|
+ expected_exceptions = [
|
|
|
"without section",
|
|
|
"invalid variable name",
|
|
|
"expected trailing ]",
|
|
@@ -27,7 +21,7 @@ def TestOneInput(data):
|
|
|
"escape character",
|
|
|
"missing end quote",
|
|
|
]
|
|
|
- if is_expected_error(expected_errors, str(e)):
|
|
|
+ if is_expected_exception(expected_exceptions, e):
|
|
|
return -1
|
|
|
else:
|
|
|
raise e
|