You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SAI-PTF] Skip test when hit expected error from sai api (#1697)
Why
When hit the expected error like SAI_STATUS_NOT_SUPPORTED = -2, then skip the test.
related to issue #1610
How
Add conditional exeption handler when return from sai api invocation
Test:
Test on brcm platform on case sainexthop.tunnelVrfTest
Signed-off-by: richardyu-ms <[email protected]>
Signed-off-by: richardyu-ms <[email protected]>
Copy file name to clipboardExpand all lines: meta/rpc/README.md
-1
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,6 @@ Optional arguments are useful for development purposes.
19
19
|`-d``--dump`| Dump all data to the file. **Should be used during development**. |
20
20
|`--mandatory-attrs`| Make mandatory attributes obligatory in *sai\_adapter.py*. It removes `=None` from attributes, which are passed as arguments into python functions. Can be useful for debugging purposes, but since most of attributes are **optionally** mandatory, this is not as useful as it could be. |
21
21
|`--dev-utils[=STR]`| Generate additional development utils within the generated code. Additional options: [=log,zero]. Useful for tests development and debugging. The generated code **should not** be committed. |
22
-
|`--skip_error[=STR]`| Skip test on specified error code. Additional options: [=-2]. The generated code **should not** be committed. |
23
22
|`--adapter_logger`| Enable the logger in sai_adapter, it will log all the method invocation. |
errorcode: a list of the error code that test will be skipped.
196
-
"""
197
-
198
-
@wraps(func)
199
-
def decorated(*args, **kwargs):
200
-
"""
201
-
Check the return value and check if the status is the error code
202
-
on which the test should be skipped.
203
-
204
-
Args:
205
-
args(List): original args
206
-
kwargs(Dict): original kwargs
207
-
Returns:
208
-
retval(Any): the original return value
209
-
"""
210
-
retval = func(*args, **kwargs)
211
-
global status
212
-
if status in errorcode:
213
-
reason = "SkipTest: {} with errorcode: {}".format(func.__name__, status)
214
-
print(reason)
215
-
testutils.skipped_test_count=1
216
-
raise SkipTest(reason)
217
-
return retval
218
-
return decorated
219
-
return skip_test_on_error_decorator
220
-
[%- END -%]
221
176
222
177
[%- BLOCK invocation_logger_func -%]
223
178
def invocation_logger(func):
@@ -259,9 +214,6 @@ def invocation_logger(func):
259
214
@instance_counter("[% function.object %]", "[% function.operation %]"[% IF dev_utils.match('log') %], log=True[% END %][% IF dev_utils.match('zero') %], zero=True[% END %])
260
215
[%- END -%]
261
216
262
-
[%- BLOCK decorate_skip_test_on_error %]
263
-
@skip_test_on_error([% IF skip_error %]errorcode=[[% skip_error %]][% END %])
0 commit comments