From 2b6bd4fb5c17c34526694c4180c2b3bf2181c220 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 22 Sep 2023 13:43:27 +0200 Subject: [PATCH] test: cleaned up stty get/set in tests --- test/lib.sh | 12 ++++++++---- test/test_autocli_alias_skip.sh | 1 - test/test_config_dump.sh | 3 +-- test/test_restconf.sh | 1 - 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/lib.sh b/test/lib.sh index 4d161cf4..6d43d2a2 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -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 @@ -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 & if [ $? -ne 0 ]; then err1 "expected 0" "$?" @@ -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 @@ -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 diff --git a/test/test_autocli_alias_skip.sh b/test/test_autocli_alias_skip.sh index aeca77ba..d625767f 100755 --- a/test/test_autocli_alias_skip.sh +++ b/test/test_autocli_alias_skip.sh @@ -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 diff --git a/test/test_config_dump.sh b/test/test_config_dump.sh index 4a838a62..ad0b1ae6 100755 --- a/test/test_config_dump.sh +++ b/test/test_config_dump.sh @@ -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 @@ -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 '^' "$dir" "0" "" "kw-nokey" "orig" "cmdline" "extradir" --not-- "42" 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' diff --git a/test/test_restconf.sh b/test/test_restconf.sh index d498ccfc..76e7d497 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -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 & if [ $? -ne 0 ]; then err1 "expected 0" "$?"