tst_net.sh: Simplify ipver settings code
PATCH 1/4 tst_net.sh: Simplify ipver settings code
--- testcases/lib/tst_net.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
testcases/lib/tst_net.sh +2 -3
@@ -29,11 +29,12 @@ TST_SETUP="tst_net_setup" # Blank for an IPV4 test; 6 for an IPV6 test. TST_IPV6=${TST_IPV6:-} +ipver=${TST_IPV6:-4} tst_net_parse_args() { case $1 in - 6) TST_IPV6=6;; + 6) TST_IPV6=6 ipver=6;; *) $TST_PARSE_ARGS_CALLER "$1" "$2";; esac }
@@ -68,7 +69,6 @@ tst_net_remote_tmpdir() tst_net_setup() { - ipver=${TST_IPV6:-4} tst_net_remote_tmpdir [ -n "$TST_SETUP_CALLER" ] && $TST_SETUP_CALLER }
@@ -79,7 +79,6 @@ fi if [ -n "$TST_USE_LEGACY_API" ]; then tst_net_read_opts "$@" - ipver=${TST_IPV6:-4} fi # old vs. new API compatibility layer
Signature · 1 line
2.16.3
PATCH 2/4 net: Allow to overwrite libraries getopts handlers
Network libraries recently started to use TST_OPTS and TST_PARSE_ARGS:89a83d8a0 ("net/ipsec_lib.sh: Process getopts parameters with TST_OPTS and TST_PARSE_ARGS")ce920a5a4 "network/virt_lib.sh: Process getopts parameters with TST_OPTS and TST_PARSE_ARGS"5f088c3f4 ("nfs/nfs_lib.sh: Fix wrong getopts parameter handling")
This allows to test using these libs customize getopts.
---
Needed for rewriting into new API.
--- testcases/network/nfs/nfs_stress/nfs_lib.sh | 4 ++-- testcases/network/stress/ipsec/ipsec_lib.sh | 5 +++-- testcases/network/tcp_fastopen/tcp_fastopen_run.sh | 4 ++-- testcases/network/virt/virt_lib.sh | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +2 -2
@@ -37,8 +37,8 @@ nfs_parse_args() esac } -TST_OPTS="hv:t:" -TST_PARSE_ARGS=nfs_parse_args +TST_OPTS="${TST_OPTS:-hv:t:}" +TST_PARSE_ARGS="${TST_PARSE_ARGS:-nfs_parse_args}" TST_USE_LEGACY_API=1 . tst_net.sh
testcases/network/stress/ipsec/ipsec_lib.sh +3 -2
@@ -67,8 +67,9 @@ ipsec_lib_parse_args() esac } -TST_OPTS="hl:m:p:s:S:k:A:e:a:c:r:" -TST_PARSE_ARGS=ipsec_lib_parse_args +TST_OPTS="${TST_OPTS:-hl:m:p:s:S:k:A:e:a:c:r:}" +TST_PARSE_ARGS="${TST_PARSE_ARGS:-ipsec_lib_parse_args}" + TST_USE_LEGACY_API=1 . tst_net.sh
testcases/network/tcp_fastopen/tcp_fastopen_run.sh +2 -2
@@ -39,8 +39,8 @@ TST_TOTAL=1 TCID="tcp_fastopen" TST_NEEDS_TMPDIR=1 -TST_OPTS="hr:n:R:" -TST_PARSE_ARGS=tcp_fastopen_parse_args +TST_OPTS="${TST_OPTS:-hr:n:R:}" +TST_PARSE_ARGS="${TST_PARSE_ARGS:-tcp_fastopen_parse_args}" TST_USE_LEGACY_API=1 . tst_net.sh
testcases/network/virt/virt_lib.sh +2 -2
@@ -48,8 +48,8 @@ virt_lib_parse_args() esac } -TST_OPTS="hi:d:" -TST_PARSE_ARGS=virt_lib_parse_args +TST_OPTS="${TST_OPTS:-hi:d:}" +TST_PARSE_ARGS="${TST_PARSE_ARGS:-virt_lib_parse_args}" TST_USE_LEGACY_API=1 . tst_net.sh
Signature · 1 line
2.16.3
PATCH 2/4 net: Allow to overwrite libraries getopts handlers
Quoted 13 lines · Petr Vorel
Network libraries recently started to use
TST_OPTSandTST_PARSE_ARGS:89a83d8a0("net/ipsec_lib.sh: Process getopts parameters withTST_OPTSandTST_PARSE_ARGS")ce920a5a4"network/virt_lib.sh: Process getopts parameters withTST_OPTSandTST_PARSE_ARGS"5f088c3f4("nfs/nfs_lib.sh: Fix wrong getopts parameter handling")This allows to test using these libs customize getopts.
Signed-off-by Petr Vorel <[email protected]>---
Needed for rewriting into new API.
---
...
testcases/network/stress/ipsec/ipsec_lib.sh ipsec_lib_parse_args() · line 70
Quoted 11 lines
testcases/network/stress/ipsec/ipsec_lib.sh +1
-2@@ -67,8 +67,9 @@ ipsec_lib_parse_args() esac } -TST_OPTS="hl:m:p:s:S:k:A:e:a:c:r:" -TST_PARSE_ARGS=ipsec_lib_parse_args +TST_OPTS="${TST_OPTS:-hl:m:p:s:S:k:A:e:a:c:r:}"
So, to customize these options we would need to implement the original library options as well or you are going to pass the rest of the options to the library ipsec_lib_parse_args handler?
I think TST_OPTS should include the library ones and the new options from the test.
It would be better to show the usage somewhere, i.e. when it is really needed.
PATCH 2/4 net: Allow to overwrite libraries getopts handlers
Hi Alexey,
...
Quoted 8 lines
testcases/network/stress/ipsec/ipsec_lib.sh ipsec_lib_parse_args() · line 70
Quoted 3 lines
testcases/network/stress/ipsec/ipsec_lib.sh +1
-2-TST_OPTS="hl:m:p:s:S:k:A:e:a:c:r:" -TST_PARSE_ARGS=ipsec_lib_parse_args +TST_OPTS="${TST_OPTS:-hl:m:p:s:S:k:A:e:a:c:r:}"So, to customize these options we would need to implement the original library options as well or you are going to pass the rest of the options to the library
ipsec_lib_parse_argshandler?
Quoted 5 lines
I think
TST_OPTSshould include the library ones and the new options from the test.It would be better to show the usage somewhere, i.e. when it is really needed.
OK, I'll include this one in patchset, which migrate virt_lib.sh + ipsec_lib.sh into the new API. I tried to introduce some changes before as the whole patch is going to be quite big (due other bugs and the need to migrate virt_lib.sh and ipsec_lib.sh altogether.
My idea is if the test which uses any of virt_lib.sh or ipsec_lib.sh needs to change getopts, it's it's responsibility to add these getopts.
Kind regards,
Petr
PATCH 3/4 net: Allow to skip additional getopts
In reply to Petr VorelNetwork libraries which use tst_test.sh allow to avoid setting their additional getopts. With TST_NET_SKIP_PARSE_ARGS=1 only -6 from tst_net.sh is handled (for both new and legacy API) and -h and -i from tst_test.sh (for new API only).
---
Not sure if this is useful. Meant for next commit.
--- testcases/lib/tst_net.sh | 3 ++- testcases/lib/tst_test.sh | 2 +- testcases/network/nfs/nfs_stress/nfs_lib.sh | 6 ++++-- testcases/network/stress/ipsec/ipsec_lib.sh | 6 ++++-- testcases/network/tcp_fastopen/tcp_fastopen_run.sh | 6 ++++-- testcases/network/virt/virt_lib.sh | 6 ++++-- 6 files changed, 19 insertions(+), 10 deletions(-)
testcases/lib/tst_net.sh +2 -1
@@ -35,7 +35,8 @@ tst_net_parse_args() { case $1 in 6) TST_IPV6=6 ipver=6;; - *) $TST_PARSE_ARGS_CALLER "$1" "$2";; + *) [ -z "$TST_NET_SKIP_PARSE_ARGS" -o "$1" = "i" -o "$1" = "h" ] && \ + $TST_PARSE_ARGS_CALLER "$1" "$2";; esac }
testcases/lib/tst_test.sh +1 -1
@@ -255,7 +255,7 @@ tst_run() OPTS|USAGE|PARSE_ARGS|POS_ARGS);; NEEDS_ROOT|NEEDS_TMPDIR|NEEDS_DEVICE|DEVICE);; NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);; - IPV6);; + IPV6|NET_SKIP_PARSE_ARGS);; *) tst_res TWARN "Reserved variable TST_$tst_i used!";; esac done
testcases/network/nfs/nfs_stress/nfs_lib.sh +4 -2
@@ -37,8 +37,10 @@ nfs_parse_args() esac } -TST_OPTS="${TST_OPTS:-hv:t:}" -TST_PARSE_ARGS="${TST_PARSE_ARGS:-nfs_parse_args}" +if [ -z "$TST_NET_SKIP_PARSE_ARGS" ]; then + TST_OPTS="${TST_OPTS:-hv:t:}" + TST_PARSE_ARGS="${TST_PARSE_ARGS:-nfs_parse_args}" +fi TST_USE_LEGACY_API=1 . tst_net.sh
testcases/network/stress/ipsec/ipsec_lib.sh +4 -2
@@ -67,8 +67,10 @@ ipsec_lib_parse_args() esac } -TST_OPTS="${TST_OPTS:-hl:m:p:s:S:k:A:e:a:c:r:}" -TST_PARSE_ARGS="${TST_PARSE_ARGS:-ipsec_lib_parse_args}" +if [ -z "$TST_NET_SKIP_PARSE_ARGS" ]; then + TST_OPTS="${TST_OPTS:-hl:m:p:s:S:k:A:e:a:c:r:}" + TST_PARSE_ARGS="${TST_PARSE_ARGS:-ipsec_lib_parse_args}" +fi TST_USE_LEGACY_API=1 . tst_net.sh
testcases/network/tcp_fastopen/tcp_fastopen_run.sh +4 -2
@@ -39,8 +39,10 @@ TST_TOTAL=1 TCID="tcp_fastopen" TST_NEEDS_TMPDIR=1 -TST_OPTS="${TST_OPTS:-hr:n:R:}" -TST_PARSE_ARGS="${TST_PARSE_ARGS:-tcp_fastopen_parse_args}" +if [ -z "$TST_NET_SKIP_PARSE_ARGS" ]; then + TST_OPTS="${TST_OPTS:-hr:n:R:}" + TST_PARSE_ARGS="${TST_PARSE_ARGS:-tcp_fastopen_parse_args}" +fi TST_USE_LEGACY_API=1 . tst_net.sh
testcases/network/virt/virt_lib.sh +4 -2
@@ -48,8 +48,10 @@ virt_lib_parse_args() esac } -TST_OPTS="${TST_OPTS:-hi:d:}" -TST_PARSE_ARGS="${TST_PARSE_ARGS:-virt_lib_parse_args}" +if [ -z "$TST_NET_SKIP_PARSE_ARGS" ]; then + TST_OPTS="${TST_OPTS:-hi:d:}" + TST_PARSE_ARGS="${TST_PARSE_ARGS:-virt_lib_parse_args}" +fi TST_USE_LEGACY_API=1 . tst_net.sh
Signature · 1 line
2.16.3
PATCH 4/4 net/macsec0{1, 2}.sh: Use TST_NET_SKIP_PARSE_ARGS=1
In reply to Petr VorelThese tests load ipsec_lib.sh and virt_lib.sh.
Currently tst_net.sh doesn't support being used by more libraries, so when handling getopts the later one wins.
Disabling variables as they aren't used in the runtest file.
---
Alexey, do you use library variables for debugging? Or would you prefer to be without this and to have at least one libraries getopts?
Kind regards,
Petr
--- testcases/network/virt/macsec01.sh | 1 + testcases/network/virt/macsec02.sh | 1 + 2 files changed, 2 insertions(+)
testcases/network/virt/macsec01.sh +1 -0
@@ -24,6 +24,7 @@ TST_NEEDS_TMPDIR=1 virt_type="macsec" VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-100} +TST_NET_SKIP_PARSE_ARGS=1 . ipsec_lib.sh . virt_lib.sh
testcases/network/virt/macsec02.sh +1 -0
@@ -24,6 +24,7 @@ TST_NEEDS_TMPDIR=1 virt_type="macsec" VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-100} +TST_NET_SKIP_PARSE_ARGS=1 . ipsec_lib.sh . virt_lib.sh
Signature · 1 line
2.16.3
PATCH 4/4 net/macsec0{1, 2}.sh: Use TST_NET_SKIP_PARSE_ARGS=1
Quoted 11 lines · Petr Vorel
These tests load
ipsec_lib.shandvirt_lib.sh.
Currentlytst_net.shdoesn't support being used by more libraries, so when handling getopts the later one wins.
Disabling variables as they aren't used in the runtest file.Signed-off-by Petr Vorel <[email protected]>---
Alexey, do you use library variables for debugging? Or would you prefer to be without this and to have at least one libraries getopts?
I'm for keeping the IPsec options in macsec test, some of them are not explicitly defined in the test, therefore can be changed.
For virt_lib.sh library the better fix would be to define the options only for vxlan/geneve tests, because only those tests are currently using them.
PATCH 4/4 net/macsec0{1, 2}.sh: Use TST_NET_SKIP_PARSE_ARGS=1
Hi Alexey,
Quoted 14 lines · Petr Vorel
Quoted 10 lines
These tests load
ipsec_lib.shandvirt_lib.sh.
Currentlytst_net.shdoesn't support being used by more libraries, so when handling getopts the later one wins.
Disabling variables as they aren't used in the runtest file.Signed-off-by Petr Vorel <[email protected]>---
Alexey, do you use library variables for debugging? Or would you prefer to be without this and to have at least one libraries getopts?
Quoted 2 lines
I'm for keeping the IPsec options in macsec test, some of them are not explicitly defined in the test, therefore can be changed.
OK, thanks for info.
Quoted 3 lines
For
virt_lib.shlibrary the better fix would be to define the options only for vxlan/geneve tests, because only those tests are currently using them.
Could you please make this change?
Kind regards,
Petr
PATCH 1/4 tst_net.sh: Simplify ipver settings code
In reply to Petr VorelQuoted 10 lines · Petr Vorel
Signed-off-by Petr Vorel <[email protected]>--- testcases/lib/tst_net.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)testcases/lib/tst_net.sh +0
-0
testcases/lib/tst_net.sh TST_SETUP="tst_net_setup" · line 32
Quoted 4 lines
testcases/lib/tst_net.sh +1
-0@@ -29,11 +29,12 @@ TST_SETUP="tst_net_setup" # Blank for an IPV4 test; 6 for an IPV6 test. TST_IPV6=${TST_IPV6:-} +ipver=${TST_IPV6:-4}
Hi Petr,
Perhaps, we need a prefix TST_.
Shouldn't the same patch remove the setting of 'ipver' in the tests?
Thanks,
Alexey
PATCH 1/4 tst_net.sh: Simplify ipver settings code
Hi Alexey,
Quoted 16 lines · Petr Vorel
Quoted 10 lines
Signed-off-by Petr Vorel <[email protected]>--- testcases/lib/tst_net.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)testcases/lib/tst_net.sh +0
-0testcases/lib/tst_net.sh TST_SETUP="tst_net_setup" · line 32
Quoted 4 lines
testcases/lib/tst_net.sh +1
-0@@ -29,11 +29,12 @@ TST_SETUP="tst_net_setup" # Blank for an IPV4 test; 6 for an IPV6 test. TST_IPV6=${TST_IPV6:-} +ipver=${TST_IPV6:-4}
Quoted 5 lines
Hi Petr,
Perhaps, we need a prefix
TST_.Shouldn't the same patch remove the setting of 'ipver' in the tests?
Thanks for comments, both makes sense. I wanted to do it after migrating everything to new API, but probably better to do it before.
Quoted 2 lines
Thanks,
Alexey
Kind regards,
Petr