diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c99596d..ba2dac7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ example backend_main() and others if you need details. ### Minor changes +* YANG keywords "action" and "belongs-to" implemented by syntactically by parser (but not proper semantics). * clixon-config YAML file has new revision: 2018-10-21. * Allow new lines in CLI prompts * uri_percent_encode() and xml_chardata_encode() changed to use stdarg parameters diff --git a/Makefile.in b/Makefile.in index 84368869..178070b5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -68,12 +68,12 @@ depend: install: for i in $(SUBDIRS) doc; \ do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done; \ - echo "Install for compilation by: make install-include" + @echo "Install for compilation by: make install-include" install-include: for i in $(SUBDIRS) doc; \ do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done; \ - echo "To install example app: cd example; make; make install" + @echo "To install example app: cd example; make; make install" uninstall: for i in $(SUBDIRS) doc example docker; \ diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index e6a1ac83..778f2717 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -1738,7 +1738,7 @@ yang_parse_str(char *str, /*! Parse yang spec from an open file descriptor * @param[in] fd File descriptor containing the YANG file as ASCII characters * @param[in] name For debug, eg filename - * @param[in] ysp Yang specification. Should ave been created by caller using yspec_new + * @param[in] ysp Yang specification. Should have been created by caller using yspec_new * @retval ymod Top-level yang (sub)module * @retval NULL Error */ diff --git a/lib/src/clixon_yang_parse.y b/lib/src/clixon_yang_parse.y index 0bd24e9f..78cb172f 100644 --- a/lib/src/clixon_yang_parse.y +++ b/lib/src/clixon_yang_parse.y @@ -418,6 +418,7 @@ submodule_header_stmts : submodule_header_stmts submodule_header_stmt submodule_header_stmt : yang_version_stmt { clicon_debug(2,"submodule-header-stmt -> yang-version-stmt"); } + | belongs_to_stmt { clicon_debug(2,"submodule-header-stmt -> belongs-to-stmt"); } ; /* linkage */ @@ -1359,6 +1360,15 @@ prefix_stmt : K_PREFIX string ';' /* XXX prefix-arg-str */ clicon_debug(2,"prefix-stmt -> PREFIX string ;");} ; +belongs_to_stmt : K_BELONGS_TO id_arg_str ';' + + { if (ysp_add(_yy, Y_BELONGS_TO, $2, NULL)== NULL) _YYERROR("100"); + clicon_debug(2,"belongs-to-stmt -> BELONGS-TO id-arg-str ;");} + | K_BELONGS_TO id_arg_str '{' prefix_stmt '}' + { if (ysp_add(_yy, Y_BELONGS_TO, $2, NULL)== NULL) _YYERROR("98"); + clicon_debug(2,"belongs-to-stmt -> BELONGS-TO id-arg-str { prefix-stmt } ");} + ; + description_stmt: K_DESCRIPTION string ';' { if (ysp_add(_yy, Y_DESCRIPTION, $2, NULL)== NULL) _YYERROR("101"); clicon_debug(2,"description-stmt -> DESCRIPTION string ;");} diff --git a/test/test_stream.sh b/test/test_stream.sh index 94becf7e..66f5414d 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -54,10 +54,12 @@ cat < $cfg streams https://localhost 60 - http://localhost/pub EOF +# For nchan testing add this line to above config +# http://localhost/pub + # RFC5277 NETCONF Event Notifications # using reportingEntity (rfc5277) not reporting-entity (rfc8040) cat < $fyang @@ -261,6 +263,7 @@ fi #-------------------------------------------------------------------- # NCHAN Need manual testing echo "Nchan streams requires manual testing" +echo "Add http://localhost/pub to config" echo "Eg: curl -H \"Accept: text/event-stream\" -s -X GET http://localhost/sub/EXAMPLE" #----------------- diff --git a/test/test_yang_parse.sh b/test/test_yang_parse.sh index c8f0f34d..9cc52da2 100755 --- a/test/test_yang_parse.sh +++ b/test/test_yang_parse.sh @@ -1,7 +1,9 @@ #!/bin/bash # Test: YANG parser tests +# First an example yang, second all openconfig yangs #PROG="valgrind --leak-check=full --show-leak-kinds=all ../util/clixon_util_yang" PROG=../util/clixon_util_yang +OPENCONFIG=~/syssrc/openconfig # include err() and new() functions and creates $dir . ./lib.sh @@ -13,13 +15,28 @@ module test{ description "Example from RFC 6020"; argument "name"; } - ex:not-defined ARGUMENT;; + ex:not-defined ARGUMENT; } EOF ) new "yang parse" -expecteof "$PROG" 0 "$YANG" "^$YANG$" +#expecteof "$PROG" 0 "$YANG" "^$YANG$" +if [ ! -d $OPENCONFIG ]; then + echo "$OPENCONFIG not found. Do git clone https://github.com/openconfig/public and point DIR to it to run these tests" + rm -rf $dir + exit 0 +fi + +# Openconfig +new "Openconfig" +files=$(find $OPENCONFIG -name "*.yang") +for f in $files; do + new "$f" + YANG=$(cat $f) + # expecteof "$PROG" 0 "$YANG" "module" +done rm -rf $dir + diff --git a/util/Makefile.in b/util/Makefile.in index 22edf3d1..4814e91a 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -75,7 +75,7 @@ APPSRC += clixon_util_xpath.c APPS = $(APPSRC:.c=) all: $(APPS) - echo "You may want to make clixon_util_stream separately (curl dependency)" + @echo "You may want to make clixon_util_stream separately (curl dependency)" clean: rm -f $(APPS) *.core diff --git a/util/clixon_util_yang.c b/util/clixon_util_yang.c index 22847b0d..9ebe991f 100644 --- a/util/clixon_util_yang.c +++ b/util/clixon_util_yang.c @@ -78,10 +78,11 @@ main(int argc, char **argv) usage(argv[0]); return -1; } + clicon_log_init("clixon_util_yang", LOG_INFO, CLICON_LOG_STDERR); if ((yspec = yspec_new()) == NULL) goto done; - if (yang_parse_file(0, "yang test", yspec) < 0){ - fprintf(stderr, "xml parse error %s\n", clicon_err_reason); + if (yang_parse_file(0, "yang test", yspec) == NULL){ + fprintf(stderr, "yang parse error %s\n", clicon_err_reason); return -1; } yang_print(stdout, (yang_node*)yspec);