Coverage for /pythoncovmergedfiles/medio/medio/src/fuzz_func.py: 65%
52 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07:16 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 07:16 +0000
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#!/usr/bin/python3
13# Copyright 2022 Google LLC
14#
15# Licensed under the Apache License, Version 2.0 (the "License");
16# you may not use this file except in compliance with the License.
17# You may obtain a copy of the License at
18#
19# http://www.apache.org/licenses/LICENSE-2.0
20#
21# Unless required by applicable law or agreed to in writing, software
22# distributed under the License is distributed on an "AS IS" BASIS,
23# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24# See the License for the specific language governing permissions and
25# limitations under the License.
27import atheris
28import sys
29with atheris.instrument_imports():
30 from redis.client import *
32def dummy_callback(obj):
33 pass
35def TestInput(data):
36 fdp = atheris.FuzzedDataProvider(data)
38 timestamp_to_datetime(fdp.ConsumeString(20))
39 timestamp_to_datetime(fdp.ConsumeInt(8))
40 timestamp_to_datetime(fdp.ConsumeFloat())
42 string_keys_to_dict("('%s','%s','%s')"%(fdp.ConsumeString(20),fdp.ConsumeString(20),fdp.ConsumeString(20)),dummy_callback)
43 string_keys_to_dict(fdp.ConsumeString(60),dummy_callback)
45 parse_debug_object(fdp.ConsumeString(20))
46 parse_debug_object(fdp.ConsumeUnicode(20))
47 parse_debug_object(fdp.ConsumeBytes(20))
49 parse_object(fdp.ConsumeString(20),fdp.ConsumeString(20))
50 parse_object(fdp.ConsumeUnicode(20),fdp.ConsumeUnicode(20))
51 parse_object(fdp.ConsumeBytes(20),fdp.ConsumeBytes(20))
52 parse_object(fdp.ConsumeInt(8),fdp.ConsumeBytes(20))
53 parse_object(fdp.ConsumeInt(8),"idletime")
54 parse_object(fdp.ConsumeFloat(),"idletime")
55 try:
56 parse_object(fdp.ConsumeString(20),"idletime")
57 except ValueError as e:
58 if "invalid literal for int() with base 10" not in str(e):
59 raise e
60 parse_object(fdp.ConsumeBool(),"idletime")
62 response_str = """
63 %s:%s
64 %s:%s
65 %s:%s
66 %s:%d
67 %s:%f
68 %s:%d
69 """%(
70 fdp.ConsumeString(20),fdp.ConsumeString(20),
71 fdp.ConsumeString(20),fdp.ConsumeUnicode(20),
72 fdp.ConsumeString(20),fdp.ConsumeBytes(20),
73 fdp.ConsumeString(20),fdp.ConsumeInt(8),
74 fdp.ConsumeString(20),fdp.ConsumeFloat(),
75 fdp.ConsumeString(20),fdp.ConsumeBool(),
76 )
78 parse_info(fdp.ConsumeString(20))
79 parse_info(fdp.ConsumeUnicode(20))
80 parse_info(fdp.ConsumeBytes(20))
81 parse_info(response_str)
83 cid = CaseInsensitiveDict({
84 fdp.ConsumeString(10):fdp.ConsumeUnicode(10),
85 fdp.ConsumeString(10):fdp.ConsumeBytes(10),
86 fdp.ConsumeString(10):fdp.ConsumeInt(8),
87 fdp.ConsumeString(10):fdp.ConsumeFloat(),
88 fdp.ConsumeString(10):fdp.ConsumeBool()
89 })
90 fdp.ConsumeString(10) in cid
91 cid.popitem()
92 cid.get(fdp.ConsumeString(10))
93 cid[fdp.ConsumeString(10)] = fdp.ConsumeString(5)
94 cid.update({
95 fdp.ConsumeString(10):fdp.ConsumeUnicode(10),
96 fdp.ConsumeString(10):fdp.ConsumeBytes(10),
97 fdp.ConsumeString(10):fdp.ConsumeInt(8),
98 fdp.ConsumeString(10):fdp.ConsumeFloat(),
99 fdp.ConsumeString(10):fdp.ConsumeBool()
100 })
102def main():
103 atheris.Setup(sys.argv, TestInput, enable_python_coverage=True)
104 atheris.Fuzz()
106if __name__ == "__main__":
107 main()