tests: Don't globally set tmux default-shell

run_term() uses tmux set-option -g to globally set the default shell.
Unfortunately this hits a chicken-and-egg problem that's common with many
of tmux's session options.  If there isn't already a tmux server running,
we can't connect to set the option.  If we attempt this after starting our
session (and therefore the server), then the session will already be
started with the previous default shell.

In any case it's not a good idea to set tmux global options, since that
might interfere with whatever else the user is doing in tmux.  So, instead
set the default-shell option locally to the session after starting it.  To
make sure we get the right shell for our initial script, explicitly invoke
/bin/sh to interpret it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2022-05-12 13:27:21 +10:00 committed by Stefano Brivio
parent 14cbbd602c
commit ae83999b75

View file

@ -542,26 +542,25 @@ pause_continue() {
# run_term() - Start tmux session, running entry point, with recording if needed # run_term() - Start tmux session, running entry point, with recording if needed
run_term() { run_term() {
export SHELL="/bin/sh"
tmux set-option -g default-shell "/bin/sh"
TMUX="tmux new-session -s passt_test -ePCAP=$PCAP -eDEBUG=$DEBUG" TMUX="tmux new-session -s passt_test -ePCAP=$PCAP -eDEBUG=$DEBUG"
if [ ${CI} -eq 1 ]; then if [ ${CI} -eq 1 ]; then
printf '\e[8;50;240t' printf '\e[8;50;240t'
asciinema rec --overwrite ci.uncut -c "$TMUX ./ci from_term" asciinema rec --overwrite ci.uncut -c "$TMUX /bin/sh -c './ci from_term'"
video_postprocess ci.uncut video_postprocess ci.uncut
elif [ ${DEMO} -eq 1 ]; then elif [ ${DEMO} -eq 1 ]; then
printf '\e[8;40;130t' printf '\e[8;40;130t'
asciinema rec --overwrite demo.uncut -c "$TMUX ./run_demo from_term" asciinema rec --overwrite demo.uncut -c "$TMUX /bin/sh -c './run_demo from_term'"
video_postprocess demo.uncut video_postprocess demo.uncut
else else
$TMUX ./run from_term $TMUX /bin/sh -c './run from_term'
fi fi
} }
# term() - Set up terminal window and panes for regular tests or CI # term() - Set up terminal window and panes for regular tests or CI
term() { term() {
tmux set-option default-shell "/bin/sh"
tmux set status-interval 1 tmux set status-interval 1
tmux rename-window '' tmux rename-window ''
@ -596,6 +595,8 @@ term() {
# term_demo() - Set up terminal window and panes for demo # term_demo() - Set up terminal window and panes for demo
term_demo() { term_demo() {
tmux set-option default-shell "/bin/sh"
tmux set status-interval 1 tmux set status-interval 1
tmux rename-window '' tmux rename-window ''