From 5351ac0ffc2871934606ac58b25b651157403ccd Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sat, 22 Jun 2024 16:30:27 +0200 Subject: [PATCH] Test: vagrant update --- example/main/example_cli.c | 2 ++ test/mem.sh | 1 - test/test_datastore_multi.sh | 29 ++++++++++++++++++----------- test/test_restconf_notifications.sh | 14 ++++++++++++-- test/vagrant/vagrant.sh | 1 + 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/example/main/example_cli.c b/example/main/example_cli.c index e297f433..941c0c33 100644 --- a/example/main/example_cli.c +++ b/example/main/example_cli.c @@ -309,7 +309,9 @@ myerror(clixon_handle h, goto done; #endif retval = 0; +#ifdef DYNAMICLINKAGE done: +#endif _errmsg_callback_fn = oldfn; if (xret) xml_free(xret); diff --git a/test/mem.sh b/test/mem.sh index e7a1ee3b..193318d9 100755 --- a/test/mem.sh +++ b/test/mem.sh @@ -58,7 +58,6 @@ function memonce(){ ;; esac - memerr=0 for test in $pattern; do # Can happen if no pattern, eg pattern=foo but "foo" does not exist diff --git a/test/test_datastore_multi.sh b/test/test_datastore_multi.sh index 03ad5479..54a943cd 100755 --- a/test/test_datastore_multi.sh +++ b/test/test_datastore_multi.sh @@ -9,6 +9,13 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example +# linux stat <- freebsd gnustat in coreutils +if [ -n "$(type gnustat 2> /dev/null)" ]; then + stat=gnustat +else + stat=stat +fi + # include err() and new() functions and creates $dir cfg=$dir/conf_yang.xml @@ -153,8 +160,8 @@ function check_db() dbname=$1 subfile=$2 - sudo chmod o+r $dir/${dbname}.d/0.xml - sudo chmod o+r $dir/${dbname}.d/$subfile + sudo chmod 755 $dir/${dbname}.d/ + sudo chmod 755 $dir/${dbname}.d/*.xml sudo rm -f $dir/x_db cat < $dir/x_db @@ -218,14 +225,14 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " new "Check candidate after edit" check_db candidate ${subfilename} -s0=$(stat -c "%Y" $dir/candidate.d/${subfilename}) +s0=$($stat -c "%Y" $dir/candidate.d/${subfilename}) sleep 1 new "Add 2nd data to mount x" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xx2x2value" "" "" new "Check candidate subfile changed" -s1=$(stat -c "%Y" $dir/candidate.d/${subfilename}) +s1=$($stat -c "%Y" $dir/candidate.d/${subfilename}) if [ $s0 -eq $s1 ]; then err "Timestamp changed" "$s0 = $s1" fi @@ -236,7 +243,7 @@ new "Change existing value in mount x" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xx2x2new" "" "" new "Check candidate subfile changed" -s2=$(stat -c "%Y" $dir/candidate.d/${subfilename}) +s2=$($stat -c "%Y" $dir/candidate.d/${subfilename}) if [ $s1 -eq $s2 ]; then err "Timestamp changed" "$s1 = $s2" fi @@ -247,7 +254,7 @@ new "Add data to top-level (not mount)" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "y" "" "" new "Check candidate subfile not changed" -s3=$(stat -c "%Y" $dir/candidate.d/${subfilename}) +s3=$($stat -c "%Y" $dir/candidate.d/${subfilename}) if [ $s2 -ne $s3 ]; then err "Timestamp not changed" "$s2 != $s3" fi @@ -258,7 +265,7 @@ new "Delete leaf" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xx2x2newnone" "" "" new "Check candidate subfile changed" -s4=$(stat -c "%Y" $dir/candidate.d/${subfilename}) +s4=$($stat -c "%Y" $dir/candidate.d/${subfilename}) if [ $s4 -eq $s3 ]; then err "Timestamp changed" "$s4 = $s3" fi @@ -269,7 +276,7 @@ new "Delete node" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xx2none" "" "" new "Check candidate subfile changed" -s4=$(stat -c "%Y" $dir/candidate.d/${subfilename}) +s4=$($stat -c "%Y" $dir/candidate.d/${subfilename}) if [ $s4 -eq $s3 ]; then err "Timestamp changed" "$s4 = $s3" fi @@ -289,7 +296,7 @@ check_db running ${subfilename} new "cli show config" expectpart "$($clixon_cli -1 -f $cfg show config xml -- -m clixon-mount1 -M urn:example:mount1)" 0 "xx1foo" -s0=$(stat -c "%Y" $dir/running.d/${subfilename}) +s0=$($stat -c "%Y" $dir/running.d/${subfilename}) new "Change mount data" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "xx1foo" "" "" @@ -299,7 +306,7 @@ new "netconf commit 3" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "" new "Check running subfile changed" -s1=$(stat -c "%Y" $dir/running.d/${subfilename}) +s1=$($stat -c "%Y" $dir/running.d/${subfilename}) if [ $s0 -eq $s1 ]; then err "Timestamp changed" "$s0 = $s1" fi @@ -313,7 +320,7 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" " sleep 1 new "Check running subfile not changed" -s2=$(stat -c "%Y" $dir/running.d/${subfilename}) +s2=$($stat -c "%Y" $dir/running.d/${subfilename}) if [ $s1 -ne $s2 ]; then # XXX Sometimes fails err "Timestamp not changed" "$s1 != $s2" fi diff --git a/test/test_restconf_notifications.sh b/test/test_restconf_notifications.sh index 3748e734..19870c98 100755 --- a/test/test_restconf_notifications.sh +++ b/test/test_restconf_notifications.sh @@ -146,7 +146,13 @@ function runtest() LB=$((5/${PERIOD} - 1)) UB=$((5/${PERIOD} + 1)) - time1=$(date -u -d"5 second now" +'%Y-%m-%dT%H:%M:%SZ') + + # date differs between -d and -v for declaring a later date + if [ $(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ' 2> /dev/null) ]; then + time1=$(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ') + else + time1=$(date -u -d"5 second now" +'%Y-%m-%dT%H:%M:%SZ') + fi new "2b) start $extra timeout:${TIMEOUT} stop after 5s - expect ${LB}-${UB} notifications" ret=$(curl $CURLOPTS $extra -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "Connection: keep-alive" $RCPROTO://localhost/streams/EXAMPLE?stop-time=${time1}) @@ -160,7 +166,11 @@ function runtest() fi if false; then # Does not work yet - time1=$(date -u -d"-5 second now" +'%Y-%m-%dT%H:%M:%SZ') + if [ $(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ' 2> /dev/null) ]; then + time1=$(date -u -v+5S +'%Y-%m-%dT%H:%M:%SZ') + else + time1=$(date -u -d"5 second now" +'%Y-%m-%dT%H:%M:%SZ') + fi LB=$(((5+${TIMEOUT})/${PERIOD} - 1)) UB=$(((5+${TIMEOUT})/${PERIOD} + 1)) new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications" diff --git a/test/vagrant/vagrant.sh b/test/vagrant/vagrant.sh index 8584e60a..0d560ae1 100755 --- a/test/vagrant/vagrant.sh +++ b/test/vagrant/vagrant.sh @@ -145,6 +145,7 @@ case $release in native) ;; esac + $sshcmd sudo pkg install -y coreutils # gnustat ;; centos) # enable ipv6