File tree 3 files changed +43
-0
lines changed
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Copyright (C) 2024 Intel Corporation
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import sys
5
+
6
+ import atheris
7
+
8
+ with atheris .instrument_imports ():
9
+ from openvino_xai import Explainer , insert_xai
10
+
11
+
12
+ def TestOneInput (input_bytes ):
13
+ data_provider = atheris .FuzzedDataProvider (input_bytes )
14
+
15
+ # Test Explainer statefull class API
16
+ try :
17
+ explainer = Explainer (
18
+ model = data_provider .ConsumeBytes (8 ),
19
+ task = data_provider .ConsumeUInt (8 ),
20
+ )
21
+ explanation = explainer (data = data_provider .ConsumeBytes (8 ))
22
+ except ValueError as e :
23
+ pass
24
+
25
+ # Test insert_xai() stateless API
26
+ try :
27
+ insert_xai (
28
+ model = data_provider .ConsumeBytes (8 ),
29
+ task = data_provider .ConsumeUInt (8 ),
30
+ )
31
+ except ValueError as e :
32
+ pass
33
+
34
+
35
+ atheris .Setup (sys .argv , TestOneInput )
36
+ atheris .Fuzz ()
Original file line number Diff line number Diff line change @@ -25,3 +25,10 @@ commands =
25
25
extras = dev,val
26
26
commands =
27
27
pytest -ra --showlocals {posargs:tests/}
28
+
29
+ [testenv:fuzz-{py310, py311}]
30
+ deps =
31
+ atheris
32
+ extras = dev
33
+ commands =
34
+ python tests/fuzz/test_fuzz.py {posargs:-artifact_prefix ={toxworkdir}/ -print_final_stats =1 -runs =10000000}
You can’t perform that action at this time.
0 commit comments