Coverage for /pythoncovmergedfiles/medio/medio/src/dulwich/fuzzing/fuzz-targets/fuzz_configfile.py: 33%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1###### Coverage stub
2import atexit
3import coverage
4cov = coverage.coverage(data_file='.coverage', cover_pylib=True)
5cov.start()
6# Register an exist handler that will print coverage
7def exit_handler():
8 cov.stop()
9 cov.save()
10atexit.register(exit_handler)
11####### End of coverage stub
12import sys
13from io import BytesIO
15import atheris
16from test_utils import is_expected_exception
18with atheris.instrument_imports():
19 from dulwich.config import ConfigFile
22def TestOneInput(data):
23 try:
24 ConfigFile.from_file(BytesIO(data))
25 except ValueError as e:
26 expected_exceptions = [
27 "without section",
28 "invalid variable name",
29 "expected trailing ]",
30 "invalid section name",
31 "Invalid subsection",
32 "escape character",
33 "missing end quote",
34 ]
35 if is_expected_exception(expected_exceptions, e):
36 return -1
37 else:
38 raise e
41def main():
42 atheris.Setup(sys.argv, TestOneInput)
43 atheris.Fuzz()
46if __name__ == "__main__":
47 main()