Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [RFC] tst_check_cmds to exit only current test
@ 2018-03-29 11:45 Petr Vorel
  2018-04-04 13:15 ` Cyril Hrubis
  0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2018-03-29 11:45 UTC (permalink / raw)
  To: ltp

Hi,

I'm thinking about implementing tst_check_cmds() equivalent just for current test.
tst_check_cmds() breaks whole testing (tst_brkm TCONF "'$cmd' not found"), which is usually what we want. But sometimes it'd be handy to have an easy way to skip only current test.
E.g. interface stress tests (if-addr-adddel, ...) run test with ifconfig and then with ip and require ifconfig (tst_check_cmds ifconfig).
As ifconfig is not already available in some distros nothing is tested in this case.

# TODO: find a better name
# another option (maybe better would be to add getopt option to tst_check_cmds()
tst_check_cmds_test()
{
	local cmd
	for cmd in $*; do
		if ! command -v $cmd > /dev/null 2>&1; then
			tst_res TCONF "'$cmd' not found"
			return 32; # we don't have tst_flag2mask() in new API
		fi
	done
}

testcases/network/stress/interface/if-addr-adddel
test_body()
{
	local cmd_type=$1                                                                                                                   
                                                                                                                                        
    case $cmd_type in                                                                                                                   
    if_cmd) local cmd_name='ifconfig' ;;
    ip_cmd) local cmd_name='ip' ;;                                                                                                      
    *) tst_brkm TBROK "Unknown test parameter '$cmd_type'"                                                                              
    esac
	tst_check_cmds_test ifconfig || return
...

Is it valid approach approach or should we use getopts to run the test twice?
Well, this wouldn't help with interface stress tests as test_net.sh still use the old
shell API, but that can change.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-04-04 14:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-29 11:45 [LTP] [RFC] tst_check_cmds to exit only current test Petr Vorel
2018-04-04 13:15 ` Cyril Hrubis
2018-04-04 13:44   ` Petr Vorel
2018-04-04 13:51     ` Cyril Hrubis
2018-04-04 14:57       ` Petr Vorel
2018-04-04 13:46   ` Petr Vorel
2018-04-04 13:58     ` Alexey Kodanev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox