From aaa18897ef8ca0c7c36fabd6cb9b4d065c250a22 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 22 Jul 2022 16:57:46 +0200 Subject: [PATCH] Test: remove obsolete test_ openconfig_system Add branch with-defaults to github workflow Check in parameter in yang_extension_value --- .github/workflows/ci.yml | 4 +- lib/src/clixon_yang.c | 4 + test/README.md | 5 + test/test_openconfig_system.sh | 181 --------------------------------- 4 files changed, 11 insertions(+), 183 deletions(-) delete mode 100755 test/test_openconfig_system.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12bfbff5..361d5f3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: Clixon CI on: push: - branches: [ master, callhome ] + branches: [ master, callhome, with-defaults ] pull_request: - branches: [ master, callhome ] + branches: [ master, callhome, with-defaults ] jobs: build: diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index 27f42374..f99fc834 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -3656,6 +3656,10 @@ yang_extension_value(yang_stmt *ys, cbuf *cb = NULL; int ret; + if (ys == NULL){ + clicon_err(OE_YANG, EINVAL, "ys is NULL"); + goto done; + } if (exist) *exist = 0; if ((cb = cbuf_new()) == NULL){ diff --git a/test/README.md b/test/README.md index 2b065a30..5f9f85af 100644 --- a/test/README.md +++ b/test/README.md @@ -86,6 +86,11 @@ Run all tests but continue after errors and only print a summary test output ide sum.sh ``` +Add a detailed error print of the first test that failed, if any: +``` + detail=true sum.sh +``` + ## Memory leak test The `mem.sh` runs memory checks using valgrind. Start it with no arguments to test all components (backend, restconf, cli, netconf), or specify which components to run: ``` diff --git a/test/test_openconfig_system.sh b/test/test_openconfig_system.sh deleted file mode 100755 index 01ef7636..00000000 --- a/test/test_openconfig_system.sh +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env bash -# Run a system around openconfig interface, ie: openconfig-if-ethernet -# Note first variant uses ietf-interfaces, maybe remove this? - -# Magic line must be first in script (see README.md) -s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi - -APPNAME=example - -cfg=$dir/conf_yang.xml -fyang=$dir/clixon-example.yang - -echo "...skipped: wrong" -if [ "$s" = $0 ]; then exit 0; else return 0; fi - -new "openconfig" -if [ ! -d "$OPENCONFIG" ]; then -# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" - echo "...skipped: OPENCONFIG not set" - if [ "$s" = $0 ]; then exit 0; else return 0; fi -fi - -OCDIR=$OPENCONFIG/release/models - -# Generate autocli for these modules -AUTOCLI=$(autocli_config clixon-example kw-nokey false) - -cat < $cfg - - $cfg - ietf-netconf:startup - ${YANG_INSTALLDIR} - $OCDIR - $fyang - /usr/local/lib/$APPNAME/clispec - /usr/local/lib/$APPNAME/cli - $APPNAME - $APPNAME - /usr/local/var/$APPNAME/$APPNAME.sock - /usr/local/var/$APPNAME/$APPNAME.pidfile - $dir - ${AUTOCLI} - -EOF - -# First using ietf-interfaces (not openconfig-interfaces) -# Example yang -cat < $fyang -module clixon-example{ - yang-version 1.1; - namespace "urn:example:example"; - prefix ex; - - import openconfig-system { - prefix oc-sys; - } -} -EOF - -# Example system -cat < $dir/startup_db - - -EOF - -if [ $BE -ne 0 ]; then - new "kill old backend" - sudo clixon_backend -zf $cfg - if [ $? -ne 0 ]; then - err - fi - sudo pkill -f clixon_backend # to be sure - - new "start backend -s startup -f $cfg" - start_backend -s startup -f $cfg -fi - -new "wait backend" -wait_backend - -new "$clixon_cli -D $DBG -1f $cfg show version" -expectpart "$($clixon_cli -D $DBG -1f $cfg show version)" 0 "${CLIXON_VERSION}" - -new "$clixon_netconf -qf $cfg" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^eeex:ethfalsetrue00]]>]]>" - -new "cli show configuration" -expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "^" --not-- "" - -new "cli set interfaces interface complete: e" -expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e" - -# XXX See https://github.com/clicon/clixon/issues/218 -#new "cli set interfaces interface e complete: not ethernet" -#expectpart "$(echo "set interfaces interface e " | $clixon_cli -f $cfg)" 0 config hold-time subinterfaces --not-- ethernet - -if [ $BE -ne 0 ]; then - new "Kill backend" - # Check if premature kill - pid=$(pgrep -u root -f clixon_backend) - if [ -z "$pid" ]; then - err "backend already dead" - fi - # kill backend - stop_backend -f $cfg -fi - -# Second using openconfig-interfaces instead -# Example yang -cat < $fyang -module clixon-example{ - yang-version 1.1; - namespace "urn:example:example"; - prefix ex; - - import openconfig-vlan { - prefix oc-vlan; - } - import openconfig-if-ethernet { - prefix oc-eth; - } -} -EOF - -# Example system -cat < $dir/startup_db - - - - eth1 - - eth1 - ianaift:ethernetCsmacd - 9206 - true - oc-vlan-types:TPID_0X8100 - - - - 2c:53:4a:09:59:73 - - - - - -EOF - -if [ $BE -ne 0 ]; then - new "kill old backend" - sudo clixon_backend -zf $cfg - if [ $? -ne 0 ]; then - err - fi - sudo pkill -f clixon_backend # to be sure - - new "start backend -s startup -f $cfg" - start_backend -s startup -f $cfg -fi - -new "wait backend" -wait_backend - -new "$clixon_cli -D $DBG -1f $cfg show version" -expectpart "$($clixon_cli -D $DBG -1f $cfg show version)" 0 "${CLIXON_VERSION}" - -if [ $BE -ne 0 ]; then - new "Kill backend" - # Check if premature kill - pid=$(pgrep -u root -f clixon_backend) - if [ -z "$pid" ]; then - err "backend already dead" - fi - # kill backend - stop_backend -f $cfg -fi - - -rm -rf $dir - -new "endtest" -endtest