Skip to content

Commit

Permalink
test: cleaned up stty get/set in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Sep 22, 2023
1 parent 2603b6f commit 2b6bd4f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
12 changes: 8 additions & 4 deletions test/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

>&2 echo "Running $testfile"

# Save stty
STTYSETTINGS=$(stty -g)

# Generated config file from autotools / configure
if [ -f ./config.sh ]; then
. ./config.sh
Expand Down Expand Up @@ -580,9 +583,8 @@ function wait_backend(){
# Start restconf daemon
# @see wait_restconf
function start_restconf(){
STTYSETTINGS=`stty -g`
# Start in background
echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $*"
# echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $*"
sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG $* </dev/null &>/dev/null &
if [ $? -ne 0 ]; then
err1 "expected 0" "$?"
Expand Down Expand Up @@ -637,8 +639,6 @@ function wait_restconf(){
if [ $valgrindtest -eq 3 ]; then
sleep 2 # some problems with valgrind
fi

stty $STTYSETTINGS >/dev/null
}

# Wait for restconf to stop
Expand Down Expand Up @@ -683,6 +683,10 @@ function wait_snmp()
# eg all.sh or mem.sh
function endtest()
{
# Commented from now, it is unclear what destroys the tty, if something does the original
# problem should be fixed at the origin.
# stty $STTYSETTINGS >/dev/null

if [ $valgrindtest -eq 1 ]; then
checkvalgrind
fi
Expand Down
1 change: 0 additions & 1 deletion test/test_autocli_alias_skip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Test skip for leaf, container and list
# Test alias only for leaf, since it is not implemented for container+list
# see also test_autocli_hide.sh
set -u
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi

Expand Down
3 changes: 1 addition & 2 deletions test/test_config_dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi

APPNAME=example


cfg=$dir/conf_yang.xml
cfdir=$dir/conf.d
test -d $cfdir || mkdir $cfdir
Expand Down Expand Up @@ -72,7 +71,7 @@ new "restconf xml"
expectpart "$(sudo $clixon_restconf -f $cfg -C xml -o CLICON_MODULE_SET=42 -o CLICON_FEATURE="cmdline")" 0 '^<clixon-config xmlns="http://clicon.org/config">' "<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR>" "<CLICON_MODULE_SET_ID>0</CLICON_MODULE_SET_ID>" "<autocli>" "<list-keyword-default>kw-nokey</list-keyword-default>" "<CLICON_FEATURE>orig</CLICON_FEATURE>" "<CLICON_FEATURE>cmdline</CLICON_FEATURE>" "<CLICON_FEATURE>extradir</CLICON_FEATURE>" --not-- "<CLICON_MODULE_SET_ID>42</CLICON_MODULE_SET_ID>"

new "cli json"
expectpart "$($clixon_cli -1 -f $cfg -C json -o CLICON_MODULE_SET=42 -o CLICON_FEATURE="cmdline")" 0 '"clixon-config:clixon-config": {' '"CLICON_YANG_MAIN_DIR": "/var/tmp/./test_config_dump.sh",'
expectpart "$($clixon_cli -1 -f $cfg -C json -o CLICON_MODULE_SET=42 -o CLICON_FEATURE="cmdline")" 0 '"clixon-config:clixon-config": {' "\"CLICON_YANG_MAIN_DIR\": \"$dir\","

new "cli text"
expectpart "$($clixon_cli -1 -f $cfg -C text -o CLICON_MODULE_SET=42 -o CLICON_FEATURE="cmdline")" 0 '^clixon-config:clixon-config {' 'list-keyword-default kw-nokey;' 'CLICON_FEATURE \[' 'extradir' 'orig' 'cmdline'
Expand Down
1 change: 0 additions & 1 deletion test/test_restconf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ function testrun()
new "start restconf daemon"
# inline of start_restconf, cant make quotes to work
echo "sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG -f $cfg -R $RESTCONFIG1"
STTYSETTINGS=$(stty -g) # reset in wait_restconf
sudo -u $wwwstartuser -s $clixon_restconf $RCLOG -D $DBG -f $cfg -R "$RESTCONFIG1" </dev/null &>/dev/null &
if [ $? -ne 0 ]; then
err1 "expected 0" "$?"
Expand Down

0 comments on commit 2b6bd4f

Please sign in to comment.