[LTP] [PATCH] containers/netns/netns_sysfs.sh: add kernel version check

Cyril Hrubis chrubis@suse.cz
Mon Oct 31 10:28:25 CET 2016

> > +tst_kvercmp 2 6 35
> > +if [ $? -eq 0 ]; then
> Just out of curiosity - I see this used on more places, but can't
> understand why would you use this instead of simply
>   if tst_kvercmp 2 6 35; then
> Any reason behind that? Am I missing a test writing rule?

The most probable reason would be that the tst_kvercmp actually returns
ternary result (older than, equal or newer is mapped to 0, 1, 2) so if
you want to anything else than "kernel is older" check you have to
examine the $?.

Maybe I sould write a new tst_kvercmp for the new shell library that
would work similar to the test shell buildin so that we can do something

if tst_kvercmp -nq "2.6.35" -o "3.8"; then

where the modifiers would stand for:

n  newer
nq newer or equal
o  older
oq older or equal

Cyril Hrubis

More information about the ltp mailing list