Coverage for /pythoncovmergedfiles/medio/medio/src/dulwich/fuzzing/fuzz-targets/fuzz_configfile.py: 32%
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
12# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
14import sys
15from io import BytesIO
17import atheris
18from test_utils import is_expected_exception
20with atheris.instrument_imports():
21 from dulwich.config import ConfigFile
24def TestOneInput(data) -> int | None:
25 try:
26 ConfigFile.from_file(BytesIO(data))
27 except ValueError as e:
28 expected_exceptions = [
29 "without section",
30 "invalid variable name",
31 "expected trailing ]",
32 "invalid section name",
33 "Invalid subsection",
34 "escape character",
35 "missing end quote",
36 ]
37 if is_expected_exception(expected_exceptions, e):
38 return -1
39 else:
40 raise e
43def main() -> None:
44 atheris.Setup(sys.argv, TestOneInput)
45 atheris.Fuzz()
48if __name__ == "__main__":
49 main()