Skip to content

Commit

Permalink
Fixed: [Clixon handle if-feature incorrectly](#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Sep 21, 2024
1 parent 3108dfc commit 6a634ef
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Developers may need to change their code

### Corrected Busg

* Fixed: [Clixon handle if-feature incorrectly](https://github.com/clicon/clixon/issues/555)
* Fixed: [Clixon fails to load yang with extension](https://github.com/clicon/clixon/issues/554)
* Fixed: Double top-levels in xmldb_get that could occur with xpath containing choice.
* Fixed: [RESTCONF exit on cert error + complex accept](https://github.com/clicon/clixon/issues/551)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/clixon_yang_parse_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ yang_augment_node(clixon_handle h,
yang_argument_get(yc0),
yang_key2str(childkey),
schema_nodeid);
goto ok;
continue;
}
break;
case Y_CASE:
Expand Down
104 changes: 104 additions & 0 deletions test/test_augment_if_feature.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
# Combined augment and if-feature
# See https://github.com/clicon/clixon/issues/555
#
# 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/shelf-slot-test.yang

cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/run/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/run/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_YANG_LIBRARY>true</CLICON_YANG_LIBRARY>
</clixon-config>
EOF

cat <<EOF > $fyang
module shelf-slot-test {
namespace "urn:example:shelf-slot-test";
prefix shelf-slot-test;
revision 2024-09-17 {
description "test";
}
container config {
}
augment /config {
container system {
}
}
feature enable-shelf {
description "enable shelf";
}
augment /config/system {
list shelf {
// This breaks clixon!
if-feature shelf-slot-test:enable-shelf;
key location;
description "location of the shelf";
leaf location {
type string;
}
}
list slot {
key location;
description "location of the slot";
leaf location {
type string;
}
}
}
augment '/config/system/slot' {
leaf v1 {
type int32;
}
}
}
EOF

new "test params: -f $cfg"

if [ $BE -ne 0 ]; then
new "kill old backend"
sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then
err
fi
new "start backend -s init -f $cfg"
start_backend -s init -f $cfg
fi

new "wait backend"
wait_backend


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

0 comments on commit 6a634ef

Please sign in to comment.