selftests: net: ksft: replace 95 with errno.EOPNOTSUPP

Petr suggested to use errno.EOPNOTSUPP instead of hard-coded 95
in the new test case. Adjust existing ones to match this style.

Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20240802000309.2368-3-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Stanislav Fomichev 2024-08-01 17:03:09 -07:00 committed by Jakub Kicinski
parent f879306834
commit a48395f22b
2 changed files with 5 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
import errno
import time
import os
from lib.py import ksft_run, ksft_exit, ksft_pr
@ -61,7 +62,7 @@ def test_pp_alloc(cfg, netdevnl):
try:
stats = get_stats()
except NlError as e:
if e.nl_msg.error == -95:
if e.nl_msg.error == -errno.EOPNOTSUPP:
stats = {}
else:
raise

View File

@ -20,7 +20,7 @@ def check_pause(cfg) -> None:
try:
ethnl.pause_get({"header": {"dev-index": cfg.ifindex}})
except NlError as e:
if e.error == 95:
if e.error == errno.EOPNOTSUPP:
raise KsftXfailEx("pause not supported by the device")
raise
@ -35,7 +35,7 @@ def check_fec(cfg) -> None:
try:
ethnl.fec_get({"header": {"dev-index": cfg.ifindex}})
except NlError as e:
if e.error == 95:
if e.error == errno.EOPNOTSUPP:
raise KsftXfailEx("FEC not supported by the device")
raise
@ -120,7 +120,7 @@ def qstat_by_ifindex(cfg) -> None:
# loopback has no stats
with ksft_raises(NlError) as cm:
netfam.qstats_get({"ifindex": 1}, dump=True)
ksft_eq(cm.exception.nl_msg.error, -95)
ksft_eq(cm.exception.nl_msg.error, -errno.EOPNOTSUPP)
ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex')
# Try to get stats for lowest unused ifindex but not 0