test: cleaned up stty get/set in tests

This commit is contained in:
Olof hagsand 2023-09-22 13:43:27 +02:00
parent 2603b6f139
commit 2b6bd4fb5c
4 changed files with 9 additions and 8 deletions

View file

@ -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 &>/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

View file

@ -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

View file

@ -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 '^<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'

View file

@ -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" "$?"