[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <57359fb9-195c-4a4a-b102-f7739453a94f@lunn.ch>
Date: Mon, 27 Oct 2025 20:46:00 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com, andrew+netdev@...n.ch, horms@...nel.org,
shuah@...nel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH net-next v2] selftests: drv-net: replace the nsim ring
test with a drv-net one
> + def test_config(config):
> + try:
> + cfg.eth.channels_set(ehdr | config)
> + get = cfg.eth.channels_get(ehdr)
> + for k, v in config.items():
> + ksft_eq(get.get(k, 0), v)
> + except NlError as e:
> + failed.append(mix)
> + ksft_pr("Can't set", config, e)
> + else:
> + ksft_pr("Okay", config)
We expect failure to leave the configuration unchanged. So i would
actually do:
try:
before = get()
set()
except:
after = get()
fail(after != before)
Also, does nlError contain the error code?
fail(e.errcode not in (EINVAL, EOPNOTSUPP))
It would be good to detect and fail ENOTSUPP, which does appear every
so often, when it should not.
> + # Try to reach min on all settings
> + for param in params:
> + val = rings[param]
> + while True:
> + try:
> + cfg.eth.rings_set({'header':{'dev-index': cfg.ifindex},
> + param: val // 2})
> + val //= 2
> + if val <= 1:
> + break
> + except NlError:
> + break
Is 0 ever valid? I would actually test 0 and make sure it fails with
EINVAL, or EOPNOTSUPP. Getting range checks wrong is a typical bug, so
it is good to test them. The happy days cases are boring because
developers tend to test those, so they are hardly worth testings. Its
the edge cases which should be tested.
Andrew
Powered by blists - more mailing lists