Page MenuHomeFreeBSD

kyua: Add "debug -x|--execute cmd" option
Needs ReviewPublic

Authored by igoro on Sat, Sep 20, 3:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 29, 3:15 PM
Unknown Object (File)
Sun, Sep 28, 1:45 PM
Unknown Object (File)
Sat, Sep 27, 3:05 AM
Unknown Object (File)
Fri, Sep 26, 5:25 PM
Unknown Object (File)
Sun, Sep 21, 10:40 PM
Unknown Object (File)
Sun, Sep 21, 1:06 AM
Unknown Object (File)
Sat, Sep 20, 10:23 PM
Unknown Object (File)
Sat, Sep 20, 9:56 PM
Subscribers

Details

Reviewers
markj
Group Reviewers
tests

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 67198
Build 64081: arc lint + arc unit

Event Timeline

igoro requested review of this revision.Sat, Sep 20, 3:35 PM

Always attempt to use $SHELL

The prototype has the following logic currently:

1 Invoking w/o argument runs $SHELL (falls back to hardcoded /usr/bin/ if SHELL env var is not found). It does chdir to the test's working dir:

> kyua debug -x test1
> kyua debug --execute test1

root@taarch64:/usr/tests/sys/netpfil/pf # kyua debug -x mbuf:inet_in_mbuf_len
root@taarch64:/tmp/kyua.h6W16I/2/work # ls -a
.                       ..                      created_interfaces.lst  created_jails.lst
root@taarch64:/tmp/kyua.h6W16I/2/work # exit
Executing command [ ping -c1 192.0.2.2 ]
alcatraz: removed
Fail: incorrect exit status: 0, expected: 1
stdout:
PING 192.0.2.2 (192.0.2.2): 56 data bytes
64 bytes from 192.0.2.2: icmp_seq=0 ttl=64 time=0.097 ms

--- 192.0.2.2 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.097/0.097/0.097/0.000 ms

stderr:

Files left in work directory after failure: created_interfaces.lst, created_jails.lst
ifconfig: interface epair0a does not exist
mbuf:inet_in_mbuf_len  ->  failed: atf-check failed; see the output of the test for details
root@taarch64:/usr/tests/sys/netpfil/pf # echo $?
1

2 If an argument is passed then $SHELL (falls back to hard-coded /bin/sh) is run with the given command string (aka $SHELL -c $cmd). A shell is expected to have -c option. It also does chdir to the test's working dir:

> kyua debug -x'printf "\a"' test1
> kyua debug --execute="cat some_file_from_test_working_dir; do_something_else" test1

The default string is intentionally set to $SHELL literal to be a hint during help output reading:

root@taarch64:/usr/tests/sys/netpfil/pf # kyua help debug
kyua (Kyua) 0.13

Usage: kyua [general_options] debug [command_options] test_case

...

Available command options:
  --build-root=path                     Path to the built test programs, if different from the location of the
                                        Kyuafile scripts.
  -k file, --kyuafile=file              Path to the test suite definition (default: Kyuafile).
  -p, --pause-before-cleanup-upon-fail  Pauses right before the test cleanup upon fail.
  --pause-before-cleanup                Pauses right before the test cleanup.
  --stdout=path                         Where to direct the standard output of the test case (default: /dev/stdout).
  --stderr=path                         Where to direct the standard error of the test case (default: /dev/stderr).
  -x cmd, --execute=cmd                 A command to run upon test failure (default: $SHELL).

See kyua-debug(1) for more details.

P.S. Eventually, I plan to extract base_option/string_option arg optionality to separate commit(s).

This works almost exactly how I want, thank you. I have one "complaint": when I use this mode, kyua 1) drops me in the shell, 2) waits for the shell to exit, 3) prints the debug output, e.g., executed commands and the test failure string. The -p mode is basically the same. It is more useful to do 3) first, then 1) and 2). Is it hard to make this change?