├── .github └── workflows │ └── test.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── bin └── yanger ├── c_src ├── Makefile ├── w3cregex_nif.c ├── yang_atom.c ├── yang_atom.h ├── yang_core_grammar.c ├── yang_core_grammar.h ├── yang_error.c ├── yang_error.h ├── yang_grammar.c ├── yang_grammar.h ├── yang_if_feature.c ├── yang_if_feature.h ├── yang_parser.c ├── yang_parser.h └── yang_parser_nif.c ├── ebin └── .gitkeep ├── env.sh ├── include └── yang.hrl ├── modules ├── ietf-inet-types.yang ├── ietf-restconf.yang ├── ietf-yang-smiv2.yang ├── ietf-yang-structure-ext.yang └── ietf-yang-types.yang ├── plugins ├── Makefile ├── yanger_depend.erl ├── yanger_expand.erl ├── yanger_restconf.erl ├── yanger_smiv2.erl ├── yanger_sn.erl ├── yanger_structure.erl ├── yanger_swagger.erl ├── yanger_tree.erl ├── yanger_yang.erl └── yanger_yin.erl ├── priv └── .gitkeep ├── src ├── Makefile ├── getopt.erl ├── mk_llerror.awk ├── mk_llerror_hrl.awk ├── w3cregex.erl ├── xpath_bif.erl ├── xpath_error.erl ├── xpath_parse.yrl ├── xpath_rewrite.erl ├── xpath_scan.erl ├── yang.erl ├── yang_error.erl ├── yang_if_feature.erl ├── yang_llerror.hrl ├── yang_parser.erl ├── yang_types.erl ├── yang_xpath.erl ├── yanger.app.src ├── yanger.erl └── yanger_plugin.erl ├── test ├── Makefile ├── eunit │ ├── Makefile │ ├── deviation_update_modules_tests.erl │ ├── eng25448_tests.erl │ ├── subm.yang │ └── test_support.erl ├── lux │ ├── ENG-23621-leafref-has-invalid-path │ │ ├── Makefile │ │ ├── run.lux │ │ └── test.yang │ ├── ENG-24068-submodule-post-expand-leafref │ │ ├── Makefile │ │ ├── run.lux │ │ ├── subtarget.yang │ │ ├── subtest.yang │ │ └── test.yang │ ├── Makefile │ ├── any-must │ │ ├── Makefile │ │ ├── any.yang │ │ └── run.lux │ ├── augment-bug │ │ ├── Makefile │ │ ├── bbf-qos-shaping.yang │ │ ├── bbf-qos-traffic-mngt.yang │ │ ├── bbf-qos-types.yang │ │ ├── bbf-yang-types.yang │ │ ├── ietf-interfaces.yang │ │ └── shaping.lux │ ├── bad │ │ ├── Makefile │ │ ├── aug-mand.yang │ │ ├── aug-miss.yang │ │ ├── aug-oper-mand.yang │ │ ├── bad-augment-node.yang │ │ ├── bad-date.yang │ │ ├── bad-union.yang │ │ ├── bad1.yang │ │ ├── basic.lux │ │ ├── clr.yang │ │ ├── config.yang │ │ ├── eb.yang │ │ ├── eb11.yang │ │ ├── eb11f.yang │ │ ├── gen_lux.sh │ │ ├── grouping.yang │ │ ├── h.yang │ │ ├── lldef1.yang │ │ ├── lldef2.yang │ │ ├── lref.yang │ │ ├── ltgt.yang │ │ ├── new.yang │ │ ├── new2.yang │ │ ├── new3.yang │ │ ├── no-feat-enum-bit.yang │ │ ├── no-feat-ref-ext.yang │ │ ├── no-feat-ref.yang │ │ ├── quoted-string-1.0.yang │ │ ├── quoted-string-1.1.yang │ │ ├── rev.yang │ │ ├── smiv2.yang │ │ ├── t.yang │ │ ├── test_sec_6_1 │ │ │ ├── Makefile │ │ │ ├── mod1.yang │ │ │ ├── mod2.yang │ │ │ └── run.lux │ │ ├── tmust.yang │ │ ├── typo.yang │ │ ├── uses.yang │ │ ├── xpathref.yang │ │ ├── xt1.yang │ │ ├── xt1s1.yang │ │ ├── xt1s2.yang │ │ ├── xt2.yang │ │ └── xt3.yang │ ├── cmdline │ │ ├── Makefile │ │ ├── warnings.lux │ │ └── warnings.yang │ ├── conformance │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b.yang │ │ ├── c.yang │ │ └── run.lux │ ├── depend │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b.yang │ │ ├── c.yang │ │ ├── d.yang │ │ ├── e.yang │ │ ├── f.yang │ │ ├── g.yang │ │ └── run.lux │ ├── deviations │ │ ├── Makefile │ │ ├── a.yang │ │ ├── asub.yang │ │ ├── aug-dev-mand.lux │ │ ├── aug-dev-mand.yang │ │ ├── b.yang │ │ ├── bad-mand-augment.lux │ │ ├── bad.lux │ │ ├── bad.yang │ │ ├── choice-def-case-chg.yang │ │ ├── choice-def-case-dev.yang │ │ ├── choice-def-case-rem.yang │ │ ├── choice-def-case.yang │ │ ├── dev-def-case.lux │ │ ├── dev-key.lux │ │ ├── dev-type-xpath.lux │ │ ├── dev-type-xpath.yang │ │ ├── dev.yang │ │ ├── dt-dev.yang │ │ ├── dt.yang │ │ ├── list-dev.yang │ │ ├── list.yang │ │ ├── run.lux │ │ ├── simple.yang │ │ ├── test-a.yang │ │ ├── test-dev-mand.yang │ │ └── test.yang │ ├── eng-25448_deviated_type_scope │ │ ├── Makefile │ │ ├── cli-server.yang │ │ ├── ietf-tcp-common.yang │ │ ├── ietf-tcp-server.yang │ │ └── run.lux │ ├── eng16248 │ │ ├── Makefile │ │ ├── a-aug-dev.yang │ │ ├── a-aug.yang │ │ ├── a.yang │ │ └── run.lux │ ├── eng17483 │ │ ├── Makefile │ │ ├── a-aug-dev.yang │ │ ├── a-aug.yang │ │ ├── a.yang │ │ ├── b.yang │ │ └── run.lux │ ├── eng17783 │ │ ├── Makefile │ │ ├── run.lux │ │ └── test.yang │ ├── eng18062 │ │ ├── Makefile │ │ ├── run.lux │ │ ├── x-base.yang │ │ ├── x-foo.yang │ │ ├── x-point.yang │ │ ├── x-prof.yang │ │ └── x.yang │ ├── eng21093 │ │ ├── Makefile │ │ ├── a-dev.yang │ │ ├── a-dev2.yang │ │ ├── a.yang │ │ └── run.lux │ ├── eng21900-typedef-leafref-points-to-disabled-node │ │ ├── ENG-21900-1.yang │ │ ├── ENG-21900-2.yang │ │ ├── Makefile │ │ └── run.lux │ ├── expand │ │ ├── Makefile │ │ ├── a.yang │ │ ├── bar-sub1.yang │ │ ├── bar.yang │ │ ├── foo.yang │ │ ├── foo2.yang │ │ ├── grp2.yang │ │ ├── identity.lux │ │ ├── minmax.lux │ │ ├── minmax.yang │ │ ├── nocrash.lux │ │ └── q.yang │ ├── features │ │ ├── Makefile │ │ ├── f.yang │ │ ├── g.yang │ │ └── run.lux │ ├── groupings │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b.yang │ │ └── run.lux │ ├── internal │ │ ├── Makefile │ │ ├── mksn.erl │ │ ├── mksn.lux │ │ ├── mksn.yang │ │ └── y.yang │ ├── invalidate_default │ │ ├── Makefile │ │ ├── dev.yang │ │ ├── deviated.yang │ │ └── run.lux │ ├── max_status │ │ ├── Makefile │ │ ├── a.yang │ │ └── run.lux │ ├── max_status_aug │ │ ├── Makefile │ │ ├── a-aug.yang │ │ ├── a.yang │ │ └── run.lux │ ├── prefix │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b.yang │ │ ├── c.yang │ │ └── run.lux │ ├── refine │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b.yang │ │ ├── bad.yang │ │ ├── ref.yang │ │ └── refine.lux │ ├── rev-clash │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b.yang │ │ ├── run.lux │ │ ├── run.lux~ │ │ ├── types@2010-09-24.yang │ │ └── types@2013-07-15.yang │ ├── structure │ │ ├── Makefile │ │ ├── a.yang │ │ └── run.lux │ ├── swagger │ │ ├── Makefile │ │ ├── README │ │ ├── escape.yang │ │ ├── example-jukebox-extended.yang │ │ ├── example-jukebox.yang │ │ ├── new.yang │ │ ├── run.lux │ │ ├── simple.yang │ │ ├── types-1.1.yang │ │ └── types.yang │ ├── tr13995 │ │ ├── Makefile │ │ ├── gen_lux.sh │ │ ├── test-config-leafref.yang │ │ └── test.yang │ ├── tr14212 │ │ ├── Makefile │ │ ├── run.lux │ │ ├── x.yang │ │ └── y.yang │ ├── tr14349 │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b-sub1.yang │ │ ├── b-sub2.yang │ │ ├── b.yang │ │ ├── c.yang │ │ ├── esc.yang │ │ ├── example-ok.yang │ │ ├── example.yang │ │ ├── run.lux │ │ └── tailf-ncx.yang │ ├── tr15882 │ │ ├── Makefile │ │ ├── run.lux │ │ └── x.yang │ ├── tr16082 │ │ ├── Makefile │ │ ├── a.yang │ │ └── run.lux │ ├── tree │ │ ├── Makefile │ │ ├── a.yang │ │ ├── ietf-snmp-cfg │ │ │ ├── ietf-snmp-common.yang │ │ │ ├── ietf-snmp-community.yang │ │ │ ├── ietf-snmp-engine.yang │ │ │ ├── ietf-snmp-notification.yang │ │ │ ├── ietf-snmp-proxy.yang │ │ │ ├── ietf-snmp-ssh.yang │ │ │ ├── ietf-snmp-target.yang │ │ │ ├── ietf-snmp-tls.yang │ │ │ ├── ietf-snmp-tsm.yang │ │ │ ├── ietf-snmp-usm.yang │ │ │ ├── ietf-snmp-vacm.yang │ │ │ ├── ietf-snmp.yang │ │ │ └── ietf-x509-cert-to-name.yang │ │ ├── parent.yang │ │ ├── small2.yang │ │ ├── small3.yang │ │ ├── small4.yang │ │ ├── small5.yang │ │ ├── small6.lux │ │ ├── small6.yang │ │ ├── sx.lux │ │ ├── sx.yang │ │ ├── tree_plugin_macro.lux │ │ ├── x-sub.yang │ │ └── x.yang │ ├── xpath-in-augment │ │ ├── Makefile │ │ ├── a.yang │ │ ├── b.yang │ │ └── run.lux │ ├── yang-1.1 │ │ ├── Makefile │ │ ├── aug-oper-mand.yang │ │ ├── aug-when-mand.yang │ │ ├── basic.lux │ │ ├── enum-and-bit.yang │ │ ├── gen_lux.sh │ │ ├── impinc.yang │ │ ├── impincyv.yang │ │ ├── impyv1.yang │ │ ├── impyv2.yang │ │ ├── incsub.yang │ │ ├── incsubyv1.yang │ │ ├── incsubyv2.yang │ │ ├── new.yang │ │ ├── u.yang │ │ ├── uimp.yang │ │ └── usub.yang │ └── yin │ │ ├── Makefile │ │ ├── parent.yang │ │ ├── small6.yang │ │ ├── test_good │ │ ├── a.yang │ │ ├── b.yang │ │ ├── q.yang │ │ ├── qs.yang │ │ ├── w.yang │ │ ├── xt10.yang │ │ ├── xt5.yang │ │ ├── xt6.yang │ │ ├── xt7.yang │ │ ├── yt10.yang │ │ ├── yt5.yang │ │ ├── yt6.yang │ │ ├── yt7.yang │ │ ├── yt8.yang │ │ └── yt9.yang │ │ ├── test_tailf_info │ │ ├── config.yang │ │ ├── tailf-cli-extensions.yang │ │ ├── tailf-common.yang │ │ └── tailf-meta-extensions.yang │ │ ├── yin_plugin_macro.lux │ │ ├── yin_plugin_macro_cannoical.lux │ │ └── yin_plugin_macro_pretty_strings.lux └── support │ ├── eunit.mk │ ├── lux_testarea.mk │ └── lux_testcases.mk └── vsn.mk /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | on: push 2 | 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | name: OTP ${{matrix.otp}} 7 | strategy: 8 | matrix: 9 | otp: ['24', '25', '26'] 10 | steps: 11 | - uses: actions/checkout@v3 12 | 13 | - uses: erlef/setup-beam@v1 14 | with: 15 | otp-version: ${{matrix.otp}} 16 | 17 | - name: Prepare prerequisites 18 | run: sudo apt-get update 19 | 20 | - name: Install prerequisites 21 | run: sudo apt-get install libxml2-dev python3 python3-pip 22 | 23 | - name: Install pyang 24 | run: | 25 | pip3 install pyang 26 | 27 | - name: Install lux 28 | run: | 29 | git clone https://github.com/hawk/lux.git 30 | cd lux 31 | autoconf 32 | ./configure 33 | make 34 | 35 | - name: Run tests 36 | run: | 37 | export PATH=$PATH:$(pwd)/lux/bin 38 | source env.sh 39 | make 40 | make test 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .eunit 2 | deps 3 | priv 4 | *.o 5 | *.so 6 | *.beam 7 | *.plt 8 | src/yang_llerror.erl 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM erlang:23-alpine 2 | 3 | # src/Makefile expects parent directory to be called yanger 4 | ARG YANGER_LOCATION=/yanger 5 | ENV PATH="${YANGER_LOCATION}/bin:${PATH}" 6 | ENV YANG_MODPATH="${YANGER_LOCATION}/modules" 7 | 8 | WORKDIR ${YANGER_LOCATION} 9 | COPY ./ ${YANGER_LOCATION} 10 | 11 | # -virtual used to remove build deps as part of single layer, keep image small 12 | RUN set -xe \ 13 | && apk add --no-cache coreutils libxml2-dev \ 14 | && apk add --no-cache --virtual build-dependencies make gcc libc-dev \ 15 | && make clean all \ 16 | && apk del build-dependencies 17 | 18 | # reset workdir, user should mount their local files to this directory 19 | WORKDIR /workdir 20 | 21 | ENTRYPOINT ["yanger"] 22 | CMD ["-h"] -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS = c_src src plugins 2 | 3 | all: 4 | @set -e ; \ 5 | for d in $(SUBDIRS) ; do \ 6 | if [ -f $$d/Makefile ]; then \ 7 | ( cd $$d && $(MAKE) ) || exit 1 ; \ 8 | fi ; \ 9 | done 10 | 11 | clean: $(LOCALCLEAN) 12 | @set -e ; \ 13 | for d in $(SUBDIRS) ; do \ 14 | if [ -f $$d/Makefile ]; then \ 15 | ( cd $$d && $(MAKE) $@ ) || exit 1 ; \ 16 | fi ; \ 17 | done 18 | 19 | include vsn.mk 20 | dialyzer: 21 | dialyzer -DVSN=\"$(VSN)\" -pa ../yanger/ebin --src src/*.erl 22 | 23 | # requires 'lux' in the PATH (https://github.com/hawk/lux) 24 | # the tree test requires 'pyang' (https://github.com/mbj4668/pyang) 25 | # checked out next to 'yanger' and in the PATH 26 | test: 27 | (cd test; $(MAKE)) 28 | .PHONY: test 29 | -------------------------------------------------------------------------------- /bin/yanger: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env escript 2 | %% -*- erlang -*- 3 | %%! -noinput 4 | 5 | main(Args) -> 6 | ScriptName = script_name(), 7 | code:add_patha(ebin(ScriptName)), 8 | yanger:main(name(ScriptName), Args). 9 | 10 | ebin(ScriptName) -> 11 | %% The escript is located in .../yanger/bin 12 | AppDir = filename:dirname(filename:dirname(ScriptName)), 13 | filename:join(AppDir, "ebin"). 14 | 15 | name(ScriptName) -> 16 | filename:basename(ScriptName). 17 | 18 | script_name() -> 19 | script_name(escript:script_name()). 20 | 21 | script_name([$/|_] = Name0) -> 22 | case file:read_link(Name0) of 23 | {ok, [$/|_] = Name} -> 24 | Name; 25 | {ok, RelName} -> 26 | script_name(filename:join(filename:dirname(Name0), RelName)); 27 | _ -> 28 | %% there may still be symlink components 29 | {ok, Cwd} = file:get_cwd(), 30 | ok = file:set_cwd(filename:dirname(Name0)), 31 | {ok, Dir} = file:get_cwd(), 32 | ok = file:set_cwd(Cwd), 33 | filename:join(Dir, filename:basename(Name0)) 34 | end; 35 | script_name(RelName) -> 36 | script_name(filename:absname(RelName)). 37 | -------------------------------------------------------------------------------- /c_src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PARSER_NIF = ../priv/yang_parser_nif.so 3 | REGEX_NIF = ../priv/w3cregex_nif.so 4 | 5 | PRIV_FILES = $(PARSER_NIF) $(REGEX_NIF) 6 | 7 | CFLAGS = -std=c99 8 | CWARNINGS = \ 9 | -Werror \ 10 | -Wall \ 11 | -Wsign-compare \ 12 | -Wstrict-prototypes \ 13 | -Wpointer-arith \ 14 | -Wcast-align \ 15 | -Wwrite-strings \ 16 | -Wnested-externs 17 | 18 | CFLAGS += -fpic -DDYNAMIC_DRIVER 19 | 20 | ifneq ($(DEBUG),) 21 | CFLAGS += -g -ggdb 22 | CWARNINGS += -Wuninitialized 23 | ERLC_FLAGS += +debug_info 24 | else 25 | CFLAGS += -O2 26 | endif 27 | 28 | CFLAGS += $(CWARNINGS) 29 | 30 | ERL_EVAL = 'io:format("~s", [os:getenv("ROOTDIR")]), erlang:halt(0)' 31 | ERL_ROOTDIR = $(shell erl -noinput -eval $(ERL_EVAL)) 32 | ifneq ($(findstring /, $(ERL_ROOTDIR)),) 33 | CFLAGS += -I$(ERL_ROOTDIR)/usr/include 34 | endif 35 | 36 | XML_CFLAGS ?= $(shell pkg-config --cflags libxml-2.0) 37 | ifeq ($(XML_CFLAGS),) 38 | XML_CFLAGS = -I/usr/include/libxml2 39 | endif 40 | CFLAGS += $(XML_CFLAGS) 41 | XML_LIBS = $(shell pkg-config --libs libxml-2.0) 42 | ifeq ($(XML_LIBS),) 43 | XML_LIBS = -lxml2 44 | endif 45 | LIBS += $(XML_LIBS) 46 | 47 | LD = $(CC) 48 | 49 | ifeq ($(shell uname -s), Darwin) 50 | LDDRV_FLAGS = -bundle -undefined dynamic_lookup 51 | else 52 | LDDRV_FLAGS = -shared 53 | endif 54 | 55 | 56 | C_SOURCES := $(wildcard yang*.c) 57 | C_HEADERS := $(wildcard yang*.h) 58 | OBJS := $(C_SOURCES:%.c=./%.o) 59 | 60 | all: $(PRIV_FILES) 61 | 62 | $(OBJS): $(C_HEADERS) 63 | 64 | $(PARSER_NIF): $(OBJS) 65 | $(LD) $(LDDRV_FLAGS) -o $@ $^ $(LIBS) 66 | 67 | $(REGEX_NIF): w3cregex_nif.o 68 | $(LD) $(LDDRV_FLAGS) -o $@ $^ $(LIBS) 69 | 70 | debug: 71 | $(MAKE) DEBUG=true all 72 | 73 | # Keep .o file around (handy when gdb debugging...) 74 | .PRECIOUS: $(OBJS) 75 | 76 | clean: 77 | rm -f ../priv/*.so ./*.so ./*.o *.o 78 | -------------------------------------------------------------------------------- /c_src/yang_atom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "yang_atom.h" 6 | 7 | #define NATOMS 29989 8 | 9 | struct bucket { 10 | yang_atom_t atom; 11 | int len; 12 | struct bucket *next; 13 | }; 14 | 15 | static struct bucket *atom_table[NATOMS]; 16 | 17 | static unsigned long 18 | hash(const char *str, int len) 19 | { 20 | unsigned long hash = 5381; 21 | int i; 22 | 23 | for (i = 0; i < len; i++) { 24 | hash = ((hash << 5) + hash) + str[i]; 25 | } 26 | return hash; 27 | } 28 | 29 | yang_atom_t 30 | yang_make_atom_len(const char *str, int len) 31 | { 32 | unsigned long h; 33 | int idx; 34 | struct bucket *p; 35 | 36 | h = hash(str, len); 37 | idx = h % NATOMS; 38 | for (p = atom_table[idx]; p != NULL; p = p->next) { 39 | if (p->len == len && 40 | strncmp(str, p->atom, len) == 0) { 41 | return p->atom; 42 | } 43 | } 44 | p = (struct bucket *)malloc(sizeof(struct bucket)); 45 | p->atom = (yang_atom_t)malloc(sizeof(char) * (len + 1)); 46 | strncpy(p->atom, str, len); 47 | p->atom[len] = '\0'; 48 | p->len = len; 49 | p->next = atom_table[idx]; 50 | atom_table[idx] = p; 51 | return p->atom; 52 | } 53 | 54 | yang_atom_t 55 | yang_make_atom(const char *str) 56 | { 57 | return yang_make_atom_len(str, strlen(str)); 58 | } 59 | 60 | int 61 | yang_is_atom_len(const char *str, int len) 62 | { 63 | unsigned long h; 64 | int idx; 65 | struct bucket *p; 66 | 67 | h = hash(str, len); 68 | idx = h % NATOMS; 69 | for (p = atom_table[idx]; p != NULL; p = p->next) { 70 | if (p->atom == (yang_atom_t)str) { 71 | return 1; 72 | } 73 | } 74 | return 0; 75 | } 76 | 77 | int 78 | yang_is_atom(const char *str) 79 | { 80 | return yang_is_atom_len(str, strlen(str)); 81 | } 82 | 83 | void 84 | yang_print_atom_table(void) 85 | { 86 | int i; 87 | struct bucket *p; 88 | 89 | for (i = 0; i < NATOMS; i++) { 90 | for (p = atom_table[i]; p != NULL; p = p->next) { 91 | printf("atom: %s\n", p->atom); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /c_src/yang_atom.h: -------------------------------------------------------------------------------- 1 | #ifndef _yang_atom_h 2 | #define _yang_atom_h 3 | 4 | typedef char *yang_atom_t; 5 | 6 | #define yang_atom_to_str(a) ((char*)(a)) 7 | 8 | extern yang_atom_t yang_make_atom_len(const char *str, int len); 9 | extern yang_atom_t yang_make_atom(const char *str); 10 | extern int yang_is_atom_len(const char *str, int len); 11 | extern int yang_is_atom(const char *str); 12 | extern void yang_print_atom_table(void); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /c_src/yang_core_grammar.h: -------------------------------------------------------------------------------- 1 | #ifndef _yang_core_grammar_h 2 | #define _yang_core_grammar_h 3 | 4 | extern int yang_init_core_stmt_grammar(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /c_src/yang_error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "yang_error.h" 5 | #include "yang_parser.h" 6 | 7 | 8 | struct yang_error_ctx * 9 | yang_alloc_err_ctx(void) 10 | { 11 | struct yang_error_ctx *ectx; 12 | 13 | ectx = (struct yang_error_ctx *)malloc(sizeof(struct yang_error_ctx)); 14 | if (!ectx) { 15 | return NULL; 16 | } 17 | ectx->err = NULL; 18 | return ectx; 19 | } 20 | 21 | void 22 | yang_free_err_ctx(struct yang_error_ctx *ectx) 23 | { 24 | struct yang_error *p, *tmp; 25 | 26 | p = ectx->err; 27 | while (p) { 28 | tmp = p; 29 | p = p->next; 30 | free(tmp); 31 | } 32 | free(ectx); 33 | } 34 | 35 | static struct yang_error * 36 | add_err(struct yang_error_ctx *ectx) 37 | { 38 | struct yang_error *err; 39 | 40 | err = (struct yang_error *)malloc(sizeof(struct yang_error)); 41 | if (!err) { 42 | fprintf(stderr, "failed to allocate %ld bytes for error report", 43 | (long int)sizeof(struct yang_error)); 44 | return NULL; 45 | } 46 | err->next = ectx->err; 47 | ectx->err = err; 48 | return err; 49 | } 50 | 51 | void 52 | yang_add_err_gen(struct yang_error_ctx *ectx, 53 | int code, 54 | const char *filename, 55 | int line, 56 | int col, 57 | const char *fmt, ...) 58 | { 59 | va_list args; 60 | struct yang_error *err; 61 | 62 | err = add_err(ectx); 63 | if (!err) { 64 | return; 65 | } 66 | 67 | err->code = code; 68 | err->filename = filename; 69 | err->line = line; 70 | err->col = col; 71 | 72 | va_start(args, fmt); 73 | vsnprintf(err->msg, sizeof(err->msg), fmt, args); 74 | va_end(args); 75 | } 76 | 77 | void 78 | yang_add_err(struct yang_error_ctx *ectx, 79 | int code, 80 | struct yang_statement *stmt, 81 | const char *fmt, ...) 82 | { 83 | va_list args; 84 | struct yang_error *err; 85 | 86 | err = add_err(ectx); 87 | if (!err) { 88 | return; 89 | } 90 | 91 | err->code = code; 92 | err->filename = stmt->filename; 93 | err->line = stmt->line; 94 | err->col = -1; 95 | 96 | va_start(args, fmt); 97 | vsnprintf(err->msg, sizeof(err->msg), fmt, args); 98 | va_end(args); 99 | } 100 | 101 | void 102 | yang_add_alloc_err(struct yang_error_ctx *ectx, 103 | int nbytes) 104 | { 105 | yang_add_err_gen(ectx, YANG_ERR_MEMORY_ERROR, NULL, 0, 0, 106 | "failed to allocate %d bytes of memory", nbytes); 107 | } 108 | -------------------------------------------------------------------------------- /c_src/yang_error.h: -------------------------------------------------------------------------------- 1 | #ifndef _yang_error_h 2 | #define _yang_error_h 3 | 4 | #include 5 | 6 | #define YANG_FIRST_WARNING 1000 7 | 8 | #define YANG_ERR_INTERNAL 1 9 | #define YANG_ERR_MEMORY_ERROR 2 10 | 11 | #define YANG_ERR_PARSE_EOF 100 12 | #define YANG_ERR_PARSE_FOPEN 102 13 | #define YANG_ERR_PARSE_BAD_KEYWORD 103 14 | #define YANG_ERR_PARSE_EXPECTED_SEPARATOR 104 15 | #define YANG_ERR_PARSE_EXPECTED_STRING 105 16 | #define YANG_ERR_PARSE_INCOMPLETE_STATEMENT 106 17 | #define YANG_ERR_PARSE_EXPECTED_QUOTED_STRING 107 18 | #define YANG_ERR_PARSE_TRAILING_GARBAGE 108 19 | #define YANG_ERR_PARSE_ILLEGAL_ESCAPE 109 20 | 21 | #define YANG_WARN_PARSE_ILLEGAL_ESCAPE 1000 22 | 23 | #define YANG_ERR_GRAMMAR_KEYWORD_ALREADY_FOUND 200 24 | #define YANG_ERR_GRAMMAR_EXPECTED_KEYWORD 201 25 | #define YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 202 26 | #define YANG_ERR_GRAMMAR_UNDEFINED_PREFIX 203 27 | #define YANG_ERR_GRAMMAR_DUPLICATE_PREFIX 204 28 | #define YANG_ERR_GRAMMAR_MISSING_ARGUMENT 205 29 | #define YANG_ERR_GRAMMAR_UNEXPECTED_ARGUMENT 206 30 | #define YANG_ERR_GRAMMAR_BAD_ARGUMENT 207 31 | 32 | struct yang_statement; 33 | 34 | struct yang_error { 35 | int code; 36 | const char *filename; 37 | int line; 38 | int col; 39 | char msg[BUFSIZ]; 40 | struct yang_error *next; 41 | }; 42 | 43 | struct yang_error_ctx { 44 | struct yang_error *err; 45 | }; 46 | 47 | extern struct yang_error_ctx *yang_alloc_err_ctx(void); 48 | extern void yang_free_err_ctx(struct yang_error_ctx *ectx); 49 | 50 | extern void yang_add_err_gen(struct yang_error_ctx *ectx, 51 | int code, 52 | const char *filename, 53 | int line, 54 | int col, 55 | const char *fmt, ...); 56 | extern void yang_add_err(struct yang_error_ctx *ectx, 57 | int code, 58 | struct yang_statement *stmt, 59 | const char *fmt, ...); 60 | extern void yang_add_alloc_err(struct yang_error_ctx *ectx, 61 | int nbytes); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /c_src/yang_if_feature.h: -------------------------------------------------------------------------------- 1 | #ifndef _yang_if_feature_h 2 | #define _yang_if_feature_h 3 | 4 | #include 5 | 6 | extern bool 7 | yang_parse_if_feature_expr(char *str); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /c_src/yang_parser.h: -------------------------------------------------------------------------------- 1 | #ifndef _yang_parser_h 2 | #define _yang_parser_h 3 | 4 | #include 5 | 6 | #include "yang_atom.h" 7 | #include "yang_error.h" 8 | 9 | #define YANG_VERSION_1 1 10 | #define YANG_VERSION_1_1 2 11 | 12 | struct yang_statement; 13 | 14 | #define F_ARG_TYPE_SYNTAX_REGEXP (1 << 0) 15 | #define F_ARG_TYPE_SYNTAX_CB (1 << 1) 16 | 17 | struct yang_arg_type { 18 | yang_atom_t name; 19 | union { 20 | char *xsd_regexp; 21 | struct { 22 | bool (*validate)(char *arg, void *opaque, char yang_version, 23 | char *errbuf, int sz); 24 | void *opaque; /* any data needed by the validate function */ 25 | } cb; 26 | } syntax; 27 | /* if none of F_ARG_TYPE_SYNTAX_CB and F_ARG_TYPE_SYNTAX_REGEXP is 28 | set, no validation of the argument is done */ 29 | unsigned int flags; 30 | }; 31 | 32 | struct yang_statement { 33 | /* NULL | prefix of keyword */ 34 | yang_atom_t prefix; 35 | /* NULL | name of module from which keyword is imported */ 36 | yang_atom_t module_name; /* filled in by grammar check */ 37 | yang_atom_t keyword; 38 | char *arg; 39 | struct yang_arg_type *arg_type; /* filled in by grammar check */ 40 | /* yang-version of the module where this statement is defined */ 41 | char yang_version; /* filled in by grammar check */ 42 | char *filename; 43 | int line; 44 | struct yang_statement *next; 45 | struct yang_statement *substmt; 46 | }; 47 | 48 | extern bool yang_init_parser(void); 49 | 50 | extern bool yang_parse(char *filename, 51 | struct yang_statement **stmt, 52 | struct yang_error_ctx *ectx); 53 | extern void yang_free_tree(struct yang_statement *stmt); 54 | extern void yang_free_statement(struct yang_statement *stmt); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /ebin/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # source this file to get environment setup for the 4 | # yanger below here 5 | 6 | p=`pwd` 7 | export PATH=$p/bin:$PATH 8 | export YANG_MODPATH=$p/modules:$YANG_MODPATH 9 | export W=$p 10 | -------------------------------------------------------------------------------- /plugins/Makefile: -------------------------------------------------------------------------------- 1 | include ../vsn.mk 2 | 3 | ERL_SOURCES := $(wildcard *.erl) 4 | ERL_OBJECTS := $(ERL_SOURCES:%.erl=../priv/%.beam) 5 | 6 | ERLC_FLAGS += -pa ../../yanger/ebin -Werror 7 | 8 | ERLC ?= erlc 9 | 10 | all: $(ERL_OBJECTS) 11 | 12 | debug: 13 | $(MAKE) TYPE=debug 14 | 15 | ../priv/%.beam: %.erl ../include/yang.hrl 16 | $(ERLC) $(ERLC_FLAGS) -o ../priv $< 17 | 18 | clean: 19 | rm -f ../priv/*.beam .*.erl.d 20 | 21 | ERL_DEPS = $(ERL_SOURCES:%.erl=.%.erl.d) 22 | 23 | .%.erl.d: %.erl 24 | $(ERLC) -M -MG -I ../.. -o ../priv -pa ../ebin $< > $@ 25 | 26 | .PHONY: depend 27 | 28 | # forcefully re-generate dependency files 29 | depend: 30 | rm -f .*.erl.d 31 | $(MAKE) $(ERL_DEPS) 32 | 33 | ifneq ($(MAKECMDGOALS),clean) 34 | -include $(ERL_DEPS) 35 | endif 36 | -------------------------------------------------------------------------------- /plugins/yanger_restconf.erl: -------------------------------------------------------------------------------- 1 | %%%------------------------------------------------------------------- 2 | %%% @doc Yanger RESTCONF Plugin 3 | %%% Verifies RESTCONF YANG statements as defined in RFC 8040, 4 | %%% Section 8. RESTCONF Module. 5 | %%%------------------------------------------------------------------- 6 | -module(yanger_restconf). 7 | -behaviour(yanger_plugin). 8 | 9 | -export([init/1]). 10 | 11 | -import(yanger_plugin, [add_error/4]). 12 | 13 | -include_lib("yanger/include/yang.hrl"). 14 | 15 | -define(RESTCONF, 'ietf-restconf'). 16 | 17 | init(Ctx0) -> 18 | yanger_plugin:install_grammar(?RESTCONF, grammar()), 19 | Ctx1 = yanger_plugin:register_data_definition_stmt( 20 | Ctx0, 21 | {?RESTCONF, 'yang-data'}, 22 | 'tailf:structure'), 23 | Ctx2 = yanger_plugin:register_error_codes( 24 | Ctx1, 25 | [{'RESTCONF_YANG_DATA_CHILDREN', error, 26 | "yang-data must have a single container as a child"}]), 27 | Ctx3 = yanger_plugin:register_hook( 28 | Ctx2, 29 | #hooks.pre_mk_sn, 30 | fun pre_mk_sn/5), 31 | _Ctx4 = yanger_plugin:register_hook( 32 | Ctx3, 33 | #hooks.post_mk_sn, 34 | fun post_mk_sn/5). 35 | 36 | grammar() -> 37 | %% {,, 38 | %% , 39 | %% {, can occur>}} 40 | [ 41 | {'yang-data', 'identifier', 42 | [{'uses', '?'}, 43 | {'container', '?'}], 44 | {'*', ['module', 'submodule']}} 45 | ]. 46 | 47 | pre_mk_sn(Ctx, #sn{stmt = {Keyword, _, _, _}} = Sn, 48 | final, _UsesPos, _Ancestors) 49 | when Keyword == {?RESTCONF, 'yang-data'} -> 50 | {Ctx, Sn#sn{config = 'ignore'}}; 51 | pre_mk_sn(Ctx, Sn, _Mode, _UsesPos, _Ancestors) -> 52 | {Ctx, Sn}. 53 | 54 | %% Verify that there is only one child data node, i.e. manually check that 55 | %% groupings doesn't contain more than one container. 56 | post_mk_sn(Ctx, 57 | #sn{children = [_, #sn{stmt = {_, _, ChildPos, _}} | _ ], 58 | stmt = {Keyword, _, _Pos, _}} = Sn, 59 | final, _UsesPos, _Ancestors) 60 | when (Keyword == {?RESTCONF, 'yang-data'}) -> 61 | {add_error(Ctx, ChildPos, 'RESTCONF_YANG_DATA_CHILDREN', []), Sn}; 62 | post_mk_sn(Ctx, 63 | #sn{children = [#sn{stmt = {ChildKeyword, _, ChildPos, _}}], 64 | stmt = {Keyword, _, _, _}} = Sn, 65 | final, _UsesPos, _Ancestors) 66 | when (Keyword == {?RESTCONF, 'yang-data'}) 67 | andalso 68 | (ChildKeyword /= 'container') -> 69 | {add_error(Ctx, ChildPos, 'RESTCONF_YANG_DATA_CHILDREN', []), Sn}; 70 | post_mk_sn(Ctx, Sn, _Mode, _UsesPos, _Ancestors) -> 71 | {Ctx, Sn}. 72 | -------------------------------------------------------------------------------- /plugins/yanger_structure.erl: -------------------------------------------------------------------------------- 1 | -module(yanger_structure). 2 | -behaviour(yanger_plugin). 3 | 4 | -export([init/1]). 5 | 6 | -import(yanger_plugin, [add_error/4]). 7 | 8 | -include_lib("yanger/include/yang.hrl"). 9 | 10 | -define(SX_MODULE_NAME, 'ietf-yang-structure-ext'). 11 | 12 | init(Ctx) -> 13 | yanger_plugin:install_grammar(?SX_MODULE_NAME, grammar()), 14 | Ctx1 = yanger_plugin:register_data_definition_stmt( 15 | Ctx, {?SX_MODULE_NAME, 'structure'}, 'structure'), 16 | Ctx2 = yanger_plugin:register_conditional_hook( 17 | Ctx1, #hooks.pre_mk_sn, [{imports, ?SX_MODULE_NAME}], 18 | fun pre_mk_sn/5), 19 | Ctx2. 20 | 21 | grammar() -> 22 | %% {,, 23 | %% , 24 | %% {, can occur>}} 25 | [ 26 | {'structure', 'identifier', 27 | [{'must', '*'}, 28 | {'status', '?'}, 29 | {'description', '?'}, 30 | {'reference', '?'}, 31 | {'typedef', '*'}, 32 | {'grouping', '*'}, 33 | {'leaf', '*'}, 34 | {'leaf-list', '*'}, 35 | {'container', '*'}, 36 | {'list', '*'}, 37 | {'choice', '*'}, 38 | {'anydata', '*'}, 39 | {'anyxml', '*'}, 40 | {'uses', '*'} 41 | ], 42 | {'*', ['module', 'submodule']}} 43 | ]. 44 | 45 | pre_mk_sn(Ctx, #sn{kind = 'structure'} = Sn, _, _, _) -> 46 | {Ctx, Sn#sn{config = ignore}}; 47 | pre_mk_sn(Ctx, Sn, _, _, _) -> 48 | {Ctx, Sn}. 49 | -------------------------------------------------------------------------------- /priv/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | include ../vsn.mk 2 | 3 | ERL_SOURCES := $(wildcard *.erl) 4 | YECC_SOURCES := $(wildcard *.yrl) 5 | ERL_OBJECTS := $(ERL_SOURCES:%.erl=../ebin/%.beam) \ 6 | $(YECC_SOURCES:%.yrl=../ebin/%.beam) 7 | 8 | ERL_OBJECTS += ../ebin/yang_llerror.beam 9 | 10 | APP_SOURCES := $(wildcard *.app.src) 11 | APP_OBJECTS := $(APP_SOURCES:%.app.src=../ebin/%.app) 12 | 13 | null := 14 | space := $(null) # 15 | comma := , 16 | MODULES := $(subst $(space),$(comma),$(strip $(ERL_OBJECTS:../ebin/%.beam=%))) 17 | 18 | ERLC ?= erlc 19 | 20 | ERLC_FLAGS += -DVSN=\"$(VSN)\" -pa ../../yanger/ebin -Werror +debug_info 21 | 22 | compile: all 23 | 24 | all: $(ERL_OBJECTS) $(APP_OBJECTS) 25 | 26 | yang_llerror.erl: ../c_src/yang_error.h 27 | awk -f mk_llerror.awk < $< > $@ 28 | 29 | yang_llerror.hrl: ../c_src/yang_error.h 30 | awk -f mk_llerror_hrl.awk < $< > $@ 31 | 32 | ../ebin/yang.beam: yang_llerror.hrl 33 | 34 | ../ebin/%.app: %.app.src ../vsn.mk Makefile 35 | sed -e "s/%VSN%/$(VSN)/; s/%MODULES%/$(MODULES)/" < $< > $@ 36 | 37 | ../ebin/%.beam: %.erl 38 | $(ERLC) $(ERLC_FLAGS) -o ../ebin $< 39 | 40 | %.erl: %.yrl 41 | $(ERLC) $< 42 | 43 | clean: 44 | rm -f ../ebin/*.* .*.erl.d 45 | rm -f yang_llerror.erl yang_parse.erl 46 | 47 | ERL_DEPS = $(ERL_SOURCES:%.erl=.%.erl.d) 48 | 49 | .%.erl.d: %.erl 50 | $(ERLC) -M -MG -I ../.. -o ../ebin -pa ../ebin $< > $@ 51 | 52 | .PHONY: depend 53 | 54 | # forcefully re-generate dependency files 55 | depend: 56 | rm -f .*.erl.d 57 | $(MAKE) $(ERL_DEPS) 58 | 59 | ifneq ($(MAKECMDGOALS),clean) 60 | -include $(ERL_DEPS) 61 | endif 62 | -------------------------------------------------------------------------------- /src/mk_llerror.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | printf("%% NOTE: this file has been generated from yang_error.h.\n"); 3 | printf("%% Do not edit.\n"); 4 | printf("-module(yang_llerror).\n"); 5 | printf("-export([code2err/1, codes/0]).\n\n"); 6 | } 7 | 8 | /^#define YANG_ERR_/ { 9 | errors[$2] = $3; 10 | } 11 | /^#define YANG_WARN_/ { 12 | warnings[$2] = $3; 13 | } 14 | 15 | END { 16 | for (err in errors) { 17 | printf("code2err(%s) -> '%s';\n", errors[err], err); 18 | } 19 | for (err in warnings) { 20 | printf("code2err(%s) -> '%s';\n", warnings[err], err); 21 | } 22 | printf("code2err(_) -> undefined.\n\n"); 23 | 24 | printf("codes() ->\n"); 25 | printf(" [\n"); 26 | for (err in errors) { 27 | printf(" {'%s', error, \"~s\"},\n", err); 28 | } 29 | for (err in warnings) { 30 | printf(" {'%s', warning, \"~s\"},\n", err); 31 | } 32 | printf(" {dummy, error, \"~s\"}].\n"); 33 | } 34 | -------------------------------------------------------------------------------- /src/mk_llerror_hrl.awk: -------------------------------------------------------------------------------- 1 | BEGIN { 2 | printf("%% NOTE: this file has been generated from yang_error.h.\n"); 3 | printf("%% Do not edit.\n\n"); 4 | } 5 | 6 | /^#define YANG_FIRST_WARNING/ { 7 | printf("-define(YANG_FIRST_WARNING, %s).\n", $3) 8 | } 9 | -------------------------------------------------------------------------------- /src/w3cregex.erl: -------------------------------------------------------------------------------- 1 | %%% ------------------------------------------------------------------------ 2 | %%% @copyright 2012 Tail-f Systems AB 3 | %%% @doc NIF implementation of W3C regular expressions 4 | %%% ------------------------------------------------------------------------ 5 | -module(w3cregex). 6 | 7 | -export([compile/1, match/2, cmatchp/2]). 8 | -export([string/1, is_xreg/1]). 9 | 10 | -on_load(on_load/0). 11 | 12 | -opaque xreg() :: <<>>. 13 | -type binstring() :: iolist() | binary(). 14 | 15 | -export_type([xreg/0]). 16 | 17 | 18 | -spec cmatchp(Pattern::binstring(), String::binstring()) -> 19 | boolean() | {'error', string()}. 20 | cmatchp(Pattern, String) -> 21 | case compile(Pattern) of 22 | {ok, XReg} -> 23 | match(XReg, String); 24 | Err -> 25 | Err 26 | end. 27 | 28 | 29 | -spec compile(Pattern::binstring()) -> {'ok', xreg()} | {'error', string()}. 30 | compile(_Pattern) -> 31 | nif_only(). 32 | 33 | -spec match(xreg(), binstring()) -> boolean() | {'error', string()}. 34 | match(CompiledRegex, String) when is_binary(String), (size(String) < 64) -> 35 | run_match(CompiledRegex, String); 36 | match(CompiledRegex, String) -> 37 | run_match_null(CompiledRegex, [String, 0]). 38 | 39 | run_match(_CompiledRegex, _String) -> 40 | nif_only(). 41 | 42 | run_match_null(_CompiledRegex, _String) -> 43 | nif_only(). 44 | 45 | 46 | -spec is_xreg(term()) -> boolean(). 47 | %% @doc Returns true if term is a compiled regular expression (as 48 | %% returned by compile()) 49 | is_xreg(_CompiledRegex) -> 50 | nif_only(). 51 | 52 | 53 | -spec string(xreg()) -> string(). 54 | string(_CompiledRegex) -> 55 | nif_only(). 56 | 57 | 58 | on_load() -> 59 | %Sligtly ugly if we do not return ok module_info does not work and 60 | %Also cover does not handle internal calls there for no internal function 61 | %calls here please! 62 | case os:type() of 63 | {win32, _} -> 64 | ok; 65 | _ -> 66 | case code:priv_dir(yanger) of 67 | {error,_} -> 68 | ok; 69 | PrivDir -> 70 | File = filename:append(PrivDir, "w3cregex_nif"), 71 | erlang:load_nif(File, 0) 72 | end 73 | end. 74 | 75 | nif_only() -> 76 | erlang:nif_error({nif_not_loaded, ?MODULE}). 77 | -------------------------------------------------------------------------------- /src/yang_llerror.hrl: -------------------------------------------------------------------------------- 1 | % NOTE: this file has been generated from yang_error.h. 2 | % Do not edit. 3 | 4 | -define(YANG_FIRST_WARNING, 1000). 5 | -------------------------------------------------------------------------------- /src/yanger.app.src: -------------------------------------------------------------------------------- 1 | {application, yanger, 2 | [ 3 | {description, ""}, 4 | {vsn, "%VSN%"}, 5 | {modules, [%MODULES%]}, 6 | {registered, []}, 7 | {applications, [ 8 | kernel, 9 | stdlib 10 | ]}, 11 | {env, []} 12 | ]}. 13 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | DIRS = lux eunit 2 | 3 | all: test 4 | 5 | build: 6 | for d in $(DIRS) ; do \ 7 | (cd $$d && $(MAKE) build) || exit 1; \ 8 | done 9 | 10 | test: 11 | @error="" ; \ 12 | for d in $(DIRS); do \ 13 | ( cd $$d && env MAKE=$(MAKE) $(MAKE) test; \ 14 | ) || error="$$error $$d"; \ 15 | done ; \ 16 | if [ "$$error" ]; then \ 17 | echo '***********************************' ; \ 18 | echo '*** Failed test(s) (see above): ***' ; \ 19 | echo ' ' $$error ; \ 20 | echo '***********************************' ; \ 21 | exit 1 ; \ 22 | fi; 23 | 24 | clean: 25 | for d in $(DIRS) ; do ( cd $$d && $(MAKE) clean) ; done 26 | desc: 27 | @echo "Overview:" 28 | @echo "yanger grey box testing" 29 | @$(MAKE) -C lux lux_desc --no-print-directory 30 | 31 | .PHONY: all build test clean desc 32 | -------------------------------------------------------------------------------- /test/eunit/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ## This will be export_all compiled. 3 | EXTRA_EUNIT_BUILD=ebin/app/yang.beam 4 | 5 | include ../support/eunit.mk 6 | 7 | -------------------------------------------------------------------------------- /test/eunit/subm.yang: -------------------------------------------------------------------------------- 1 | 2 | // This module is used in deviation_update_modules_tests.erl 3 | 4 | submodule subm { 5 | belongs-to deviating { 6 | prefix dev; 7 | } 8 | 9 | import target { 10 | prefix target; 11 | } 12 | 13 | deviation "/target:master/target:item" { 14 | deviate replace {type int32;} 15 | } 16 | } -------------------------------------------------------------------------------- /test/lux/ENG-23621-leafref-has-invalid-path/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/ENG-23621-leafref-has-invalid-path/run.lux: -------------------------------------------------------------------------------- 1 | [doc] 2 | Check invalid path in leafref path handled gracefully. 3 | 4 | If there is a leafref path that points to an invalid path eg. invalid namespace 5 | due to not imported modules, or XPATH compilation failed for some reason, 6 | yanger shall report a proper error. This is the case for most of the scenarios 7 | but when a leafref points to another leafref that has an invalid path, we were 8 | getting an internal error previously. This test ensures that yanger reports a 9 | proper error message. 10 | [enddoc] 11 | 12 | ################################################################################ 13 | 14 | [shell yanger] 15 | -function_clause 16 | !env YANGERROR=super-pruned yanger --verbose test.yang 17 | ???test.yang:11: error: XPath error: Invalid namespace prefix: ngsub 18 | !echo ==$$?== 19 | ?==1== 20 | -------------------------------------------------------------------------------- /test/lux/ENG-23621-leafref-has-invalid-path/test.yang: -------------------------------------------------------------------------------- 1 | module test { 2 | namespace "http://acme/test"; 3 | prefix test; 4 | leaf name { 5 | type leafref { 6 | path '../name2'; 7 | } 8 | } 9 | leaf name2 { 10 | type leafref { 11 | path '/ngsub:sub-vpns'; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/lux/ENG-24068-submodule-post-expand-leafref/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: iclean 6 | rm -rf lux_logs 7 | -------------------------------------------------------------------------------- /test/lux/ENG-24068-submodule-post-expand-leafref/run.lux: -------------------------------------------------------------------------------- 1 | [doc] 2 | Return proper error if a leafref refers to a conditional leaf that does not exist due to the condtition. 3 | 4 | RFC-7950 states: 5 | "If the leaf that the leafref refers to is conditional based on one or 6 | more features (see Section 7.20.2), then the leaf with the leafref 7 | type MUST also be conditional based on at least the same set of features." 8 | 9 | [enddoc] 10 | 11 | ################################################################################ 12 | 13 | [shell test] 14 | !env yanger --print-error-code test.yang --features test: 15 | ???./subtest.yang:9: YANG_ERR_NODE_NOT_FOUND3 16 | ???./subtest.yang:15: YANG_ERR_NODE_NOT_FOUND2 17 | -==0== 18 | !echo ==$$?== 19 | ?==1== 20 | -------------------------------------------------------------------------------- /test/lux/ENG-24068-submodule-post-expand-leafref/subtarget.yang: -------------------------------------------------------------------------------- 1 | submodule subtarget { 2 | yang-version 1.1; 3 | belongs-to test { 4 | prefix t; 5 | } 6 | feature name; 7 | 8 | container top{ 9 | leaf subtarget { 10 | if-feature name; 11 | type string; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/lux/ENG-24068-submodule-post-expand-leafref/subtest.yang: -------------------------------------------------------------------------------- 1 | submodule subtest { 2 | yang-version 1.1; 3 | belongs-to test { 4 | prefix t; 5 | } 6 | 7 | leaf target { 8 | type leafref { 9 | path '/t:top/t:subtarget'; 10 | } 11 | } 12 | 13 | leaf name { 14 | type leafref { 15 | path '/t:basename'; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/lux/ENG-24068-submodule-post-expand-leafref/test.yang: -------------------------------------------------------------------------------- 1 | module test { 2 | yang-version 1.1; 3 | namespace "http://acme/test"; 4 | prefix t; 5 | include subtarget; 6 | include subtest; 7 | 8 | leaf basename { 9 | if-feature name; 10 | type string; 11 | default "testname"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/lux/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | $(MAKE) build 3 | $(MAKE) test_testarea 4 | 5 | include ../support/lux_testarea.mk 6 | 7 | build: 8 | $(MAKE) build_testarea 9 | 10 | clean: 11 | $(MAKE) clean_testarea 12 | rm -rf lux_logs 13 | 14 | .PHONY: build clean test 15 | -------------------------------------------------------------------------------- /test/lux/any-must/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/any-must/any.yang: -------------------------------------------------------------------------------- 1 | module any { 2 | yang-version 1.1; 3 | namespace urn:any; 4 | prefix any; 5 | 6 | leaf foo { 7 | type int32; 8 | } 9 | 10 | anyxml bar { 11 | must "../foo = 42"; 12 | } 13 | anydata baz { 14 | must "../foo = 42"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/lux/any-must/run.lux: -------------------------------------------------------------------------------- 1 | [doc Verify that 'must' is allowed as substatement to 'anyxml'/'anydata'] 2 | 3 | [shell test] 4 | -error 5 | !yanger any.yang 6 | !echo ==$$?== 7 | ?==0== 8 | -------------------------------------------------------------------------------- /test/lux/augment-bug/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/augment-bug/shaping.lux: -------------------------------------------------------------------------------- 1 | [doc test bug augment ] 2 | 3 | [shell yanger] 4 | !yanger bbf-qos-shaping.yang -f tree 5 | """??? 6 | module: bbf-qos-shaping 7 | 8 | augment /if:interfaces/if:interface/bbf-qos-tm:tm-root: 9 | +--rw shaper-name? -> /bbf-qos-tm:tm-profiles/bbf-qos-shap:shaper-profile/name 10 | augment /if:interfaces/if:interface/bbf-qos-tm:tm-root/bbf-qos-tm:children-type/bbf-qos-tm:queues/bbf-qos-tm:queue/bbf-qos-tm:queue-scheduling-cfg-type/bbf-qos-tm:inline: 11 | +--rw shaper-name? -> /bbf-qos-tm:tm-profiles/bbf-qos-shap:shaper-profile/name 12 | augment /bbf-qos-tm:tm-profiles: 13 | +--rw shaper-profile* [name] 14 | +--rw name bbf-yang:string-ascii64 15 | +--rw (shaper-type) 16 | +--:(single-token-bucket) 17 | | +--rw single-token-bucket 18 | | +--rw pir? uint32 19 | | +--rw pbs? uint32 20 | +--:(dual-rate) {dual-rate-shaper}? 21 | +--rw dual-rate 22 | +--rw pir? uint32 23 | +--rw cir? uint32 24 | """ 25 | -------------------------------------------------------------------------------- /test/lux/bad/Makefile: -------------------------------------------------------------------------------- 1 | #Includes for test and build 2 | include ../../support/*_testcases.mk 3 | 4 | .PHONY: build 5 | 6 | YANG = $(wildcard *.yang) 7 | GENLUX = $(YANG:%.yang=%.lux) 8 | 9 | build: $(GENLUX) 10 | 11 | %.lux: %.yang 12 | sh gen_lux.sh $< > $@ 13 | 14 | clean: 15 | rm -f $(GENLUX) 16 | rm -fr lux_logs 17 | -------------------------------------------------------------------------------- /test/lux/bad/aug-mand.yang: -------------------------------------------------------------------------------- 1 | module aug-mand { 2 | namespace "urn:aug"; 3 | prefix aug; 4 | 5 | import t { 6 | prefix t; 7 | } 8 | 9 | augment "/t:t" { 10 | leaf m { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 11 | type int32; 12 | mandatory true; 13 | } 14 | container p { 15 | presence ""; 16 | leaf l { 17 | type int32; 18 | mandatory true; 19 | } 20 | } 21 | container c { 22 | list l { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 23 | key k; 24 | leaf k { 25 | type string; 26 | } 27 | min-elements 1; 28 | } 29 | } 30 | } 31 | 32 | /* 'when' should not allow mandatory in 1.0 */ 33 | augment "/t:t" { 34 | when false(); 35 | leaf mm { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 36 | type int32; 37 | mandatory true; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/lux/bad/aug-miss.yang: -------------------------------------------------------------------------------- 1 | module aug-miss { 2 | namespace urn:aug-miss; 3 | prefix am; 4 | 5 | import h { 6 | prefix h; 7 | } 8 | import not-found { // LINE: YANG_ERR_MODULE_NOT_FOUND 9 | prefix nf; 10 | } 11 | 12 | augment /h:xx { 13 | leaf new { 14 | type string; 15 | } 16 | } 17 | augment /nf:yy { 18 | leaf zz { 19 | type string; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/lux/bad/aug-oper-mand.yang: -------------------------------------------------------------------------------- 1 | module aug-oper-mand { 2 | namespace urn:aom; 3 | prefix aom; 4 | 5 | import t { 6 | prefix t; 7 | } 8 | 9 | augment /t:t { 10 | leaf mand { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 11 | config false; 12 | type string; 13 | mandatory true; 14 | } 15 | container oper { 16 | config false; 17 | list mand { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 18 | key k; 19 | leaf k { 20 | type string; 21 | } 22 | min-elements 1; 23 | } 24 | } 25 | container config { 26 | leaf mand { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 27 | config false; 28 | type string; 29 | mandatory true; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /test/lux/bad/bad-augment-node.yang: -------------------------------------------------------------------------------- 1 | module bad-augment-node { 2 | namespace urn:bad-augment-node; 3 | prefix ban; 4 | 5 | import h { 6 | prefix h; 7 | } 8 | 9 | // augmenting a leaf 10 | augment /h:xx/h:a/h:name { 11 | leaf foo { // LINE: YANG_ERR_BAD_AUGMENT_NODE_TYPE2 12 | type int32; 13 | } 14 | } 15 | 16 | // augmenting a leaf-list 17 | augment /h:xx/h:a/h:value { 18 | leaf bar { // LINE: YANG_ERR_BAD_AUGMENT_NODE_TYPE2 19 | type int32; 20 | } 21 | } 22 | 23 | // augmenting a non-choice with a case 24 | augment /h:xx { 25 | case baz { // LINE: YANG_ERR_BAD_AUGMENT_NODE_TYPE2 26 | leaf baz { 27 | type int32; 28 | } 29 | } 30 | } 31 | 32 | // augmenting a "not-yet-found" leaf target ("__tmp_augment__") 33 | augment /h:xx/h:a/ban:foobar { // LINE: YANG_ERR_BAD_AUGMENT_NODE_TYPE 34 | leaf cc { 35 | type int32; 36 | } 37 | } 38 | augment /h:xx/h:a { 39 | leaf foobar { 40 | type int32; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/lux/bad/bad-date.yang: -------------------------------------------------------------------------------- 1 | module bad-date { 2 | 3 | namespace "http://example.com/test"; 4 | 5 | prefix "t"; 6 | 7 | revision 2018-02-29 { // LINE: YANG_ERR_GRAMMAR_BAD_ARGUMENT 8 | description 9 | "This is a out-of-bounds date."; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/lux/bad/bad-union.yang: -------------------------------------------------------------------------------- 1 | module bad-union { 2 | namespace urn:bad-union; 3 | prefix bu; 4 | 5 | container test { 6 | leaf mac-address { 7 | type union { 8 | type yang:mac-address; // LINE: YANG_ERR_PREFIX_NOT_FOUND 9 | type enumeration { 10 | enum default; 11 | } 12 | } 13 | default default; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/lux/bad/bad1.yang: -------------------------------------------------------------------------------- 1 | module bad1 { 2 | namespace urn:bad1; 3 | 4 | contact "hej"; // expect prefix LINE: YANG_ERR_GRAMMAR_EXPECTED_KEYWORD 5 | 6 | leafx; // LINE: YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 7 | 8 | leafy; // LINE: YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 9 | 10 | container xmLLeaf; // LINE: YANG_ERR_GRAMMAR_BAD_ARGUMENT 11 | container xm; 12 | container X; 13 | container xm_LLeaf; 14 | 15 | container a { 16 | choice b { 17 | case c { 18 | must "/X"; // LINE: YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 19 | leaf d { 20 | type string; 21 | } 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /test/lux/bad/basic.lux: -------------------------------------------------------------------------------- 1 | [doc Test that yanger can be run] 2 | 3 | [shell yanger] 4 | !yanger -h 5 | ?Usage: yanger 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/lux/bad/clr.yang: -------------------------------------------------------------------------------- 1 | module clr { 2 | namespace urn:clr; 3 | prefix clr; 4 | 5 | import t { 6 | prefix t; 7 | } 8 | 9 | leaf x { 10 | type leafref { 11 | path /t:t/x; // LINE: YANG_ERR_CIRCULAR_DEPENDENCY_LEAFREF 12 | } 13 | } 14 | augment /t:t { 15 | leaf x { 16 | type leafref { 17 | path /x; // LINE: YANG_ERR_CIRCULAR_DEPENDENCY_LEAFREF 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/lux/bad/eb.yang: -------------------------------------------------------------------------------- 1 | module eb { 2 | namespace urn:eb; 3 | prefix eb; 4 | 5 | typedef e1 { 6 | type enumeration { 7 | enum a; 8 | enum b { 9 | value 0; // LINE: YANG_ERR_DUPLICATE_ENUM_VALUE 10 | } 11 | enum c; 12 | enum d { 13 | value 2147483647; 14 | } 15 | enum a; // LINE: YANG_ERR_DUPLICATE_ENUM_NAME 16 | enum e; // LINE: YANG_ERR_ENUM_VALUE 17 | enum f { 18 | value -2147483649; // LINE: YANG_ERR_ENUM_VALUE 19 | } 20 | } 21 | } 22 | typedef e2 { 23 | type e1 { 24 | enum a; // LINE: YANG_ERR_BAD_RESTRICTION 25 | } 26 | } 27 | 28 | typedef b1 { 29 | type bits { 30 | bit a; 31 | bit b { 32 | position 0; // LINE: YANG_ERR_DUPLICATE_BIT_POSITION 33 | } 34 | bit c; 35 | bit d { 36 | position 4294967296; // LINE: YANG_ERR_BIT_POSITION 37 | } 38 | bit a; // LINE: YANG_ERR_DUPLICATE_BIT_NAME 39 | } 40 | } 41 | typedef b2 { 42 | type b1 { 43 | bit a; // LINE: YANG_ERR_BAD_RESTRICTION 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /test/lux/bad/eb11.yang: -------------------------------------------------------------------------------- 1 | module eb11 { 2 | yang-version 1.1; 3 | namespace urn:eb11; 4 | prefix eb11; 5 | 6 | feature foo; 7 | 8 | typedef e1 { 9 | type enumeration { 10 | enum a { 11 | if-feature foo; 12 | } 13 | enum b; 14 | enum c; 15 | } 16 | /* default b is not valid for typedef e4 */ 17 | default b; // LINE: YANG_ERR_TYPE_VALUE 18 | } 19 | typedef e2 { 20 | type e1 { 21 | enum d; // LINE: YANG_ERR_ENUM_NAME_MISMATCH 22 | enum b; 23 | } 24 | } 25 | typedef e3 { 26 | type e1 { 27 | enum a { 28 | value 3; // LINE: YANG_ERR_ENUM_VALUE_MISMATCH 29 | } 30 | enum b; 31 | } 32 | } 33 | typedef e4 { 34 | type e1 { 35 | enum a; 36 | enum c { value 2; } // ok, same value 37 | } 38 | } 39 | typedef e5 { 40 | type e4 { 41 | enum a { 42 | value 1; // LINE: YANG_ERR_ENUM_VALUE_MISMATCH 43 | } 44 | enum b; // LINE: YANG_ERR_ENUM_NAME_MISMATCH 45 | enum c { value 2; } // ok, same value 46 | } 47 | } 48 | 49 | typedef b1 { 50 | type bits { 51 | bit a; 52 | bit b; 53 | bit c; 54 | } 55 | /* default b is not valid for typedef b4 */ 56 | default b; // LINE: YANG_ERR_TYPE_VALUE 57 | } 58 | typedef b2 { 59 | type b1 { 60 | bit d; // LINE: YANG_ERR_BIT_NAME_MISMATCH 61 | bit b; 62 | } 63 | } 64 | typedef b3 { 65 | type b1 { 66 | bit a { 67 | position 3; // LINE: YANG_ERR_BIT_POSITION_MISMATCH 68 | } 69 | bit b; 70 | } 71 | } 72 | typedef b4 { 73 | type b1 { 74 | bit a; 75 | bit c { position 2; } // ok, same position 76 | } 77 | } 78 | typedef b5 { 79 | type b4 { 80 | bit a { 81 | position 1; // LINE: YANG_ERR_BIT_POSITION_MISMATCH 82 | } 83 | bit b; // LINE: YANG_ERR_BIT_NAME_MISMATCH 84 | bit c { position 2; } // ok, same position 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /test/lux/bad/eb11f.yang: -------------------------------------------------------------------------------- 1 | module eb11f { 2 | yang-version 1.1; 3 | namespace urn:eb11f; 4 | prefix eb11f; 5 | 6 | // YANGER_EXTRA_FLAGS: --ignore-unknown-features --features bar 7 | 8 | feature foo; 9 | 10 | typedef e1 { 11 | type enumeration { 12 | enum a { 13 | if-feature foo; 14 | } 15 | enum b; 16 | enum c; 17 | } 18 | } 19 | typedef e2 { 20 | type e1 { 21 | enum d; // LINE: YANG_ERR_ENUM_NAME_MISMATCH 22 | enum b; 23 | } 24 | } 25 | typedef e3 { 26 | type e1 { 27 | enum a { 28 | value 3; // LINE: YANG_ERR_ENUM_VALUE_MISMATCH 29 | } 30 | enum b; 31 | } 32 | } 33 | typedef e4 { 34 | type e1 { 35 | enum a; 36 | enum c { value 2; } // ok, same value 37 | } 38 | } 39 | typedef e5 { 40 | type e4 { 41 | enum a { 42 | value 1; // LINE: YANG_ERR_ENUM_VALUE_MISMATCH 43 | } 44 | enum c { value 2; } // ok, same value 45 | } 46 | } 47 | 48 | typedef b1 { 49 | type bits { 50 | bit a; 51 | bit b; 52 | bit c; 53 | } 54 | } 55 | typedef b2 { 56 | type b1 { 57 | bit d; // LINE: YANG_ERR_BIT_NAME_MISMATCH 58 | bit b; 59 | } 60 | } 61 | typedef b3 { 62 | type b1 { 63 | bit a { 64 | position 3; // LINE: YANG_ERR_BIT_POSITION_MISMATCH 65 | } 66 | bit b; 67 | } 68 | } 69 | typedef b4 { 70 | type b1 { 71 | bit a; 72 | bit c { position 2; } // ok, same position 73 | } 74 | } 75 | typedef b5 { 76 | type b4 { 77 | bit a { 78 | position 1; // LINE: YANG_ERR_BIT_POSITION_MISMATCH 79 | } 80 | bit c { position 2; } // ok, same position 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /test/lux/bad/gen_lux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # pick up any extra flags to yanger needed for this module 6 | YF=`sed -n 's/^[^:]*YANGER_EXTRA_FLAGS:\(.*\)$/\1/p' $1` 7 | CMD0="yanger --smiv2-detect-duplicate-oids $YF" 8 | CMD="$CMD0 --print-error-code" 9 | 10 | # NOTE: We mustn't send command lines longer than 80 chars below, since some 11 | # shells output a CR at column 80 to deal with the vt100/xterm cursor issue. 12 | # Thus we fold the command with '\' (need 2 since single backslash is consumed 13 | # by lux, means 4 in the "here doc" - using echo is impossible due to broken 14 | # /bin/sh implementations) and match only the second line - but this means we 15 | # must match on the PS2 prompt, otherwise it may appear *after* the echo of 16 | # the second line. Sigh... 17 | 18 | cat <&1 | grep $1 27 | -SH-PROMPT 28 | """? 29 | $1 2>&1 \\| grep $1 30 | EOF 31 | 32 | grep -n LINE $1 /dev/null | awk ' 33 | /LINE:/ { split($0, a, "LINE: "); printf "%s([0-9]+:)? (\\(.*\\): )?%s\n", $1, a[2] } 34 | ' 35 | 36 | cat <&1 | grep $1 47 | -SH-PROMPT 48 | """? 49 | $1 2>&1 \\| grep $1 50 | EOF 51 | 52 | grep -n LINE $1 /dev/null | awk ' 53 | /LINE:/ { printf "%s([0-9]+:)? (\\(.*\\): )?(error|warning): \\S+.*\n", $1 } 54 | ' 55 | 56 | cat < /nfr:rootleaf"; // LINE: YANG_ERR_XPATH_BAD_REF 30 | } 31 | leaf must2 { 32 | type int16; 33 | must ". > /nfr:rootlist/nfr:id"; // LINE: YANG_ERR_XPATH_BAD_REF 34 | } 35 | leaf must3 { 36 | type int16; 37 | must ". > /nfr:rootcont/nfr:xxx"; // LINE: YANG_ERR_XPATH_BAD_REF 38 | } 39 | 40 | leaf when1 { 41 | when "../must1 > /nfr:rootleaf"; // LINE: YANG_ERR_XPATH_BAD_REF 42 | type int16; 43 | } 44 | leaf when2 { 45 | when "../must1 > /nfr:rootlist/nfr:id"; // LINE: YANG_ERR_XPATH_BAD_REF 46 | type int16; 47 | } 48 | leaf when3 { 49 | when "../must1 > /nfr:rootcont/nfr:xxx"; // LINE: YANG_ERR_XPATH_BAD_REF 50 | type int16; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test/lux/bad/quoted-string-1.0.yang: -------------------------------------------------------------------------------- 1 | module quoted-string-1.0 { 2 | namespace urn:example:qs; 3 | prefix qs; 4 | 5 | description 6 | "Newline is ok.\nAnd tab\t, and a slash\\, and a 7 | double quote \"."; 8 | 9 | container x { 10 | description 11 | "But nothing else! \'."; // LINE: YANG_WARN_PARSE_ILLEGAL_ESCAPE 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /test/lux/bad/quoted-string-1.1.yang: -------------------------------------------------------------------------------- 1 | module quoted-string-1.1 { 2 | yang-version 1.1; 3 | namespace urn:example:qs; 4 | prefix qs; 5 | 6 | description 7 | "Newline is ok.\nAnd tab\t, and a slash\\, and a 8 | double quote \"."; 9 | 10 | container x { 11 | description 12 | "But nothing else! \'."; // LINE: YANG_ERR_PARSE_ILLEGAL_ESCAPE 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test/lux/bad/rev.yang: -------------------------------------------------------------------------------- 1 | module rev { 2 | namespace urn:rev; 3 | prefix rev; 4 | 5 | revision 2015-04-01; 6 | 7 | import ietf-inet-types { // LINE: YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 8 | prefix inet; 9 | } 10 | import ietf-yang-types { // LINE: YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 11 | prefix yang; 12 | } 13 | 14 | leaf address { 15 | type inet:ip-address; 16 | } 17 | leaf now { 18 | type yang:date-and-time; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/bad/smiv2.yang: -------------------------------------------------------------------------------- 1 | module smiv2 { 2 | namespace urn:smiv2; 3 | prefix s; 4 | 5 | import ietf-yang-smiv2 { 6 | prefix smiv2; 7 | } 8 | 9 | container x { 10 | smiv2:subid 3; // LINE: SMIv2_ERR_SUBID 11 | } 12 | 13 | container y { 14 | smiv2:oid "1.3.6.2"; 15 | container z { 16 | smiv2:subid 3; 17 | } 18 | leaf e { 19 | type string; 20 | smiv2:subid 3; 21 | smiv2:oid "1.3.5"; // LINE: SMIv2_ERR_SUBID_AND_OID 22 | } 23 | leaf q { 24 | smiv2:subid 3; // LINE: SMIv2_ERR_DUPLICATE_OID 25 | type string; 26 | } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /test/lux/bad/t.yang: -------------------------------------------------------------------------------- 1 | module t { 2 | namespace "urn:t"; 3 | prefix "t"; 4 | 5 | grouping obsolete-grouping { 6 | status obsolete; 7 | container d; 8 | } 9 | 10 | typedef deprecated-type { 11 | status deprecated; 12 | type string; 13 | } 14 | 15 | typedef bad-type { 16 | type deprecated-type; // LINE: YANG_BAD_STATUS_REFERENCE 17 | } 18 | 19 | container t { 20 | grouping obsolete-grouping2 { 21 | status obsolete; 22 | container d2; 23 | } 24 | leaf current-leaf { type string; } 25 | leaf deprecated-leaf { type string; status deprecated; } 26 | leaf obsolete-leaf { type string; status obsolete;} 27 | leaf c { 28 | status current; 29 | type deprecated-type; // LINE: YANG_BAD_STATUS_REFERENCE 30 | } 31 | leaf r { // LINE: YANG_BAD_STATUS_REFERENCE 32 | type leafref { 33 | path "/t/deprecated-leaf"; 34 | } 35 | } 36 | uses obsolete-grouping { // LINE: YANG_BAD_STATUS_REFERENCE 37 | status deprecated; 38 | } 39 | uses obsolete-grouping2 { // LINE: YANG_BAD_STATUS_REFERENCE 40 | status current; 41 | } 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /test/lux/bad/test_sec_6_1/Makefile: -------------------------------------------------------------------------------- 1 | include ../../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/bad/test_sec_6_1/mod1.yang: -------------------------------------------------------------------------------- 1 | module mod1 { 2 | yang-version 1.1; 3 | namespace "urn:mod1"; 4 | prefix m1; 5 | 6 | contact test1'; 7 | 8 | leaf l { 9 | type uint8; 10 | } 11 | } -------------------------------------------------------------------------------- /test/lux/bad/test_sec_6_1/mod2.yang: -------------------------------------------------------------------------------- 1 | module mod2 { 2 | namespace "urn:mod2"; 3 | prefix m2; 4 | 5 | leaf l { 6 | type uint8; 7 | units k"g; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/lux/bad/test_sec_6_1/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test RFC 7950, 6.1.3, Quoting] 2 | 3 | [shell yanger] 4 | !yanger --print-error-code mod1.yang 5 | ?mod1.yang:6:16: YANG_ERR_PARSE_INCOMPLETE_STATEMENT 6 | 7 | !yanger --print-error-code mod2.yang 8 | ?mod2.yang:7:12: YANG_ERR_PARSE_INCOMPLETE_STATEMENT 9 | -------------------------------------------------------------------------------- /test/lux/bad/tmust.yang: -------------------------------------------------------------------------------- 1 | module tmust { 2 | 3 | namespace "http://netconfcentral.org/ns/tmust"; 4 | 5 | prefix tm; 6 | 7 | revision "2015-10-08" { 8 | } 9 | 10 | leaf A { type int8; } 11 | 12 | container X { 13 | choice Y { 14 | must "/A=4"; // LINE: YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 15 | case YY { 16 | leaf ZZ { type string; } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/bad/typo.yang: -------------------------------------------------------------------------------- 1 | module typo { 2 | namespace urn:typo; 3 | prefix t; 4 | 5 | leaf bad { 6 | type strings; // LINE: YANG_ERR_DEFINITION_NOT_FOUND 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/lux/bad/uses.yang: -------------------------------------------------------------------------------- 1 | module uses { 2 | namespace "urn:uses"; 3 | prefix u; 4 | 5 | /* check that groupings are only porcessed once */ 6 | grouping g2 { 7 | list l2 { 8 | key e2; // LINE: YANG_ERR_TYPE_EMPTY_IN_KEY 9 | leaf e2 { 10 | type empty; 11 | } 12 | leaf-list ll2 { 13 | type empty; // LINE: YANG_ERR_TYPE_EMPTY_IN_LEAF_LIST 14 | } 15 | leaf l1 { 16 | type uint8 { 17 | range "-1..1"; // LINE: YANG_ERR_BAD_RANGE_VALUE 18 | } 19 | } 20 | } 21 | } 22 | 23 | grouping g1 { 24 | list l1 { 25 | key e1; // LINE: YANG_ERR_TYPE_EMPTY_IN_KEY 26 | leaf e1 { 27 | type empty; 28 | } 29 | leaf-list ll1 { 30 | type empty; // LINE: YANG_ERR_TYPE_EMPTY_IN_LEAF_LIST 31 | } 32 | } 33 | container c1 { 34 | /* using a grouping that is "later" alphabetically 35 | but not in file order - used to cause duplicated processing */ 36 | uses g2; 37 | /* using a grouping that is "later" in file order 38 | but not alphabetically */ 39 | uses g0; 40 | /* same grouping name in different subtrees is OK... */ 41 | container c11 { 42 | grouping g3 { 43 | leaf-list ll3 { 44 | type empty; // LINE: YANG_ERR_TYPE_EMPTY_IN_LEAF_LIST 45 | } 46 | } 47 | uses g3; 48 | } 49 | container c12 { 50 | grouping g3 { 51 | list l3 { 52 | key e3; // LINE: YANG_ERR_TYPE_EMPTY_IN_KEY 53 | leaf e3 { 54 | type empty; 55 | } 56 | } 57 | } 58 | uses g3; 59 | } 60 | uses g3; // LINE: YANG_ERR_DEFINITION_NOT_FOUND 61 | } 62 | } 63 | 64 | grouping g0 { 65 | list l0 { 66 | key e0; // LINE: YANG_ERR_TYPE_EMPTY_IN_KEY 67 | leaf e0 { 68 | type empty; 69 | } 70 | leaf-list ll0 { 71 | type empty; // LINE: YANG_ERR_TYPE_EMPTY_IN_LEAF_LIST 72 | } 73 | } 74 | } 75 | 76 | /* check circular dependency detection */ 77 | grouping z0 { 78 | container cc0 { 79 | uses z1; 80 | } 81 | } 82 | grouping z1 { 83 | container cc1 { 84 | uses z2; 85 | } 86 | } 87 | grouping z2 { // LINE: YANG_ERR_CIRCULAR_DEPENDENCY 88 | container cc2 { 89 | uses z0; 90 | } 91 | } 92 | 93 | container c { 94 | uses g1; 95 | uses z2; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /test/lux/bad/xpathref.yang: -------------------------------------------------------------------------------- 1 | module xpathref { 2 | yang-version 1.1; 3 | namespace "urn:xpathref"; 4 | prefix xr; 5 | 6 | container x { 7 | leaf foo { 8 | type int32; 9 | config false; 10 | } 11 | leaf bar { 12 | type int32; 13 | must "../foo"; // LINE: YANG_ERR_XPATH_REF_BAD_CONFIG 14 | } 15 | leaf baz { 16 | type int32; 17 | when "../foo"; // LINE: YANG_ERR_XPATH_REF_BAD_CONFIG 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/bad/xt1s1.yang: -------------------------------------------------------------------------------- 1 | submodule xt1s1 { 2 | belongs-to xt1 {prefix xt1; } 3 | // import xt3 { prefix xt3p; } // different prefix than in xt1 4 | organization "hopp"; 5 | contact "hej" { 6 | // xt3p:test hej {} 7 | } 8 | 9 | revision 2007-06-06 { description "initinla"; } 10 | 11 | container sub1 { 12 | leaf q { 13 | type int32; 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /test/lux/bad/xt1s2.yang: -------------------------------------------------------------------------------- 1 | submodule xt1s2 { 2 | belongs-to foo { // error: bad belongs-to 3 | prefix xt1; 4 | } 5 | 6 | typedef foo { 7 | type int32; 8 | } 9 | 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/lux/bad/xt2.yang: -------------------------------------------------------------------------------- 1 | module xt2 { 2 | namespace "xt2"; // LINE: YANG_ERR_GRAMMAR_BAD_ARGUMENT 3 | prefix "xt2"; 4 | 5 | import h { 6 | prefix xt2; // LINE: YANG_ERR_GRAMMAR_DUPLICATE_PREFIX 7 | } 8 | import a { 9 | prefix a; 10 | } 11 | import b { 12 | prefix a; // LINE: YANG_ERR_GRAMMAR_DUPLICATE_PREFIX 13 | } 14 | 15 | organization "hopp"; 16 | contact "hej"; 17 | description "arne" + /* hmm*/ ' ' + 'anka'; 18 | revision "2008-01-01" { description "initinla"; } 19 | 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/lux/bad/xt3.yang: -------------------------------------------------------------------------------- 1 | module xt3 { 2 | namespace "http://tmp/foo/bar"; 3 | // prefix "xt3"; // error: prefix missing 4 | import xt4 { prefix xt4; } // LINE: YANG_ERR_GRAMMAR_EXPECTED_KEYWORD 5 | organization "hopp"; 6 | contact "hej"; 7 | description "arne" + /* hmm*/ ' ' + 'anka'; 8 | revision '2005-01-01' { description "initinla"; } 9 | 10 | extension test { 11 | argument name; 12 | } 13 | 14 | typedef bazInt { 15 | type int16; 16 | } 17 | 18 | typedef yt { 19 | type string { 20 | pattern "[x-y]"; 21 | } 22 | } 23 | 24 | typedef t0 { 25 | type xt4:yt { 26 | length "1..5 | 11..20"; 27 | pattern "[x-y]*"; 28 | } 29 | } 30 | 31 | extension hemm { 32 | argument data { 33 | yin-element true; 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /test/lux/cmdline/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/cmdline/warnings.lux: -------------------------------------------------------------------------------- 1 | [doc Test -W, -w, and -E] 2 | 3 | [shell yanger] 4 | !yanger warnings.yang 5 | -error: 6 | ?warning: the revision 7 | ?SH-PROMPT 8 | !echo ==$$?== 9 | ?==0== 10 | ?SH-PROMPT 11 | - 12 | 13 | !yanger -W error warnings.yang 14 | -warning: 15 | ?error: the revision 16 | ?SH-PROMPT 17 | !echo ==$$?== 18 | ?==1== 19 | ?SH-PROMPT 20 | - 21 | 22 | !yanger -E YANG_ERR_REVISION_ORDER warnings.yang 23 | -warning: 24 | ?error: the revision 25 | ?SH-PROMPT 26 | !echo ==$$?== 27 | ?==1== 28 | ?SH-PROMPT 29 | - 30 | 31 | !yanger -W error -W YANG_ERR_REVISION_ORDER warnings.yang 32 | -error: 33 | ?warning: the revision 34 | ?SH-PROMPT 35 | !echo ==$$?== 36 | ?==0== 37 | ?SH-PROMPT 38 | - 39 | 40 | !yanger -Wnone warnings.yang 41 | -warning: 42 | ?SH-PROMPT 43 | !echo ==$$?== 44 | ?==0== 45 | ?SH-PROMPT 46 | - 47 | 48 | !yanger -w YANG_ERR_REVISION_ORDER warnings.yang 49 | -warning: 50 | ?SH-PROMPT 51 | !echo ==$$?== 52 | ?==0== 53 | ?SH-PROMPT 54 | - 55 | 56 | !yanger -Werror -w YANG_ERR_REVISION_ORDER warnings.yang 57 | -warning: 58 | ?SH-PROMPT 59 | !echo ==$$?== 60 | ?==0== 61 | ?SH-PROMPT 62 | - 63 | 64 | -------------------------------------------------------------------------------- /test/lux/cmdline/warnings.yang: -------------------------------------------------------------------------------- 1 | module warnings { 2 | namespace urn:w; 3 | prefix w; 4 | 5 | revision 2001-04-01; 6 | revision 2010-04-01; 7 | 8 | } 9 | -------------------------------------------------------------------------------- /test/lux/conformance/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/conformance/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | typedef xref { 6 | type leafref { 7 | path "/a/x"; 8 | } 9 | } 10 | 11 | container a; 12 | 13 | augment /a { 14 | leaf x { 15 | type string; 16 | } 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /test/lux/conformance/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | 9 | augment /a:a { // this is an error if 'a' has conformance 'import' 10 | container b; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/lux/conformance/c.yang: -------------------------------------------------------------------------------- 1 | module c { 2 | namespace urn:c; 3 | prefix c; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | 9 | container c { 10 | leaf cxref { 11 | type a:xref; // this is an error if 'a' has conformance 'import' 12 | } 13 | leaf cxref2 { 14 | type leafref { 15 | path "/a:a/a:x"; // this is an error if 'a' has conformance 'import' 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/lux/conformance/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test --conformance flag] 2 | 3 | [shell compilation] 4 | -internal|module|error 5 | !yanger -f tree -C a:import -C b:import a.yang b.yang 6 | ?SH-PROMPT 7 | !yanger -f tree -C import a.yang b.yang 8 | ?SH-PROMPT 9 | -internal|error 10 | !yanger -f tree -C implement a.yang b.yang 11 | """?? 12 | module: a 13 | +--rw a 14 | +--rw x? string 15 | +--rw b:b 16 | SH-PROMPT 17 | """ 18 | -internal|b:b|error 19 | !yanger -f tree -C a:implement -C b:import a.yang b.yang 20 | """?? 21 | module: a 22 | +--rw a 23 | +--rw x? string 24 | SH-PROMPT 25 | """ 26 | !yanger -f tree -C b:import a.yang b.yang 27 | """?? 28 | module: a 29 | +--rw a 30 | +--rw x? string 31 | SH-PROMPT 32 | """ 33 | !yanger --print-error-code -C a:import a.yang b.yang 34 | -SH-PROMPT 35 | ?YANG_ERR_NODE_NOT_FOUND 36 | -YANG_ERR 37 | ?SH-PROMPT 38 | - 39 | !yanger --print-error-code -C a:import a.yang c.yang 40 | -SH-PROMPT 41 | ?YANG_ERR_NODE_NOT_FOUND2 42 | -YANG_ERR 43 | ?SH-PROMPT 44 | - -------------------------------------------------------------------------------- /test/lux/depend/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/depend/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | import b { 6 | prefix b; 7 | } 8 | import c { 9 | prefix c; 10 | } 11 | 12 | include d; 13 | include f; 14 | } 15 | -------------------------------------------------------------------------------- /test/lux/depend/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b1; 4 | 5 | import c { 6 | prefix c1; // NOTE: different prefix than in a.yang when b:b is used. 7 | } 8 | 9 | import e { 10 | prefix e; 11 | } 12 | 13 | include g; 14 | } 15 | -------------------------------------------------------------------------------- /test/lux/depend/c.yang: -------------------------------------------------------------------------------- 1 | module c { 2 | namespace urn:c; 3 | prefix c2; 4 | } 5 | -------------------------------------------------------------------------------- /test/lux/depend/d.yang: -------------------------------------------------------------------------------- 1 | submodule d { 2 | belongs-to a { 3 | prefix a; 4 | } 5 | 6 | include f; 7 | } 8 | -------------------------------------------------------------------------------- /test/lux/depend/e.yang: -------------------------------------------------------------------------------- 1 | module e { 2 | namespace urn:e; 3 | prefix e; 4 | 5 | import c { 6 | prefix c; // NOTE: different prefix than in a.yang when b:b is used. 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/lux/depend/f.yang: -------------------------------------------------------------------------------- 1 | submodule f { 2 | belongs-to a { 3 | prefix a; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/lux/depend/g.yang: -------------------------------------------------------------------------------- 1 | submodule g { 2 | belongs-to b { 3 | prefix b; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/lux/depend/run.lux: -------------------------------------------------------------------------------- 1 | [doc test depend plugin] 2 | 3 | [shell test] 4 | !yanger -f depend a.yang 5 | """?? 6 | a.yang : b c d f 7 | SH-PROMPT 8 | """ 9 | 10 | !yanger -f depend --depend-no-submodules a.yang 11 | """?? 12 | a.yang : b c 13 | SH-PROMPT 14 | """ 15 | 16 | !yanger -f depend --depend-no-submodules --depend-recurse a.yang 17 | """?? 18 | a.yang : b c e 19 | SH-PROMPT 20 | """ 21 | 22 | !yanger -f depend --depend-recurse a.yang 23 | """?? 24 | a.yang : b c d e f g 25 | SH-PROMPT 26 | """ 27 | 28 | !yanger -f depend --depend-recurse --depend-ignore-module b a.yang 29 | """?? 30 | a.yang : c d e f g 31 | SH-PROMPT 32 | """ 33 | 34 | !yanger -f depend --depend-recurse --depend-extension .test a.yang 35 | """?? 36 | a.yang : b.test c.test d.test e.test f.test g.test 37 | SH-PROMPT 38 | """ 39 | 40 | !yanger -f depend --depend-recurse --depend-include-path --depend-double-colon a.yang 41 | """?? 42 | a.yang :: b.yang c.yang d.yang e.yang f.yang g.yang 43 | SH-PROMPT 44 | """ 45 | 46 | !yanger -f depend --depend-recurse --depend-include-path --depend-extension .test a.yang 47 | """?? 48 | a.yang : b.test c.test d.test e.test f.test g.test 49 | SH-PROMPT 50 | """ 51 | 52 | !yanger -f depend --depend-target test_target a.yang 53 | """?? 54 | test_target : b c d f 55 | SH-PROMPT 56 | """ 57 | -------------------------------------------------------------------------------- /test/lux/deviations/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/deviations/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace "urn:a"; 3 | prefix a; 4 | 5 | import b { 6 | prefix b; 7 | } 8 | include asub; 9 | 10 | container x; 11 | 12 | augment /x { 13 | list bar { 14 | key foo; 15 | leaf foo { 16 | type int32; 17 | } 18 | leaf bar { 19 | type int32; 20 | mandatory true; 21 | } 22 | leaf baz { 23 | type string; 24 | } 25 | } 26 | } 27 | 28 | deviation /b:x { 29 | deviate replace { 30 | config false; 31 | } 32 | } 33 | deviation /b:x/b:r { 34 | deviate replace { 35 | mandatory false; 36 | type uint32 { 37 | range "0..1"; 38 | } 39 | } 40 | } 41 | 42 | deviation /x { 43 | deviate replace { 44 | config false; 45 | } 46 | } 47 | deviation /x/bar/baz { 48 | deviate not-supported; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/lux/deviations/asub.yang: -------------------------------------------------------------------------------- 1 | submodule asub { 2 | belongs-to a { 3 | prefix a; 4 | } 5 | 6 | import b { 7 | prefix b1; 8 | } 9 | deviation /b1:x/b1:u { 10 | deviate not-supported; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/lux/deviations/aug-dev-mand.lux: -------------------------------------------------------------------------------- 1 | [doc Test errors in aug-dev-mand.yang] 2 | 3 | [shell yanger] 4 | !export PS2=CONT: 5 | ?SH-PROMPT: 6 | !yanger --smiv2-detect-duplicate-oids --print-error-code \\ 7 | ?CONT: 8 | !aug-dev-mand.yang 2>&1 | grep aug-dev-mand.yang 9 | -SH-PROMPT 10 | """? 11 | aug-dev-mand.yang 2>&1 \| grep aug-dev-mand.yang 12 | aug-dev-mand.yang:11: (\(.*\): )?YANG_ERR_MANDATORY_NODE_IN_AUGMENT 13 | aug-dev-mand.yang:22: (\(.*\): )?YANG_ERR_MANDATORY_NODE_IN_AUGMENT 14 | """ 15 | # make sure there are no extra errors reported 16 | -aug-dev-mand.yang 17 | ?SH-PROMPT: 18 | 19 | # verify that a correctly formatted message is given w/o --print-error-code 20 | # (i.e. no crash, and no "unregistered" code) 21 | !yanger --smiv2-detect-duplicate-oids \\ 22 | ?CONT: 23 | !aug-dev-mand.yang 2>&1 | grep aug-dev-mand.yang 24 | -SH-PROMPT 25 | """? 26 | aug-dev-mand.yang 2>&1 \| grep aug-dev-mand.yang 27 | aug-dev-mand.yang:11: (\(.*\): )?(error|warning): \S+.* 28 | aug-dev-mand.yang:22: (\(.*\): )?(error|warning): \S+.* 29 | """ 30 | # make sure there are no extra errors reported 31 | -aug-dev-mand.yang 32 | ?SH-PROMPT: 33 | -------------------------------------------------------------------------------- /test/lux/deviations/aug-dev-mand.yang: -------------------------------------------------------------------------------- 1 | module aug-dev-mand { 2 | namespace urn:aug-dev-mand; 3 | prefix aug-dev-mand; 4 | 5 | import test-a { 6 | prefix t-a; 7 | } 8 | 9 | augment /t-a:it { 10 | container item { 11 | leaf name { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 12 | type string; 13 | } 14 | } 15 | container p { 16 | presence ""; 17 | leaf name { 18 | type string; 19 | mandatory false; 20 | } 21 | } 22 | list l { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 23 | key k; 24 | leaf k { 25 | type string; 26 | } 27 | } 28 | } 29 | 30 | // => mandatory augment 31 | deviation /t-a:it/item/name { 32 | deviate add { 33 | mandatory true; 34 | } 35 | } 36 | // no mandatory augment since p is presence container 37 | deviation /t-a:it/p/name { 38 | deviate replace { 39 | mandatory true; 40 | } 41 | } 42 | // => mandatory augment 43 | deviation /t-a:it/l { 44 | deviate add { 45 | min-elements 1; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/lux/deviations/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b; 4 | 5 | container x { 6 | leaf r { 7 | type string; 8 | mandatory true; 9 | } 10 | leaf u { 11 | type string; 12 | } 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/lux/deviations/bad-mand-augment.lux: -------------------------------------------------------------------------------- 1 | [doc Test that augment of mandatory node due to deviation is rejected] 2 | 3 | [shell yanger] 4 | !export PS2=CONT: 5 | ?SH-PROMPT: 6 | !yanger --deviation-module test-dev-mand.yang --print-error-code \\ 7 | ?CONT: 8 | !test.yang 2>&1 | grep test.yang 9 | -SH-PROMPT 10 | """? 11 | test.yang 2>&1 \| grep test.yang 12 | test.yang:11: (\(.*\): )?YANG_ERR_MANDATORY_NODE_IN_AUGMENT 13 | test.yang:22: (\(.*\): )?YANG_ERR_MANDATORY_NODE_IN_AUGMENT 14 | """ 15 | # make sure there are no extra errors reported 16 | -test.yang 17 | ?SH-PROMPT: 18 | 19 | - 20 | # verify that a correctly formatted message is given w/o --print-error-code 21 | # (i.e. no crash, and no "unregistered" code) 22 | !yanger --deviation-module test-dev-mand.yang \\ 23 | ?CONT: 24 | !test.yang 2>&1 | grep test.yang 25 | -SH-PROMPT 26 | """? 27 | test.yang 2>&1 \| grep test.yang 28 | test.yang:11: (\(.*\): )?(error|warning): \S+.* 29 | test.yang:22: (\(.*\): )?(error|warning): \S+.* 30 | """ 31 | # make sure there are no extra errors reported 32 | -test.yang 33 | ?SH-PROMPT: 34 | -------------------------------------------------------------------------------- /test/lux/deviations/bad.lux: -------------------------------------------------------------------------------- 1 | [doc Test errors in dt-dev.yang] 2 | 3 | # originally generated by ../bad/gen_lux.sh but required tweaks... 4 | 5 | [shell yanger] 6 | !export PS2=CONT: 7 | ?SH-PROMPT: 8 | !yanger --deviation-module dt-dev.yang --print-error-code \\ 9 | ?CONT: 10 | !dt.yang 2>&1 | grep dt-dev.yang 11 | -SH-PROMPT 12 | """? 13 | dt.yang 2>&1 \| grep dt-dev.yang 14 | dt-dev.yang:11: (\(.*\): )?YANG_ERR_NODE_NOT_FOUND 15 | dt-dev.yang:16: (\(.*\): )?YANG_ERR_BAD_DEVIATION 16 | dt-dev.yang:17: (\(.*\): )?YANG_ERR_BAD_DEVIATE_ADD 17 | dt-dev.yang:20: (\(.*\): )?YANG_ERR_BAD_DEVIATE_REPLACE_NOT_FOUND 18 | dt-dev.yang:21: (\(.*\): )?YANG_ERR_BAD_DEVIATE_REPLACE 19 | dt-dev.yang:24: (\(.*\): )?YANG_ERR_BAD_DEVIATE_DELETE 20 | """ 21 | # make sure there are no extra errors reported 22 | -dt.yang 23 | ?SH-PROMPT: 24 | 25 | # verify that a correctly formatted message is given w/o --print-error-code 26 | # (i.e. no crash, and no "unregistered" code) 27 | !yanger --deviation-module dt-dev.yang \\ 28 | ?CONT: 29 | !dt.yang 2>&1 | grep dt-dev.yang 30 | -SH-PROMPT 31 | """? 32 | dt.yang 2>&1 \| grep dt-dev.yang 33 | dt-dev.yang:11: (\(.*\): )?(error|warning): \S+.* 34 | dt-dev.yang:16: (\(.*\): )?(error|warning): \S+.* 35 | dt-dev.yang:17: (\(.*\): )?(error|warning): \S+.* 36 | dt-dev.yang:20: (\(.*\): )?(error|warning): \S+.* 37 | dt-dev.yang:21: (\(.*\): )?(error|warning): \S+.* 38 | dt-dev.yang:24: (\(.*\): )?(error|warning): \S+.* 39 | """ 40 | # make sure there are no extra errors reported 41 | -dt.yang 42 | ?SH-PROMPT: 43 | -------------------------------------------------------------------------------- /test/lux/deviations/bad.yang: -------------------------------------------------------------------------------- 1 | module bad { 2 | namespace urn:bad; 3 | prefix d; 4 | 5 | import b { 6 | prefix b; 7 | } 8 | 9 | container x { 10 | config true; 11 | } 12 | 13 | augment /x { 14 | list bar { 15 | key foo; 16 | leaf foo { 17 | type int32; 18 | } 19 | leaf bar { 20 | type int32; 21 | mandatory true; 22 | } 23 | } 24 | } 25 | 26 | deviation /b:x/b:r { 27 | deviate add { 28 | default hej; // error, doesn't match the new type 29 | } 30 | deviate replace { 31 | mandatory false; 32 | type uint32 { 33 | range "-1..1"; // error; bad range 34 | } 35 | } 36 | } 37 | 38 | extension foo; 39 | deviation "/x" { 40 | deviate "add" { 41 | d:foo; 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /test/lux/deviations/choice-def-case-chg.yang: -------------------------------------------------------------------------------- 1 | module choice-def-case-chg { 2 | namespace urn:dummy; 3 | prefix dummy; 4 | 5 | import choice-def-case { 6 | prefix cdc; 7 | } 8 | 9 | deviation "/cdc:foo/cdc:ch" { 10 | deviate replace { 11 | default ca3; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/lux/deviations/choice-def-case-dev.yang: -------------------------------------------------------------------------------- 1 | module choice-def-case-dev { 2 | namespace urn:dummy; 3 | prefix dummy; 4 | 5 | import choice-def-case { 6 | prefix cdc; 7 | } 8 | 9 | deviation "/cdc:foo/cdc:ch" { 10 | deviate delete { 11 | default ca1; 12 | } 13 | } 14 | 15 | deviation "/cdc:foo/cdc:ch/cdc:ca1" { 16 | deviate not-supported; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/lux/deviations/choice-def-case-rem.yang: -------------------------------------------------------------------------------- 1 | module choice-def-case-rem { 2 | namespace urn:dummy; 3 | prefix dummy; 4 | 5 | import choice-def-case { 6 | prefix cdc; 7 | } 8 | 9 | deviation "/cdc:foo/cdc:ch/cdc:ca1" { 10 | deviate not-supported; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/lux/deviations/choice-def-case.yang: -------------------------------------------------------------------------------- 1 | module choice-def-case { 2 | namespace urn:cdc; 3 | prefix cdc; 4 | 5 | container foo { 6 | leaf one { 7 | type string; 8 | } 9 | choice ch { 10 | default ca1; 11 | case ca1 { 12 | leaf bar { 13 | type string; 14 | } 15 | } 16 | case ca2 { 17 | leaf baz { 18 | type string; 19 | } 20 | } 21 | } 22 | leaf two { 23 | type string; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/lux/deviations/dev-def-case.lux: -------------------------------------------------------------------------------- 1 | [doc Test that deviation removing the default case in a choice is rejected] 2 | 3 | [shell yanger] 4 | !export PS2=CONT: 5 | ?SH-PROMPT: 6 | 7 | # 1. remove the default case node 8 | # - should give error for the choice 'default' statement 9 | 10 | !yanger --deviation-module choice-def-case-rem.yang --print-error-code \\ 11 | ?CONT: 12 | !choice-def-case.yang 2>&1 | grep choice-def-case.yang 13 | -SH-PROMPT 14 | """? 15 | choice-def-case.yang 2>&1 \| grep choice-def-case.yang 16 | choice-def-case.yang:10: (\(.*\): )?YANG_ERR_DEFAULT_CASE_NOT_FOUND 17 | """ 18 | # make sure there are no extra errors reported 19 | -choice-def-case.yang 20 | ?SH-PROMPT: 21 | 22 | - 23 | # verify that a correctly formatted message is given w/o --print-error-code 24 | # (i.e. no crash, and no "unregistered" code) 25 | !yanger --deviation-module choice-def-case-rem.yang \\ 26 | ?CONT: 27 | !choice-def-case.yang 2>&1 | grep choice-def-case.yang 28 | -SH-PROMPT 29 | """? 30 | choice-def-case.yang 2>&1 \| grep choice-def-case.yang 31 | choice-def-case.yang:10: (\(.*\): )?(error|warning): \S+.* 32 | """ 33 | # make sure there are no extra errors reported 34 | -choice-def-case.yang 35 | ?SH-PROMPT: 36 | 37 | # 2. remove the choice 'default' *and* default case node (in that order) 38 | # - should be OK 39 | 40 | !yanger --deviation-module choice-def-case-dev.yang --print-error-code \\ 41 | ?CONT: 42 | !choice-def-case.yang 2>&1 | grep choice-def-case.yang 43 | -SH-PROMPT 44 | """? 45 | choice-def-case.yang 2>&1 \| grep choice-def-case.yang 46 | """ 47 | # make sure there are no extra errors reported 48 | -choice-def-case.yang 49 | ?SH-PROMPT: 50 | 51 | - 52 | # verify that a correctly formatted message is given w/o --print-error-code 53 | # (i.e. no crash, and no "unregistered" code) 54 | !yanger --deviation-module choice-def-case-dev.yang \\ 55 | ?CONT: 56 | !choice-def-case.yang 2>&1 | grep choice-def-case.yang 57 | -SH-PROMPT 58 | """? 59 | choice-def-case.yang 2>&1 \| grep choice-def-case.yang 60 | """ 61 | # make sure there are no extra errors reported 62 | -choice-def-case.yang 63 | ?SH-PROMPT: 64 | 65 | # 3. change the choice 'default' to give a non-existent case node 66 | # - should give error for the choice 'default' statement _in the deviation_ 67 | 68 | !yanger --deviation-module choice-def-case-chg.yang --print-error-code \\ 69 | ?CONT: 70 | !choice-def-case.yang 2>&1 | grep 'choice-def-case.*.yang' 71 | -SH-PROMPT 72 | """? 73 | choice-def-case.yang 2>&1 \| grep 'choice-def-case.\*.yang' 74 | choice-def-case-chg.yang:11: (\(.*\): )?YANG_ERR_DEFAULT_CASE_NOT_FOUND 75 | """ 76 | # make sure there are no extra errors reported 77 | -choice-def-case.*.yang 78 | ?SH-PROMPT: 79 | 80 | - 81 | # verify that a correctly formatted message is given w/o --print-error-code 82 | # (i.e. no crash, and no "unregistered" code) 83 | !yanger --deviation-module choice-def-case-chg.yang \\ 84 | ?CONT: 85 | !choice-def-case.yang 2>&1 | grep 'choice-def-case.*.yang' 86 | -SH-PROMPT 87 | """? 88 | choice-def-case.yang 2>&1 \| grep 'choice-def-case.\*.yang' 89 | choice-def-case-chg.yang:11: (\(.*\): )?(error|warning): \S+.* 90 | """ 91 | # make sure there are no extra errors reported 92 | -choice-def-case.*.yang 93 | ?SH-PROMPT: 94 | -------------------------------------------------------------------------------- /test/lux/deviations/dev-key.lux: -------------------------------------------------------------------------------- 1 | [doc Verify that deviation removing a list key is rejected] 2 | 3 | [shell yanger] 4 | !export PS2=CONT: 5 | ?SH-PROMPT: 6 | 7 | # remove the key leaf 8 | # - should give error for the list 'key' statement 9 | 10 | !yanger --deviation-module list-dev.yang --print-error-code \\ 11 | ?CONT: 12 | !list.yang 2>&1 | grep list.yang 13 | -SH-PROMPT 14 | """? 15 | list.yang 2>&1 \| grep list.yang 16 | list.yang:6: (\(.*\): )?YANG_ERR_BAD_KEY 17 | """ 18 | # make sure there are no extra errors reported 19 | -list.yang 20 | ?SH-PROMPT: 21 | 22 | - 23 | # verify that a correctly formatted message is given w/o --print-error-code 24 | # (i.e. no crash, and no "unregistered" code) 25 | !yanger --deviation-module list-dev.yang \\ 26 | ?CONT: 27 | !list.yang 2>&1 | grep list.yang 28 | -SH-PROMPT 29 | """? 30 | list.yang 2>&1 \| grep list.yang 31 | list.yang:6: (\(.*\): )?(error|warning): \S+.* 32 | """ 33 | # make sure there are no extra errors reported 34 | -list.yang 35 | ?SH-PROMPT: 36 | -------------------------------------------------------------------------------- /test/lux/deviations/dev-type-xpath.lux: -------------------------------------------------------------------------------- 1 | [doc Test deviation that re-checks Xpath] 2 | 3 | [shell yanger] 4 | -error 5 | !yanger --deviation-module dev-type-xpath.yang simple.yang 6 | ?SH-PROMPT 7 | -------------------------------------------------------------------------------- /test/lux/deviations/dev-type-xpath.yang: -------------------------------------------------------------------------------- 1 | module dev-type-xpath { 2 | namespace "urn:dummy"; 3 | prefix dummy; 4 | 5 | import simple { prefix s1; } 6 | 7 | deviation "/s1:servers/s1:server/s1:port" { 8 | deviate replace { 9 | type uint16; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/lux/deviations/dev.yang: -------------------------------------------------------------------------------- 1 | module dev { 2 | namespace "urn:dummy"; 3 | prefix dummy; 4 | 5 | import simple { prefix s1; } 6 | 7 | deviation "/s1:servers/s1:server/s1:name" { 8 | deviate add { 9 | must "current() < no-existing"; 10 | } 11 | } 12 | 13 | deviation "/s1:servers/s1:server/s1:port" { 14 | deviate delete { 15 | must ". < 1024"; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/lux/deviations/dt-dev.yang: -------------------------------------------------------------------------------- 1 | module dt-dev { 2 | namespace urn:dummy; 3 | prefix dummy; 4 | 5 | // YANGER_EXTRA_FLAGS: dt.yang --deviation-module 6 | 7 | import dt { 8 | prefix dt; 9 | } 10 | 11 | deviation /dt:foo/dt:baz { // LINE: YANG_ERR_NODE_NOT_FOUND 12 | deviate not-supported; 13 | } 14 | deviation /dt:foo/dt:bar { 15 | deviate add { 16 | max-elements 3; // LINE: YANG_ERR_BAD_DEVIATION 17 | type string; // LINE: YANG_ERR_BAD_DEVIATE_ADD 18 | } 19 | deviate replace { 20 | default 42; // LINE: YANG_ERR_BAD_DEVIATE_REPLACE_NOT_FOUND 21 | must ". = 42"; // LINE: YANG_ERR_BAD_DEVIATE_REPLACE 22 | } 23 | deviate delete { 24 | must ". = 42"; // LINE: YANG_ERR_BAD_DEVIATE_DELETE 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/lux/deviations/dt.yang: -------------------------------------------------------------------------------- 1 | module dt { 2 | namespace urn:dt; 3 | prefix dt; 4 | 5 | container foo { 6 | leaf bar { 7 | type int32; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/lux/deviations/list-dev.yang: -------------------------------------------------------------------------------- 1 | module list-dev { 2 | namespace urn:dev; 3 | prefix dev; 4 | 5 | import list { 6 | prefix list; 7 | } 8 | 9 | deviation /list:foo/list:baz { 10 | deviate not-supported; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/lux/deviations/list.yang: -------------------------------------------------------------------------------- 1 | module list { 2 | namespace urn:list; 3 | prefix list; 4 | 5 | list foo { 6 | key "bar baz"; 7 | leaf bar { 8 | type string; 9 | } 10 | leaf baz { 11 | type string; 12 | } 13 | leaf foobar { 14 | type string; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/lux/deviations/run.lux: -------------------------------------------------------------------------------- 1 | [doc test deviations] 2 | 3 | [shell test] 4 | -==0== 5 | !yanger -Werror --deviation-module dev.yang simple.yang 6 | !echo ==$$?== 7 | ?==1== 8 | ?SH-PROMPT 9 | 10 | [shell test] 11 | !yanger --deviation-module a.yang -f tree b.yang 12 | # make sure only module b is printed 13 | -module: a 14 | """?? 15 | module: b 16 | +--ro x 17 | +--ro r? uint32 18 | """ 19 | ?SH-PROMPT 20 | - 21 | 22 | !yanger -f tree a.yang 23 | """?? 24 | module: a 25 | +--ro x 26 | +--ro bar* [foo] 27 | +--ro foo int32 28 | +--ro bar int32 29 | """ 30 | 31 | [shell test] 32 | [doc test that validation is done on the refined statements] 33 | !yanger --print-error-code --deviation-module bad.yang b.yang 34 | ?bad.yang:\d+: YANG_ERR_TYPE_VALUE 35 | ?bad.yang:\d+: YANG_ERR_BAD_RANGE_VALUE 36 | -bad.yang 37 | ?SH-PROMPT 38 | -------------------------------------------------------------------------------- /test/lux/deviations/simple.yang: -------------------------------------------------------------------------------- 1 | module simple { 2 | namespace "http://tail-f.com/ns/simple"; 3 | prefix s1; 4 | 5 | import ietf-inet-types { 6 | prefix inet; 7 | } 8 | 9 | container servers { 10 | list server { 11 | key name; 12 | leaf name { type int16; } 13 | leaf ip { 14 | type inet:ip-address; 15 | } 16 | leaf port { 17 | type inet:port-number; 18 | must ". < 1024"; 19 | when "../name"; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/lux/deviations/test-a.yang: -------------------------------------------------------------------------------- 1 | module test-a { 2 | namespace "http://test-a"; 3 | prefix t-a; 4 | 5 | container it; 6 | } 7 | -------------------------------------------------------------------------------- /test/lux/deviations/test-dev-mand.yang: -------------------------------------------------------------------------------- 1 | module test-dev-mand { 2 | namespace "http://test-devm"; 3 | prefix test-devm; 4 | 5 | import test { 6 | prefix t; 7 | } 8 | import test-a { 9 | prefix t-a; 10 | } 11 | 12 | // => mandatory augment 13 | deviation /t-a:it/t:item/t:name { 14 | deviate add { 15 | mandatory true; 16 | } 17 | } 18 | // no mandatory augment since p is presence container 19 | deviation /t-a:it/t:p/t:name { 20 | deviate replace { 21 | mandatory true; 22 | } 23 | } 24 | // => mandatory augment 25 | deviation /t-a:it/t:l { 26 | deviate add { 27 | min-elements 1; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/lux/deviations/test.yang: -------------------------------------------------------------------------------- 1 | module test { 2 | namespace "http://test"; 3 | prefix t; 4 | 5 | import test-a { 6 | prefix t-a; 7 | } 8 | 9 | augment /t-a:it { 10 | container item { 11 | leaf name { 12 | type string; 13 | } 14 | } 15 | container p { 16 | presence ""; 17 | leaf name { 18 | type string; 19 | mandatory false; 20 | } 21 | } 22 | list l { 23 | key k; 24 | leaf k { 25 | type string; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/lux/eng-25448_deviated_type_scope/Makefile: -------------------------------------------------------------------------------- 1 | 2 | build: 3 | lux run.lux 4 | 5 | clean: 6 | rm -f *.fxs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/eng-25448_deviated_type_scope/cli-server.yang: -------------------------------------------------------------------------------- 1 | module cli-server { 2 | 3 | yang-version 1.1; 4 | 5 | namespace "urn:example"; 6 | prefix x; 7 | 8 | import ietf-inet-types { 9 | prefix inet; 10 | } 11 | import ietf-tcp-server { 12 | prefix tcps; 13 | } 14 | 15 | typedef ssh-port-number { 16 | type inet:port-number { 17 | range "22 | 1024..49151 | 49500..max"; 18 | } 19 | } 20 | 21 | grouping ssh-server-stack-grouping { 22 | container ssh { 23 | container tcp-server-parameters { 24 | uses tcps:tcp-server-grouping { 25 | refine "local-port" { 26 | default "22"; 27 | } 28 | } 29 | } 30 | } /* container ssh */ 31 | } /* grouping ssh-server-stack-grouping */ 32 | 33 | grouping cli-server-listen-stack-grouping { 34 | leaf enabled { 35 | type boolean; 36 | default false; 37 | } 38 | choice transport { 39 | case ssh { 40 | uses ssh-server-stack-grouping; 41 | } 42 | } 43 | } /* cli-server-listen-stack-grouping */ 44 | 45 | grouping cli-server-app-grouping { 46 | container listen { 47 | leaf idle-timeout { 48 | type uint32; 49 | units "seconds"; 50 | default 900; 51 | } 52 | list endpoint { 53 | key name; 54 | leaf name { 55 | type string { 56 | length "1 .. 32"; 57 | } 58 | } 59 | uses cli-server-listen-stack-grouping; 60 | } 61 | } 62 | } /* grouping cli-server-app-grouping */ 63 | 64 | container cli-server { 65 | uses cli-server-app-grouping; 66 | } /* container cli-server */ 67 | 68 | deviation "/cli-server/listen/endpoint/transport/ssh/ssh/tcp-server-parameters/local-port" { 69 | deviate replace { 70 | type ssh-port-number; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /test/lux/eng-25448_deviated_type_scope/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test local typedef can be found in deviation] 2 | 3 | [shell yanger] 4 | -error 5 | !yanger cli-server.yang 6 | !echo ==$$?== 7 | ?==0== 8 | -------------------------------------------------------------------------------- /test/lux/eng16248/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/eng16248/a-aug-dev.yang: -------------------------------------------------------------------------------- 1 | module a-aug-dev { 2 | namespace urn:a-aug-dev; 3 | prefix aad; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | import a-aug { 9 | prefix b; 10 | } 11 | 12 | deviation /a:a/b:a { 13 | deviate add { 14 | unique v1; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/lux/eng16248/a-aug.yang: -------------------------------------------------------------------------------- 1 | module a-aug { 2 | namespace urn:a-aug; 3 | prefix aa; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | 9 | augment /a:a { 10 | list a { 11 | key k; 12 | leaf k { 13 | type string; 14 | } 15 | leaf v1 { 16 | type string; 17 | } 18 | leaf v2 { 19 | type string; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/lux/eng16248/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | container a; 6 | } 7 | -------------------------------------------------------------------------------- /test/lux/eng16248/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test deviation "add unique" of augmenting module using different prefix] 2 | 3 | [shell compilation] 4 | -[Ee][Rr][Rr][Oo][Rr] 5 | !yanger --deviation-module a-aug-dev.yang a-aug.yang 6 | !echo ==$$?== 7 | ?==0== 8 | -------------------------------------------------------------------------------- /test/lux/eng17483/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/eng17483/a-aug-dev.yang: -------------------------------------------------------------------------------- 1 | module a-aug-dev { 2 | namespace urn:a-aug-dev; 3 | prefix aad; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | import a-aug { 9 | prefix aa; 10 | } 11 | import b { 12 | prefix b; 13 | } 14 | 15 | deviation /a:a/aa:a { 16 | deviate add { 17 | must "k > /b:b"; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/eng17483/a-aug.yang: -------------------------------------------------------------------------------- 1 | module a-aug { 2 | namespace urn:a-aug; 3 | prefix aa; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | 9 | augment /a:a { 10 | list a { 11 | key k; 12 | leaf k { 13 | type int32; 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/lux/eng17483/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | container a; 6 | } 7 | -------------------------------------------------------------------------------- /test/lux/eng17483/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b; 4 | 5 | leaf b { 6 | type int32; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/lux/eng17483/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test deviation that adds a must expression to augmented node, using prefix defined in the deviation module] 2 | 3 | [shell compilation] 4 | -[Ee][Rr][Rr][Oo][Rr] 5 | !yanger --deviation-module a-aug-dev.yang a-aug.yang 6 | !echo ==$$?== 7 | ?==0== 8 | -------------------------------------------------------------------------------- /test/lux/eng17783/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/eng17783/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test that missing module name gives correct error] 2 | 3 | 4 | [shell compilation] 5 | !yanger --print-error-code test.yang 2>&1 6 | !echo ==$$?== 7 | ?YANG_ERR_GRAMMAR_MISSING_ARGUMENT 8 | ?==1== 9 | -------------------------------------------------------------------------------- /test/lux/eng17783/test.yang: -------------------------------------------------------------------------------- 1 | module { 2 | namespace "http://tail-f.com/test"; 3 | prefix "test"; 4 | container test { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/lux/eng18062/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/eng18062/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test that typedef in submodule is properly validated] 2 | 3 | [shell compilation] 4 | -==1== 5 | !yanger --print-error-code x.yang 2>&1 6 | !echo ==$$?== 7 | ?==0== 8 | -------------------------------------------------------------------------------- /test/lux/eng18062/x-base.yang: -------------------------------------------------------------------------------- 1 | submodule x-base { 2 | yang-version 1.1; 3 | belongs-to x { 4 | prefix x; 5 | } 6 | 7 | container base { 8 | container prof { 9 | } 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/lux/eng18062/x-foo.yang: -------------------------------------------------------------------------------- 1 | submodule x-foo { 2 | yang-version 1.1; 3 | belongs-to x { 4 | prefix x; 5 | } 6 | 7 | include x-base; 8 | include x-point; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /test/lux/eng18062/x-point.yang: -------------------------------------------------------------------------------- 1 | submodule x-point { 2 | yang-version 1.1; 3 | belongs-to x { 4 | prefix x; 5 | } 6 | 7 | include x-prof; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /test/lux/eng18062/x-prof.yang: -------------------------------------------------------------------------------- 1 | submodule x-prof { 2 | yang-version 1.1; 3 | belongs-to x { 4 | prefix x; 5 | } 6 | 7 | include x-base; 8 | 9 | typedef prof-ref { 10 | type leafref { 11 | path '/x:base/x:prof/x:foo-prof/x:name'; 12 | } 13 | } 14 | 15 | augment '/x:base/x:prof' { 16 | list foo-prof { 17 | key "name"; 18 | leaf name { 19 | type string; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/lux/eng18062/x.yang: -------------------------------------------------------------------------------- 1 | module x { 2 | yang-version 1.1; 3 | namespace "urn:x"; 4 | prefix x; 5 | 6 | include x-base; 7 | include x-point; 8 | include x-foo; 9 | include x-prof; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /test/lux/eng21093/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/eng21093/a-dev.yang: -------------------------------------------------------------------------------- 1 | module a-dev { 2 | yang-version 1.1; 3 | namespace "urn:example:a-dev"; 4 | prefix adev; 5 | 6 | import a { 7 | prefix a; 8 | } 9 | 10 | deviation "/a:test/a:foo" { 11 | deviate delete { 12 | mandatory true; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/lux/eng21093/a-dev2.yang: -------------------------------------------------------------------------------- 1 | module a-dev2 { 2 | yang-version 1.1; 3 | namespace "urn:example:a-dev2"; 4 | prefix adev2; 5 | 6 | import a { 7 | prefix a; 8 | } 9 | 10 | deviation "/a:test/a:foo" { 11 | deviate not-supported { 12 | mandatory true; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/lux/eng21093/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | yang-version 1.1; 3 | namespace "urn:example:a"; 4 | prefix a; 5 | 6 | container test { 7 | leaf foo { 8 | type string; 9 | mandatory true; 10 | } 11 | leaf bar { 12 | type int32; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/lux/eng21093/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test that deviation delete of mandatory gives error] 2 | 3 | 4 | [shell compilation] 5 | !yanger --print-error-code --deviation-module a-dev.yang a.yang 2>&1 6 | -==0== 7 | !echo ==$$?== 8 | ?YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 9 | ?==1== 10 | 11 | !yanger --print-error-code --deviation-module a-dev2.yang a.yang 2>&1 12 | -==0== 13 | !echo ==$$?== 14 | ?YANG_ERR_GRAMMAR_UNEXPECTED_KEYWORD 15 | ?==1== 16 | -------------------------------------------------------------------------------- /test/lux/eng21900-typedef-leafref-points-to-disabled-node/ENG-21900-1.yang: -------------------------------------------------------------------------------- 1 | module ENG-21900-1 { 2 | yang-version 1.1; 3 | namespace "http://tail-f.com/eng-21900-1"; 4 | prefix eng-1; 5 | 6 | feature enabled-feature; 7 | feature disabled-feature; 8 | 9 | typedef typedef-leafref-no-prefix { 10 | type leafref { 11 | require-instance false; 12 | path "/the-container/the-list/the-leaf"; 13 | } 14 | } 15 | 16 | typedef typedef-leafref-has-prefix { 17 | type leafref { 18 | require-instance false; 19 | path "/eng-1:the-container/eng-1:the-list/eng-1:the-leaf"; 20 | } 21 | } 22 | 23 | typedef typedef-uses-typedef-leafref { 24 | type typedef-leafref-no-prefix; 25 | } 26 | 27 | container the-container { 28 | list the-list { 29 | if-feature "disabled-feature"; 30 | key name; 31 | leaf name { 32 | type string; 33 | } 34 | leaf the-leaf { 35 | type string; 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/lux/eng21900-typedef-leafref-points-to-disabled-node/ENG-21900-2.yang: -------------------------------------------------------------------------------- 1 | module ENG-21900-2 { 2 | yang-version 1.1; 3 | namespace "http://tail-f.com/eng-21900-2"; 4 | prefix eng-2; 5 | 6 | import ENG-21900-1 { 7 | prefix eng-1; 8 | } 9 | 10 | feature enabled-feature; 11 | feature disabled-feature; 12 | 13 | typedef typedef-leafref { 14 | type leafref { 15 | require-instance false; 16 | path "/the-container/the-list/the-leaf"; 17 | } 18 | description 19 | "If typedef has bad-path, we should NOT report error."; 20 | } 21 | 22 | leaf bad-path-no-prefix { 23 | type leafref { 24 | require-instance false; 25 | path "/the-container/the-list/the-leaf"; 26 | } 27 | description 28 | "If a node has bad-path, make sure we report error."; 29 | } 30 | 31 | leaf bad-path-has-prefix { 32 | type leafref { 33 | require-instance false; 34 | path "/eng-2:the-container/eng-2:the-list/eng-2:the-leaf"; 35 | } 36 | description 37 | "If a node has bad-path, make sure we report error."; 38 | } 39 | 40 | leaf uses-typedef-1 { 41 | type typedef-leafref; 42 | description 43 | "If a node uses typedef has bad-path, we should report error."; 44 | } 45 | 46 | leaf uses-typedef-2 { 47 | type typedef-leafref; 48 | description 49 | "If many node uses one typedef has bad-path, 50 | make sure we only report the error once."; 51 | } 52 | 53 | leaf uses-imported-typedef-no-prefix { 54 | type eng-1:typedef-leafref-no-prefix; 55 | } 56 | 57 | leaf uses-imported-typedef-has-prefix { 58 | type eng-1:typedef-leafref-has-prefix; 59 | } 60 | 61 | container the-container { 62 | list the-list { 63 | if-feature "disabled-feature"; 64 | key name; 65 | leaf name { 66 | type string; 67 | } 68 | leaf the-leaf { 69 | type string; 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /test/lux/eng21900-typedef-leafref-points-to-disabled-node/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/eng21900-typedef-leafref-points-to-disabled-node/run.lux: -------------------------------------------------------------------------------- 1 | [doc] 2 | Handle validation of path in leafref 3 | 4 | If there is a typedef leafref, points to non-existent node, then 5 | Yanger shall silently ignore the typedef if no node uses the typedef. 6 | Yanger shall report an error if there is node using the typedef. 7 | [enddoc] 8 | 9 | ################################################################################ 10 | 11 | [shell yanger] 12 | -==1== 13 | !yanger ENG-21900-1.yang 14 | !echo ==$$?== 15 | ?==0== 16 | 17 | !yanger ENG-21900-2.yang 18 | !echo ==$$?== 19 | ?==0== 20 | 21 | !yanger -F ENG-21900-1:enabled-feature ENG-21900-1.yang 22 | !echo ==$$?== 23 | ?==0== 24 | 25 | -==0== 26 | !yanger --print-error-code -F ENG-21900-1:enabled-feature ENG-21900-2.yang 27 | ?ENG-21900-1.yang:19: YANG_ERR_NODE_NOT_FOUND3 28 | !echo ==$$?== 29 | ?==1== 30 | 31 | !yanger --print-error-code -F ENG-21900-2:enabled-feature ENG-21900-2.yang 32 | ?ENG-21900-2.yang:16: YANG_ERR_NODE_NOT_FOUND3 33 | ?ENG-21900-2.yang:25: YANG_ERR_NODE_NOT_FOUND3 34 | ?ENG-21900-2.yang:34: YANG_ERR_NODE_NOT_FOUND3 35 | !echo ==$$?== 36 | ?==1== 37 | -------------------------------------------------------------------------------- /test/lux/expand/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/expand/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | description 6 | "string with unicode chars ö Ὗ and \" \\ x\n \t escapes 7 | line 2 with escape \" å. 8 | line 3"; 9 | 10 | rpc rpc1 { 11 | input { 12 | container x; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/lux/expand/bar-sub1.yang: -------------------------------------------------------------------------------- 1 | submodule bar-sub1 { 2 | belongs-to bar { 3 | prefix bar; 4 | } 5 | 6 | import ietf-inet-types { 7 | prefix in; 8 | } 9 | 10 | import ietf-yang-types { 11 | prefix yang; 12 | } 13 | 14 | container sub1-stuff { 15 | leaf address { 16 | type in:ipv4-address; 17 | } 18 | leaf time-of-action { 19 | type yang:date-and-time; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/lux/expand/bar.yang: -------------------------------------------------------------------------------- 1 | module bar { 2 | namespace "urn:bar"; 3 | prefix bar; 4 | 5 | include bar-sub1; 6 | 7 | import ietf-inet-types { 8 | prefix inet; 9 | } 10 | 11 | container stuff { 12 | leaf address { 13 | type inet:ipv4-address; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/lux/expand/foo.yang: -------------------------------------------------------------------------------- 1 | module foo { 2 | namespace "urn:foo"; 3 | prefix foo; 4 | 5 | typedef mytype { 6 | type string; 7 | } 8 | 9 | container foo { 10 | list bar { 11 | key k; 12 | leaf k { 13 | type string; 14 | } 15 | uses hello; 16 | uses goodbye; 17 | leaf bazinga { 18 | type int64; 19 | } 20 | } 21 | } 22 | 23 | grouping hello { 24 | leaf hello-1 { 25 | type mytype; 26 | } 27 | typedef type2 { 28 | type string; 29 | } 30 | leaf hello-2 { 31 | type type2; 32 | } 33 | } 34 | grouping goodbye { 35 | typedef type2 { 36 | type uint32; 37 | } 38 | leaf hello-3 { 39 | type type2; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/lux/expand/foo2.yang: -------------------------------------------------------------------------------- 1 | module foo2 { 2 | namespace "urn:foo2"; 3 | prefix foo2; 4 | 5 | import ietf-inet-types { 6 | prefix inet; 7 | } 8 | 9 | import ietf-yang-types { 10 | prefix yang; 11 | } 12 | 13 | typedef mytype { 14 | type string; 15 | } 16 | 17 | container foo { 18 | list bar { 19 | key k; 20 | leaf k { 21 | type string; 22 | } 23 | uses hello; 24 | leaf value { 25 | type uint32 { 26 | range "1..42"; 27 | } 28 | default 42; 29 | } 30 | leaf ip-address { 31 | type inet:ipv4-address; 32 | } 33 | } 34 | } 35 | container bar { 36 | leaf baz { 37 | type uint64; 38 | } 39 | list interface { 40 | key "address prefix"; 41 | leaf address { 42 | type inet:ipv4-address; 43 | } 44 | leaf prefix { 45 | type uint32 { 46 | range 0..32; 47 | } 48 | } 49 | } 50 | } 51 | grouping hello { 52 | leaf hello-1 { 53 | type mytype; 54 | } 55 | typedef type2 { 56 | type string; 57 | default "foobar"; 58 | } 59 | leaf hello-2 { 60 | type type2 { 61 | length 0..64; 62 | } 63 | default "baz"; 64 | } 65 | leaf hello-4 { 66 | type type2; 67 | } 68 | } 69 | 70 | container stats { 71 | config false; 72 | 73 | leaf counter1 { 74 | type yang:counter64; 75 | } 76 | leaf-list knobs { 77 | type enumeration { 78 | enum "a"; 79 | enum "b"; 80 | enum "c"; 81 | enum "d"; 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /test/lux/expand/grp2.yang: -------------------------------------------------------------------------------- 1 | module grp2 { 2 | namespace "urn:grp2"; 3 | prefix grp2; 4 | 5 | import ietf-inet-types { 6 | prefix inet; 7 | } 8 | 9 | typedef key-attribute-string-type { 10 | type string; 11 | } 12 | 13 | typedef ipv4addr { 14 | type union { 15 | type inet:ipv4-address; 16 | type string; 17 | } 18 | } 19 | 20 | grouping apply-group { 21 | leaf-list apply-groups { 22 | ordered-by user; 23 | type string; 24 | } 25 | leaf-list apply-groups-except { 26 | ordered-by user; 27 | type string; 28 | } 29 | } 30 | 31 | container configuration { 32 | uses apply-group; 33 | list groups { 34 | ordered-by user; 35 | key "name"; 36 | leaf name { 37 | type string; 38 | } 39 | uses top-configuration; 40 | } 41 | uses top-configuration; 42 | } 43 | 44 | grouping top-configuration { 45 | leaf version { 46 | type string; 47 | description 48 | "Software version information"; 49 | } 50 | container system { 51 | description 52 | "System parameters"; 53 | uses juniper-system; 54 | } 55 | container chassis { 56 | description 57 | "Chassis configuration"; 58 | uses chassis-type; 59 | } 60 | } 61 | 62 | grouping juniper-system { 63 | uses apply-group; 64 | leaf host-name { 65 | type string; 66 | } 67 | container ntp { 68 | uses apply-group; 69 | } 70 | container backup-router { 71 | presence ""; 72 | leaf address { 73 | mandatory true; 74 | type ipv4addr; 75 | } 76 | leaf-list destination { 77 | type uint32; 78 | ordered-by user; 79 | } 80 | } 81 | } 82 | 83 | grouping chassis-type { 84 | uses apply-group; 85 | container nssu { 86 | presence "enable nssu"; 87 | description 88 | "Nonstop Software Upgrade settings"; 89 | uses apply-group; 90 | list upgrade-group { 91 | key "name"; 92 | ordered-by user; 93 | description 94 | "Nonstop Software Upgrade group"; 95 | leaf name { 96 | type key-attribute-string-type { 97 | length "1 .. 254"; 98 | } 99 | } 100 | uses apply-group; 101 | leaf-list fpcs { 102 | max-elements "16"; 103 | description 104 | "FPCs associated with update-group"; 105 | type uint32 { 106 | range "0 .. 31"; 107 | } 108 | } 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /test/lux/expand/identity.lux: -------------------------------------------------------------------------------- 1 | [doc minimal test, an expanded module should be equal to itself after second expansion] 2 | 3 | 4 | [macro identity MODULE] 5 | - 6 | !rm -f _tmp_*_${MODULE} 7 | ?SH-PROMPT 8 | -error: 9 | !yanger -f yang -t expand -o _tmp_1_${MODULE} ${MODULE} 10 | ?SH-PROMPT 11 | !echo ==$$?== 12 | ?==0== 13 | ?SH-PROMPT 14 | 15 | !yanger -f yang -t expand -o _tmp_2_${MODULE} _tmp_1_${MODULE} 16 | ?SH-PROMPT 17 | !echo ==$$?== 18 | ?==0== 19 | ?SH-PROMPT 20 | 21 | !diff -u _tmp_1_${MODULE} _tmp_2_${MODULE} 22 | ?SH-PROMPT 23 | !echo ==$$?== 24 | ?==0== 25 | ?SH-PROMPT 26 | - 27 | [endmacro] 28 | 29 | 30 | [shell test] 31 | # foo.yang, bar.yang, foo2.yang all fail b/c of bugs w/ expand 32 | [invoke identity grp2.yang] 33 | [invoke identity q.yang] 34 | [invoke identity a.yang] 35 | -------------------------------------------------------------------------------- /test/lux/expand/minmax.lux: -------------------------------------------------------------------------------- 1 | [doc Verify that yanger -t expand preserves min-elements/max-elements] 2 | 3 | [shell test] 4 | !yanger -t expand -f yang minmax.yang 5 | """??? 6 | module minmax { 7 | namespace "urn:minmax"; 8 | prefix mm; 9 | 10 | list l { 11 | max-elements 3; 12 | key k; 13 | leaf k { 14 | type int32; 15 | } 16 | leaf-list ll { 17 | min-elements 2; 18 | type int32; 19 | } 20 | } 21 | } 22 | """ 23 | ?SH-PROMPT 24 | !echo ==$$?== 25 | ?==0== 26 | ?SH-PROMPT 27 | -------------------------------------------------------------------------------- /test/lux/expand/minmax.yang: -------------------------------------------------------------------------------- 1 | module minmax { 2 | namespace urn:minmax; 3 | prefix mm; 4 | 5 | grouping g { 6 | leaf-list ll { 7 | type int32; 8 | min-elements 2; 9 | } 10 | } 11 | 12 | list l { 13 | key k; 14 | max-elements 3; 15 | leaf k { 16 | type int32; 17 | } 18 | uses g; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/expand/nocrash.lux: -------------------------------------------------------------------------------- 1 | [doc minimal test, expanding a module should not crash] 2 | 3 | 4 | [macro expand MODULE] 5 | [progress ${MODULE}] 6 | - 7 | !rm -f _tmp_*_${MODULE} 8 | ?SH-PROMPT 9 | -[Ee]rror 10 | !yanger -f yang -t expand -o _tmp_1_${MODULE} ${MODULE} 11 | ?SH-PROMPT 12 | -==[1-9][0-9]*== 13 | !echo ==$$?== 14 | ?==0== 15 | ?SH-PROMPT 16 | 17 | [endmacro] 18 | 19 | 20 | [shell test] 21 | [invoke expand grp2.yang] 22 | [invoke expand q.yang] 23 | [invoke expand a.yang] 24 | [invoke expand foo.yang] 25 | [invoke expand foo2.yang] 26 | [invoke expand bar.yang] 27 | 28 | -------------------------------------------------------------------------------- /test/lux/expand/q.yang: -------------------------------------------------------------------------------- 1 | module q { 2 | 3 | 4 | namespace "urn:q"; 5 | prefix "q"; 6 | 7 | 8 | 9 | 10 | description "Foo" + " bar 11 | baz bong. 12 | 13 | Hello. 14 | 15 | "; 16 | 17 | container "foo" + "-" + "bar" { 18 | leaf 19 | "fff_ggg" { type "u" + "int32"; } uses blurb; 20 | } 21 | grouping blurb { leaf 22 | blurb { type 'str' + 23 | 'ing' 24 | ; 25 | description 26 | " 27 | x 28 | " 29 | ; 30 | }}} -------------------------------------------------------------------------------- /test/lux/features/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/features/f.yang: -------------------------------------------------------------------------------- 1 | module f { 2 | namespace urn:f; 3 | prefix f; 4 | 5 | feature a; 6 | feature b; 7 | feature c; 8 | 9 | container f { 10 | container a { 11 | if-feature a; 12 | } 13 | container b { 14 | if-feature b; 15 | } 16 | container c { 17 | if-feature c; 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test/lux/features/g.yang: -------------------------------------------------------------------------------- 1 | module g { 2 | namespace urn:g; 3 | prefix g; 4 | 5 | import f { 6 | prefix f; 7 | } 8 | 9 | feature a; 10 | 11 | container g { 12 | container a { 13 | if-feature a; 14 | } 15 | container fa { 16 | if-feature f:a; 17 | } 18 | container fb { 19 | if-feature f:b; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /test/lux/features/run.lux: -------------------------------------------------------------------------------- 1 | [doc test features] 2 | 3 | [shell test] 4 | !yanger -f tree --features f:a f.yang 5 | """?? 6 | module: f 7 | +--rw f 8 | +--rw a {a}? 9 | SH-PROMPT 10 | """ 11 | 12 | !yanger -f tree --features f:a,c f.yang 13 | """?? 14 | module: f 15 | +--rw f 16 | +--rw a {a}? 17 | +--rw c {c}? 18 | SH-PROMPT 19 | """ 20 | 21 | !yanger -f tree --features f:a --features f:c f.yang 22 | """?? 23 | module: f 24 | +--rw f 25 | +--rw a {a}? 26 | +--rw c {c}? 27 | SH-PROMPT 28 | """ 29 | 30 | !yanger -f tree --features f:a g.yang 31 | """?? 32 | module: g 33 | +--rw g 34 | +--rw a {a}? 35 | +--rw fa {f:a}? 36 | SH-PROMPT 37 | """ 38 | 39 | !yanger -f tree --features f: g.yang 40 | """?? 41 | module: g 42 | +--rw g 43 | +--rw a {a}? 44 | SH-PROMPT 45 | """ 46 | 47 | !yanger -f tree --features g:a g.yang 48 | """?? 49 | module: g 50 | +--rw g 51 | +--rw a {a}? 52 | +--rw fa {f:a}? 53 | +--rw fb {f:b}? 54 | SH-PROMPT 55 | """ 56 | -------------------------------------------------------------------------------- /test/lux/groupings/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/groupings/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | grouping EXTERNAL-OUT { 6 | leaf external-out { 7 | type boolean; 8 | } 9 | } 10 | 11 | grouping AREA-TABLE { 12 | 13 | grouping AREA-CONTENT { 14 | uses EXTERNAL-OUT; 15 | } 16 | 17 | uses AREA-CONTENT; 18 | } 19 | 20 | container ospf { 21 | uses AREA-TABLE; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /test/lux/groupings/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | yang-version 1.1; 3 | namespace "urn:b"; 4 | prefix b; 5 | 6 | grouping x { 7 | container xx; 8 | } 9 | 10 | grouping u { 11 | container uu; 12 | } 13 | 14 | grouping v { 15 | uses u; 16 | container vv; 17 | } 18 | 19 | grouping y { 20 | uses x { 21 | augment xx { 22 | uses v; 23 | } 24 | } 25 | } 26 | 27 | container q { 28 | uses y; 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test/lux/groupings/run.lux: -------------------------------------------------------------------------------- 1 | [doc test grouping expansion] 2 | 3 | [shell test] 4 | !yanger -f tree a.yang 5 | """?? 6 | module: a 7 | +--rw ospf 8 | +--rw external-out? boolean 9 | SH-PROMPT 10 | """ 11 | 12 | !yanger -f tree b.yang 13 | """?? 14 | module: b 15 | +--rw q 16 | +--rw xx 17 | +--rw uu 18 | +--rw vv 19 | SH-PROMPT 20 | """ 21 | -------------------------------------------------------------------------------- /test/lux/internal/Makefile: -------------------------------------------------------------------------------- 1 | ### 2 | ### Tests of yanger internals, e.g., callbacks. 3 | ### 4 | 5 | include ../../support/*_testcases.mk 6 | 7 | .PHONY: build 8 | 9 | build: mksn.beam 10 | 11 | mksn.beam: mksn.erl 12 | erlc -pa ../../../../yanger/ebin $< 13 | 14 | clean: 15 | rm -f mksn.beam 16 | rm -fr lux_logs 17 | -------------------------------------------------------------------------------- /test/lux/internal/mksn.erl: -------------------------------------------------------------------------------- 1 | -module(mksn). 2 | -behaviour(yanger_plugin). 3 | 4 | -export([init/1, 5 | emit/3]). 6 | 7 | -include_lib("yanger/include/yang.hrl"). 8 | 9 | init(Ctx) -> 10 | yanger_plugin:register_hook(Ctx, #hooks.pre_mk_sn, fun pre_mk_sn/5). 11 | 12 | emit(_YCtx, _Modules, _Fd) -> 13 | ok. 14 | 15 | pre_mk_sn(Ctx, Sn, Mode, UsesPos, Ancestors) -> 16 | UsesStr = if UsesPos == undefined -> ""; 17 | true -> " " ++ yang_error:fmt_pos(UsesPos) 18 | end, 19 | XStr = case yang:search_one_substmt(description, Sn#sn.stmt) of 20 | {_, Arg, _, _} -> 21 | " " ++ Arg; 22 | false -> 23 | "" 24 | end, 25 | ?iof("mk_sn: ~p ~p~s~s\n", 26 | [fmt_path([Sn | Ancestors]), Mode, UsesStr, XStr]), 27 | {Ctx, Sn}. 28 | 29 | fmt_path([#sn{name = {ModName, Name}, kind = Kind} | T]) -> 30 | fmt_path(T) ++ "/" ++ ?a2l(ModName) ++ ":" ++ ?a2l(Name) ++ 31 | "(" ++ ?a2l(Kind) ++ ")"; 32 | fmt_path([#sn{name = Name, kind = Kind} | T]) -> 33 | fmt_path(T) ++ "/" ++ ?a2l(Name) ++ "(" ++ ?a2l(Kind) ++ ")"; 34 | fmt_path([#module{}]) -> 35 | "ROOT: "; 36 | fmt_path([]) -> 37 | "NONE: ". 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/lux/internal/mksn.lux: -------------------------------------------------------------------------------- 1 | [config skip=TAILFSKIP_RELEASE] 2 | 3 | 4 | [doc Test mk_sn hook callback] 5 | 6 | [shell yanger] 7 | !yanger -P . mksn.yang 8 | """??? 9 | yanger -P . mksn.yang 10 | mk_sn: "ROOT: /c(container)" final 11 | mk_sn: "ROOT: /o(container)" final 12 | mk_sn: "NONE: /o(container)" grouping 13 | mk_sn: "NONE: /o(container)/p(container)" grouping 14 | mk_sn: "NONE: /o(container)/p(container)/q(container)" grouping 15 | mk_sn: "NONE: /w(container)" grouping 16 | mk_sn: "NONE: /w(container)" grouping mksn.yang:28 17 | mk_sn: "ROOT: /a(container)" final 18 | mk_sn: "ROOT: /foo(operation)" final 19 | mk_sn: "ROOT: /foo(operation)/input(input)" final 20 | mk_sn: "ROOT: /foo(operation)/input(input)/z(container)" final 21 | mk_sn: "ROOT: /foo(operation)/input(input)/w(container)" final mksn.yang:77 22 | mk_sn: "ROOT: /bar(notification)" final 23 | mk_sn: "ROOT: /bar(notification)/z(container)" final 24 | mk_sn: "ROOT: /bar(notification)/w(container)" final mksn.yang:83 25 | mk_sn: "NONE: /z(container)" augment 26 | mk_sn: "NONE: /z(container)/g(leaf)" augment 27 | mk_sn: "NONE: /z(container)" augment 28 | mk_sn: "NONE: /z(container)/g(leaf)" augment 29 | mk_sn: "NONE: /w(container)" augment mksn.yang:36 30 | mk_sn: "NONE: /b(container)" augment 31 | mk_sn: "NONE: /e(container)" augment 32 | mk_sn: "NONE: /c(container)" augment 33 | mk_sn: "NONE: /c(container)/d(container)" augment 34 | mk_sn: "NONE: /n(container)" augment 35 | mk_sn: "NONE: /n(container)/m(container)" augment 36 | mk_sn: "NONE: /o(container)" augment mksn.yang:67 37 | mk_sn: "NONE: /o(container)/p(container)" augment mksn.yang:67 38 | mk_sn: "NONE: /o(container)/p(container)/q(container)" augment mksn.yang:67 FOO 39 | mk_sn: "ROOT: /a(container)/b(container)" final 40 | mk_sn: "ROOT: /a(container)/b(container)/c(container)" final 41 | mk_sn: "ROOT: /a(container)/b(container)/c(container)/d(container)" final 42 | mk_sn: "ROOT: /a(container)/b(container)/c(container)/d(container)/e(container)" final 43 | mk_sn: "ROOT: /a(container)/b(container)/c(container)/d(container)/e(container)/w(container)" final 44 | mk_sn: "ROOT: /a(container)/n(container)" final 45 | mk_sn: "ROOT: /a(container)/n(container)/m(container)" final 46 | mk_sn: "ROOT: /a(container)/o(container)" final 47 | mk_sn: "ROOT: /a(container)/o(container)/p(container)" final 48 | mk_sn: "ROOT: /a(container)/o(container)/p(container)/q(container)" final FOO 49 | mk_sn: "ROOT: /c(container)/mksn:z(container)" final 50 | mk_sn: "ROOT: /c(container)/mksn:z(container)/mksn:g(leaf)" final 51 | mk_sn: "ROOT: /o(container)/mksn:z(container)" final 52 | mk_sn: "ROOT: /o(container)/mksn:z(container)/mksn:g(leaf)" final 53 | SH-PROMPT 54 | """ 55 | -------------------------------------------------------------------------------- /test/lux/internal/mksn.yang: -------------------------------------------------------------------------------- 1 | module mksn { 2 | namespace "urn:mksn"; 3 | prefix x; 4 | 5 | // Used together with the plugin mksn.erl to test the 6 | // hook callback mk_sn() 7 | 8 | import y { 9 | prefix y; 10 | } 11 | 12 | augment "/y:c" { 13 | container z { 14 | leaf g { 15 | type int32; 16 | } 17 | } 18 | } 19 | augment "/y:o" { 20 | container z { 21 | leaf g { 22 | type int32; 23 | } 24 | } 25 | } 26 | 27 | grouping q { 28 | uses w; 29 | } 30 | 31 | grouping w { 32 | container w; 33 | } 34 | 35 | augment "/x:a/x:b/x:c/x:d/x:e" { 36 | uses q; 37 | } 38 | 39 | augment "/x:a" { 40 | container b; 41 | } 42 | 43 | augment "/x:a/x:b/x:c/x:d" { 44 | container e; 45 | } 46 | 47 | augment "/x:a/x:b" { 48 | container c { 49 | container d; 50 | } 51 | } 52 | 53 | container a; 54 | 55 | grouping z { 56 | container o { 57 | container p { 58 | container q; 59 | } 60 | } 61 | } 62 | 63 | augment /a { 64 | container n { 65 | container m; 66 | } 67 | uses z { 68 | refine "x:o/x:p/x:q" { 69 | description "FOO"; 70 | } 71 | } 72 | } 73 | 74 | rpc foo { 75 | input { 76 | container z; 77 | uses q; 78 | } 79 | } 80 | 81 | notification bar { 82 | container z; 83 | uses q; 84 | } 85 | 86 | } 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /test/lux/internal/y.yang: -------------------------------------------------------------------------------- 1 | module y { 2 | namespace urn:y; 3 | prefix y; 4 | 5 | container c { 6 | config true; 7 | } 8 | container o { 9 | config false; 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/lux/invalidate_default/Makefile: -------------------------------------------------------------------------------- 1 | # Internal env 2 | 3 | # Mandatory targets 4 | build: 5 | @echo "Build complete" 6 | 7 | clean: 8 | rm -r lux_logs 9 | 10 | -------------------------------------------------------------------------------- /test/lux/invalidate_default/dev.yang: -------------------------------------------------------------------------------- 1 | module dev { 2 | 3 | namespace "http://tail-f.com/ns/deviant-art"; 4 | prefix deviant-art; 5 | 6 | import deviated { 7 | prefix deviated; 8 | } 9 | 10 | deviation '/deviated:cont/deviated:native-cont/deviated:deviant-art' { 11 | deviate replace { 12 | type enumeration { 13 | enum any { description "Deviation-replacement"; } 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/lux/invalidate_default/deviated.yang: -------------------------------------------------------------------------------- 1 | module deviated { 2 | yang-version 1.1; 3 | namespace "http://tail-f.com/ns/deviated"; 4 | 5 | prefix deviated; 6 | 7 | typedef restricted-string { 8 | type string { pattern "(a-z)+"; } 9 | } 10 | 11 | container cont { 12 | container native-cont { 13 | leaf deviant-art { 14 | type union { 15 | type restricted-string; 16 | type enumeration { 17 | enum any { description "This is to be deviated-replaced"; } 18 | } 19 | } 20 | default any; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/lux/invalidate_default/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test of YANG model deviation compilation and use] 2 | 3 | [global fail_pattern=[Ee][Rr][Rr][Oo][Rr]] 4 | 5 | ################################################################################ 6 | 7 | [shell test] 8 | -type 9 | !yanger -f sn deviated.yang --deviation-module dev.yang | grep -A1 -E 'default.*any' 10 | ?keys.* 11 | -------------------------------------------------------------------------------- /test/lux/max_status/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/max_status/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | identity foo { 6 | status deprecated; 7 | } 8 | identity bar { 9 | status obsolete; 10 | } 11 | 12 | leaf foo { 13 | status deprecated; 14 | type string; 15 | } 16 | leaf bar { 17 | status obsolete; 18 | type string; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/max_status/run.lux: -------------------------------------------------------------------------------- 1 | [doc test max-status] 2 | 3 | [shell test] 4 | -foo|bar 5 | !yanger --print --max-status current a.yang 6 | ?SH-PROMPT 7 | 8 | -bar 9 | !yanger --print --max-status deprecated a.yang 10 | ?identities 11 | ?foo 12 | ?children 13 | ?foo 14 | ?SH-PROMPT 15 | 16 | - 17 | !yanger --print --max-status obsolete a.yang 18 | ?identities 19 | ?bar 20 | ?foo 21 | ?children 22 | ?foo 23 | ?bar 24 | ?SH-PROMPT 25 | 26 | - 27 | !yanger --print a.yang 28 | ?identities 29 | ?bar 30 | ?foo 31 | ?children 32 | ?foo 33 | ?bar 34 | ?SH-PROMPT 35 | -------------------------------------------------------------------------------- /test/lux/max_status_aug/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/max_status_aug/a-aug.yang: -------------------------------------------------------------------------------- 1 | module a-aug { 2 | namespace urn:m; 3 | prefix m; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | 9 | augment /a:bez { 10 | leaf buzz { 11 | status obsolete; 12 | type string; 13 | } 14 | } 15 | augment /a:bez { 16 | status obsolete; 17 | leaf byzz { 18 | type string; 19 | } 20 | } 21 | augment /a:bez { 22 | container bezz { 23 | status obsolete; 24 | leaf bozz { 25 | type string; 26 | } 27 | } 28 | } 29 | augment /a:bez { 30 | container bazz { 31 | leaf bizz { 32 | status obsolete; 33 | type string; 34 | } 35 | } 36 | } 37 | 38 | augment /a:aaa { 39 | leaf fizz { 40 | type string; 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /test/lux/max_status_aug/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | identity foo { 6 | status deprecated; 7 | } 8 | identity bar { 9 | status obsolete; 10 | } 11 | 12 | leaf foo { 13 | status deprecated; 14 | type string; 15 | } 16 | leaf bar { 17 | status obsolete; 18 | type string; 19 | } 20 | container baz { 21 | status obsolete; 22 | } 23 | container bez { 24 | } 25 | container boz { 26 | leaf biz { 27 | type boolean; 28 | status obsolete; 29 | } 30 | } 31 | container aaa; 32 | } 33 | -------------------------------------------------------------------------------- /test/lux/max_status_aug/run.lux: -------------------------------------------------------------------------------- 1 | [doc test max-status] 2 | 3 | [shell test] 4 | -foo|bar|baz|biz 5 | !yanger --print --max-status current a.yang 6 | ?SH-PROMPT 7 | 8 | -bar|baz|biz 9 | !yanger --print --max-status deprecated a.yang 10 | ?identities 11 | ?foo 12 | ?children 13 | ?foo 14 | ?SH-PROMPT 15 | 16 | - 17 | !yanger --print --max-status obsolete a.yang 18 | ?identities 19 | ?bar 20 | ?foo 21 | ?children 22 | ?foo 23 | ?bar 24 | ?SH-PROMPT 25 | 26 | - 27 | !yanger --print a.yang 28 | ?identities 29 | ?bar 30 | ?foo 31 | ?children 32 | ?foo 33 | ?bar 34 | ?SH-PROMPT 35 | 36 | -buzz|byzz|bezz|bozz|bizz 37 | !yanger --max-status=deprecated -f tree a-aug.yang 38 | ?bazz 39 | ?fizz 40 | ?SH-PROMPT 41 | 42 | - 43 | !yanger -f tree a-aug.yang 44 | ?buzz 45 | ?byzz 46 | ?bezz 47 | ?bozz 48 | ?bazz 49 | ?bizz 50 | ?fizz 51 | ?SH-PROMPT 52 | -------------------------------------------------------------------------------- /test/lux/prefix/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/prefix/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | import b { 6 | prefix b; 7 | } 8 | import c { 9 | prefix c; 10 | } 11 | 12 | container x { 13 | // must "foo()"; 14 | } 15 | 16 | uses b:b; 17 | 18 | leaf g { 19 | type string; 20 | must "/c:q"; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /test/lux/prefix/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b1; 4 | 5 | import c { 6 | prefix c1; // NOTE: different prefix than in a.yang when b:b is used. 7 | } 8 | 9 | grouping b { 10 | container w { 11 | leaf x { 12 | type string; 13 | } 14 | leaf y { 15 | type string; 16 | must "../x"; 17 | must "/c1:q"; 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/lux/prefix/c.yang: -------------------------------------------------------------------------------- 1 | module c { 2 | namespace urn:c; 3 | prefix c2; 4 | 5 | container q; 6 | } 7 | -------------------------------------------------------------------------------- /test/lux/prefix/run.lux: -------------------------------------------------------------------------------- 1 | [doc test prefixes in XPath expressions] 2 | 3 | [shell test] 4 | -error 5 | !yanger a.yang 6 | !echo "==$$?==" 7 | ?==0== 8 | -------------------------------------------------------------------------------- /test/lux/refine/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/refine/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix w; 4 | 5 | grouping g { 6 | leaf foo { 7 | type string; 8 | } 9 | } 10 | 11 | container a { 12 | leaf b { 13 | type string; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /test/lux/refine/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b; 4 | 5 | import a { 6 | prefix q; 7 | } 8 | 9 | augment /q:a { 10 | uses q:g { 11 | refine foo { 12 | must "/q:a/q:b = 'hej'"; 13 | } 14 | } 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/lux/refine/bad.yang: -------------------------------------------------------------------------------- 1 | module bad { 2 | namespace urn:bad; 3 | prefix b; 4 | 5 | grouping g { 6 | container a { 7 | leaf b { 8 | type int64; 9 | } 10 | } 11 | container c { 12 | config false; 13 | list d; 14 | } 15 | } 16 | 17 | uses g { 18 | refine a { 19 | config false; 20 | } 21 | refine a/b { 22 | default hopp; // error: bad type 23 | config true; // error: config true under config false 24 | must ". ."; // error: xpath syntax error 25 | } 26 | refine c { 27 | config true; // error: the list c/d does not have any keys! 28 | } 29 | refine c/d { 30 | min-elements 10; 31 | max-elements 2; // error: max-elements < min-elements 32 | } 33 | refine a { 34 | default 32; 35 | } 36 | } 37 | 38 | grouping b { 39 | leaf x { 40 | type int32; 41 | default hej; // error: bad type 42 | } 43 | } 44 | 45 | container y { 46 | container a { 47 | uses b; 48 | } 49 | container b { 50 | uses b; 51 | } 52 | container c { 53 | uses b { 54 | refine x { 55 | default 42; 56 | } 57 | } 58 | } 59 | container d { 60 | uses b { 61 | refine x { 62 | default hopp; // error; bad type 63 | } 64 | } 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /test/lux/refine/ref.yang: -------------------------------------------------------------------------------- 1 | module ref { 2 | namespace urn:ref; 3 | prefix r; 4 | 5 | extension foo; 6 | 7 | grouping g { 8 | container a { 9 | leaf b { 10 | type string; 11 | default hej; 12 | must "../c"; 13 | } 14 | leaf c { 15 | type string; 16 | mandatory true; 17 | reference orig; 18 | } 19 | leaf-list d { 20 | type string; 21 | max-elements 4; 22 | } 23 | } 24 | } 25 | 26 | uses g { 27 | refine a { 28 | presence x; // add presence 29 | } 30 | refine a/b { 31 | default hopp; // change default 32 | must "../d"; // add must 33 | r:foo; // allow this 34 | } 35 | refine a/c { 36 | mandatory false; // change mandatory 37 | config false; // change config 38 | reference hoppa; // chage reference 39 | } 40 | refine a/d { 41 | min-elements 2; // add min-elements 42 | max-elements 10; // change max-elements 43 | description hej; // add description 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /test/lux/refine/refine.lux: -------------------------------------------------------------------------------- 1 | [doc test refinement statements] 2 | 3 | [shell test] 4 | # make sure the data the tree plugin works on is properly updated 5 | !yanger -Wnone -f tree ref.yang 6 | """?? 7 | module: ref 8 | +--rw a! 9 | +--rw b? string 10 | +--ro c? string 11 | +--rw d* string 12 | """ 13 | # make sure the data the expand plugin works on is properly updated 14 | ## NOTE: this output will change if the expand plugin handles more 15 | ## statements 16 | !yanger -Wnone -t expand -f yang --yang-canonical ref.yang 17 | """?? 18 | module ref { 19 | namespace "urn:ref"; 20 | prefix r; 21 | 22 | extension foo; 23 | 24 | container a { 25 | presence "x"; 26 | leaf b { 27 | type string; 28 | must '../c'; 29 | must '../d'; 30 | default "hopp"; 31 | r:foo; 32 | } 33 | leaf c { 34 | type string; 35 | config false; 36 | mandatory false; 37 | } 38 | leaf-list d { 39 | type string; 40 | min-elements 2; 41 | max-elements 10; 42 | description 43 | "hej"; 44 | } 45 | } 46 | } 47 | """ 48 | !yanger -Wnone -f sn --sn-depth 16 ref.yang 49 | """?? 50 | %% /a/b 51 | #sn{ 52 | name = b 53 | kind = leaf 54 | """ 55 | """?? 56 | default = {{default,<<"hopp">>,{"ref.yang",31},[]},<<"hopp">>} 57 | """ 58 | """?? 59 | must = [{{relative,[{step,parent,{node_type,node},[]}, 60 | {step,child,{name,ref,c},[]}]}, 61 | """ 62 | """?? 63 | [['..',[ref|c]]], 64 | {must,<<"../c">>,{"ref.yang",12},[]}}, 65 | {{relative,[{step,parent,{node_type,node},[]}, 66 | {step,child,{name,ref,d},[]}]}, 67 | """ 68 | """?? 69 | [['..',[ref|d]]], 70 | {must,<<"../d">>,{"ref.yang",32},[]}}] 71 | """ 72 | ?SH-PROMPT 73 | 74 | [shell test] 75 | [doc test that validation is done on the refined statements] 76 | !yanger --print-error-code bad.yang 77 | ??bad.yang:17: (from bad.yang:23): YANG_ERR_INVALID_CONFIG 78 | ?bad.yang:22: YANG_ERR_TYPE_VALUE 79 | ?bad.yang:24: YANG_ERR_XPATH 80 | ?bad.yang:34: YANG_ERR_ILLEGAL_REFINE 81 | ?bad.yang:41: YANG_ERR_TYPE_VALUE 82 | ?bad.yang:62: YANG_ERR_TYPE_VALUE 83 | -bad.yang 84 | ?SH-PROMPT 85 | 86 | [shell test] 87 | [doc test that must in refine uses correct prefix] 88 | !yanger -f sn --sn-depth 64 b.yang 89 | """?? 90 | [{{comp,'=', 91 | {absolute, 92 | [{step,child,{name,a,a},[]}, 93 | {step,child,{name,a,b},[]}]}, 94 | {literal,"hej"}}, 95 | """ 96 | """?? 97 | {must,<<"/q:a/q:b = 'hej'">>,{"b.yang",12},[]}}], 98 | """ 99 | ?SH-PROMPT 100 | -------------------------------------------------------------------------------- /test/lux/rev-clash/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/rev-clash/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | import types { 6 | revision-date 2010-09-24; 7 | prefix t; 8 | } 9 | import b { 10 | prefix b; 11 | } 12 | 13 | leaf a { 14 | when "/b:b = 42"; 15 | type t:t; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/lux/rev-clash/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b; 4 | 5 | import types { 6 | revision-date 2013-07-15; 7 | prefix t; 8 | } 9 | 10 | leaf b { 11 | type t:t; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/lux/rev-clash/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test that multiple revisions of a module can be imported] 2 | 3 | [global fail_pattern=[Ee][Rr][Rr][Oo][Rr]] 4 | 5 | [shell test] 6 | -$fail_pattern 7 | !rm -f *.fxs 8 | !echo ==$$?== 9 | ?==0== 10 | 11 | !yanger a.yang 12 | !echo ==$$?== 13 | ?==0== 14 | -------------------------------------------------------------------------------- /test/lux/rev-clash/run.lux~: -------------------------------------------------------------------------------- 1 | [doc Test that multiple revisions of a module can be imported] 2 | 3 | [global fail_pattern=[Ee][Rr][Rr][Oo][Rr]] 4 | 5 | [shell test] 6 | -$fail_pattern 7 | !rm -f *.fxs 8 | !echo ==$$?== 9 | ?==0== 10 | 11 | !confdc -c a.yang 12 | !echo ==$$?== 13 | ?==0== 14 | -------------------------------------------------------------------------------- /test/lux/rev-clash/types@2010-09-24.yang: -------------------------------------------------------------------------------- 1 | module types { 2 | namespace urn:types; 3 | prefix t; 4 | 5 | revision 2010-09-24; 6 | 7 | typedef t { 8 | type int32; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/lux/rev-clash/types@2013-07-15.yang: -------------------------------------------------------------------------------- 1 | module types { 2 | namespace urn:types; 3 | prefix t; 4 | 5 | revision 2013-07-15; 6 | 7 | typedef t { 8 | type string; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/lux/structure/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/structure/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | yang-version 1.1; 3 | namespace urn:a; 4 | prefix a; 5 | 6 | import ietf-yang-structure-ext { 7 | prefix sx; 8 | } 9 | 10 | sx:structure address-book { 11 | list address { 12 | leaf name { 13 | type string; 14 | } 15 | leaf address { 16 | type string; 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/structure/run.lux: -------------------------------------------------------------------------------- 1 | [doc test structure] 2 | 3 | [shell test] 4 | !yanger a.yang 5 | !echo ==$$?== 6 | ?==0== 7 | 8 | -------------------------------------------------------------------------------- /test/lux/swagger/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs *.json 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/swagger/README: -------------------------------------------------------------------------------- 1 | Dependencies: 2 | ============= 3 | 4 | o python: required to validate generated json 5 | 6 | o swagger-cli: required to validate swagger 2.0 7 | (https://github.com/bigstickcarpet/swagger-cli.git) 8 | 9 | installation: npm install swagger-cli 10 | -------------------------------------------------------------------------------- /test/lux/swagger/escape.yang: -------------------------------------------------------------------------------- 1 | module escape { 2 | namespace urn:escape; 3 | prefix escape; 4 | 5 | description 6 | "string with unicode chars ö Ὗ and \" \\ x\n \t escapes 7 | line 2 with escape \" å. 8 | line 3"; 9 | 10 | rpc rpc1 { 11 | input { 12 | container x; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/lux/swagger/simple.yang: -------------------------------------------------------------------------------- 1 | module simple { 2 | namespace "urn:simple"; 3 | prefix "simple"; 4 | 5 | container top { 6 | container pink { 7 | leaf wish { 8 | type string; 9 | } 10 | 11 | container p-pink-inner { 12 | presence ""; 13 | leaf wish-inner { 14 | type string; 15 | } 16 | } 17 | 18 | container np-pink-inner { 19 | leaf wish-inner2 { 20 | type string; 21 | } 22 | } 23 | } 24 | 25 | container floyd { 26 | presence ""; 27 | leaf xxx { 28 | type string; 29 | } 30 | container np-floyd-inner { 31 | leaf xxx-inner1 { 32 | type string; 33 | } 34 | } 35 | container p-floyd-inner { 36 | presence ""; 37 | leaf xxx-inner2 { 38 | type string; 39 | } 40 | } 41 | } 42 | 43 | list ids { 44 | key id; 45 | 46 | leaf id { 47 | type uint32; 48 | } 49 | 50 | leaf name { 51 | type string; 52 | } 53 | 54 | choice card-type { 55 | case sre { 56 | container sre { 57 | } 58 | } 59 | } 60 | 61 | choice between { 62 | default rock; 63 | 64 | case rock { 65 | container stone { 66 | leaf mountain { 67 | type string; 68 | } 69 | } 70 | } 71 | case hard-place { 72 | container soft { 73 | leaf spot { 74 | type string; 75 | } 76 | } 77 | } 78 | } 79 | 80 | container zork { 81 | leaf foo { 82 | type string; 83 | } 84 | } 85 | } 86 | 87 | choice cross { 88 | case bohemian { 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /test/lux/tr13995/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/tr13995/gen_lux.sh: -------------------------------------------------------------------------------- 1 | ../bad/gen_lux.sh -------------------------------------------------------------------------------- /test/lux/tr13995/test-config-leafref.yang: -------------------------------------------------------------------------------- 1 | // Separate YANG module because of YANG 1.1 2 | module test-config-leafref { 3 | yang-version 1.1; 4 | namespace "http://tail-f.com/example/test"; 5 | prefix test; 6 | 7 | container non-direct-ref { 8 | 9 | leaf index_inter { 10 | type leafref { 11 | path "../con1/index"; 12 | require-instance true; 13 | } 14 | config false; 15 | } 16 | 17 | container con1 { 18 | leaf index { 19 | type uint32; 20 | } 21 | leaf refindex { 22 | type leafref { 23 | path "../../index_inter"; // LINE: YANG_ERR_LEAFREF_BAD_CONFIG 24 | require-instance true; 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/lux/tr14212/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/tr14212/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test that yanger handles multiple imports of same module.] 2 | 3 | [shell shell] 4 | -[Ee][Rr][Rr][Oo][Rr] 5 | !yanger -f yang y.yang 6 | ?x1:foo 7 | ?x1:bar 8 | !echo ==$$?== 9 | ?==0== 10 | -------------------------------------------------------------------------------- /test/lux/tr14212/x.yang: -------------------------------------------------------------------------------- 1 | module x { 2 | namespace urn:x; 3 | prefix x; 4 | 5 | typedef foo { 6 | type int32; 7 | } 8 | typedef bar { 9 | type string; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/lux/tr14212/y.yang: -------------------------------------------------------------------------------- 1 | module y { 2 | namespace urn:y; 3 | prefix y; 4 | 5 | import x { 6 | prefix x1; 7 | } 8 | import x { 9 | prefix x2; 10 | } 11 | 12 | leaf f { 13 | type x1:foo; 14 | } 15 | 16 | leaf b { 17 | type x1:bar; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /test/lux/tr14349/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/tr14349/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | container vlan { 6 | leaf add { 7 | type string; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/lux/tr14349/b-sub1.yang: -------------------------------------------------------------------------------- 1 | submodule b-sub1 { 2 | 3 | belongs-to b { 4 | prefix b; 5 | } 6 | 7 | import tailf-common { 8 | prefix tailf; 9 | } 10 | import a { 11 | prefix a; 12 | } 13 | 14 | leaf ports { 15 | type leafref { 16 | path "/a:vlan/add"; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /test/lux/tr14349/b-sub2.yang: -------------------------------------------------------------------------------- 1 | submodule b-sub2 { 2 | 3 | belongs-to b { 4 | prefix b; 5 | } 6 | 7 | import a { 8 | prefix a; 9 | } 10 | 11 | augment "/a:vlan" { 12 | leaf add { 13 | type int32; 14 | } 15 | } 16 | 17 | leaf ports { 18 | type leafref { 19 | path "/a:vlan/add"; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/lux/tr14349/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace urn:b; 3 | prefix b; 4 | 5 | import tailf-common { 6 | prefix tailf; 7 | } 8 | import a { 9 | prefix a; 10 | } 11 | 12 | leaf ports { 13 | type leafref { 14 | path "/a:vlan/add"; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /test/lux/tr14349/c.yang: -------------------------------------------------------------------------------- 1 | module c { 2 | namespace urn:c; 3 | prefix c; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | 9 | augment "/a:vlan" { 10 | leaf add { 11 | type int32; 12 | } 13 | } 14 | 15 | leaf ports { 16 | type leafref { 17 | path "/a:vlan/add"; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/tr14349/esc.yang: -------------------------------------------------------------------------------- 1 | module esc { 2 | 3 | namespace "http://www.cisco.com/esc/esc_datamodel"; 4 | prefix "esc"; 5 | 6 | import tailf-ncx { 7 | prefix ncx; 8 | } 9 | 10 | augment "/ncx:devices/ncx:device/ncx:config" { 11 | container esc_datamodel { 12 | container tenants { 13 | container tenant { 14 | leaf name { 15 | type string; 16 | } 17 | } 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /test/lux/tr14349/example-ok.yang: -------------------------------------------------------------------------------- 1 | module example-ok { 2 | prefix example-ok; 3 | namespace "http://cisco.com/yang/nso/esc-manager2"; 4 | 5 | import tailf-ncx { 6 | prefix ncx; 7 | } 8 | 9 | import esc { 10 | prefix esc; 11 | } 12 | 13 | grouping vm-grouping { 14 | leaf tenant { 15 | type leafref { 16 | path "deref(../vm-device)/../ncx:config/esc:esc_datamodel/esc:tenants/esc:tenant/esc:name"; 17 | } 18 | } 19 | 20 | leaf vm-device { 21 | mandatory true; 22 | description "Device name of the created VM"; 23 | type leafref { 24 | path "/ncx:devices/ncx:device/ncx:name"; 25 | } 26 | } 27 | } 28 | 29 | container xyz { 30 | uses vm-grouping; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/lux/tr14349/example.yang: -------------------------------------------------------------------------------- 1 | module example { 2 | prefix example; 3 | namespace "http://cisco.com/yang/nso/esc-manager"; 4 | 5 | import tailf-ncx { 6 | prefix ncx; 7 | } 8 | 9 | import esc { 10 | prefix esc; 11 | } 12 | 13 | grouping vm-grouping { 14 | leaf tenant { 15 | type leafref { 16 | path "deref(../vm-device)/../config/esc:esc_datamodel/esc:tenants/esc:tenant/esc:name"; 17 | } 18 | } 19 | 20 | leaf vm-device { 21 | mandatory true; 22 | description "Device name of the created VM"; 23 | type leafref { 24 | path "/ncx:devices/ncx:device/ncx:name"; 25 | } 26 | } 27 | } 28 | 29 | container xyz { 30 | uses vm-grouping; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/lux/tr14349/run.lux: -------------------------------------------------------------------------------- 1 | [doc Print an error when a leafref's path statement contains a name] 2 | [doc with a faulty prefix pointing to the current module.] 3 | 4 | [global fail_pattern=[Ee][Rr][Rr][Oo][Rr]] 5 | 6 | [shell compilation] 7 | # Should give an error 8 | !yanger example.yang 9 | ???example.yang:16: error: the node 'config' from module 'example' (in node 'device' from 'tailf-ncx') is not found 10 | 11 | !echo ==$$?== 12 | ?==1== 13 | 14 | # Should give an error 15 | !yanger b.yang 16 | ???b.yang:14: error: the node 'add' from module 'b' (in node 'vlan' from 'a') is not found 17 | 18 | !echo ==$$?== 19 | ?==1== 20 | 21 | !yanger b-sub1.yang 22 | ???b-sub1.yang:16: error: the node 'add' from module 'b' (in node 'vlan' from 'a') is not found 23 | 24 | !echo ==$$?== 25 | ?==1== 26 | 27 | # Should not give an error 28 | -$fail_pattern 29 | !yanger example-ok.yang 30 | 31 | !echo ==$$?== 32 | ?==0== 33 | 34 | !yanger c.yang 35 | 36 | !echo ==$$?== 37 | ?==0== 38 | 39 | !yanger b-sub2.yang 40 | 41 | !echo ==$$?== 42 | ?==0== 43 | -------------------------------------------------------------------------------- /test/lux/tr14349/tailf-ncx.yang: -------------------------------------------------------------------------------- 1 | /* 2 | * Little piece of tailf-ncs to test augmenting 3 | * into the NCS device tree from ConfD tests. 4 | */ 5 | module tailf-ncx { 6 | prefix tailf-ncx; 7 | namespace "http://cisco.com/yang/ncx"; 8 | 9 | container devices { 10 | list device { 11 | key name; 12 | leaf name { 13 | type string; 14 | } 15 | container config { 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/lux/tr15882/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/tr15882/run.lux: -------------------------------------------------------------------------------- 1 | [doc Testing of chain of derived identities] 2 | 3 | [shell compilation] 4 | -internal 5 | !yanger x.yang 6 | ?SH-PROMPT 7 | -------------------------------------------------------------------------------- /test/lux/tr15882/x.yang: -------------------------------------------------------------------------------- 1 | module x { 2 | namespace "urn:x"; 3 | prefix x; 4 | 5 | identity a { 6 | } 7 | 8 | identity b { 9 | base a; 10 | } 11 | 12 | identity C { 13 | base b; 14 | } 15 | 16 | leaf x { 17 | type identityref { 18 | base a; 19 | } 20 | default C; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/lux/tr16082/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/tr16082/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | container a { 6 | choice ch { 7 | case ca { 8 | container x; 9 | } 10 | } 11 | } 12 | 13 | augment /a { 14 | container x; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/lux/tr16082/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test that duplicate augemnted nodes are detected] 2 | 3 | 4 | [shell compilation] 5 | -==0== 6 | !yanger --print-error-code a.yang 7 | !echo ==$$?== 8 | ?YANG_ERR_DUPLICATE_SCHEMA_NODE 9 | ?==1== 10 | -------------------------------------------------------------------------------- /test/lux/tree/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/tree/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | container x { 6 | config false; 7 | list foo { 8 | leaf bar { 9 | type int32; 10 | } 11 | choice a-pretty-long-name { 12 | case another-long-name { 13 | leaf baz { 14 | type int32; 15 | } 16 | } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/tree/ietf-snmp-cfg/ietf-snmp.yang: -------------------------------------------------------------------------------- 1 | module ietf-snmp { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:ietf-snmp"; 4 | prefix snmp; 5 | 6 | // RFC Ed.: update the dates below with the date of RFC publication 7 | // and remove this note. 8 | 9 | include ietf-snmp-common { 10 | revision-date 2014-05-06; 11 | } 12 | include ietf-snmp-engine { 13 | revision-date 2014-05-06; 14 | } 15 | include ietf-snmp-target { 16 | revision-date 2014-05-06; 17 | } 18 | include ietf-snmp-notification { 19 | revision-date 2014-05-06; 20 | } 21 | include ietf-snmp-proxy { 22 | revision-date 2014-05-06; 23 | } 24 | include ietf-snmp-community { 25 | revision-date 2014-05-06; 26 | } 27 | include ietf-snmp-usm { 28 | revision-date 2014-05-06; 29 | } 30 | include ietf-snmp-tsm { 31 | revision-date 2014-05-06; 32 | } 33 | include ietf-snmp-vacm { 34 | revision-date 2014-05-06; 35 | } 36 | include ietf-snmp-tls { 37 | revision-date 2014-05-06; 38 | } 39 | include ietf-snmp-ssh { 40 | revision-date 2014-05-06; 41 | } 42 | 43 | organization 44 | "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 45 | 46 | contact 47 | "WG Web: 48 | WG List: 49 | 50 | WG Chair: Thomas Nadeau 51 | 52 | 53 | WG Chair: Juergen Schoenwaelder 54 | 55 | 56 | Editor: Martin Bjorklund 57 | 58 | 59 | Editor: Juergen Schoenwaelder 60 | "; 61 | 62 | description 63 | "This module contains a collection of YANG definitions for 64 | configuring SNMP engines. 65 | 66 | Copyright (c) 2014 IETF Trust and the persons identified as 67 | authors of the code. All rights reserved. 68 | 69 | Redistribution and use in source and binary forms, with or 70 | without modification, is permitted pursuant to, and subject 71 | to the license terms contained in, the Simplified BSD License 72 | set forth in Section 4.c of the IETF Trust's Legal Provisions 73 | Relating to IETF Documents 74 | (http://trustee.ietf.org/license-info). 75 | 76 | This version of this YANG module is part of RFC XXXX; see 77 | the RFC itself for full legal notices."; 78 | 79 | // RFC Ed.: replace XXXX with actual RFC number and remove this 80 | // note. 81 | 82 | // RFC Ed.: update the date below with the date of RFC publication 83 | // and remove this note. 84 | 85 | revision 2014-05-06 { 86 | description 87 | "Initial revision."; 88 | reference 89 | "RFC XXXX: A YANG Data Model for SNMP Configuration"; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /test/lux/tree/parent.yang: -------------------------------------------------------------------------------- 1 | module parent { 2 | namespace urn:parent; 3 | prefix parent; 4 | 5 | container parent-container { 6 | // to be augmented by small6 7 | } 8 | container parent-container-2 { 9 | // to be augmented by small6 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/lux/tree/small2.yang: -------------------------------------------------------------------------------- 1 | module small2 { 2 | 3 | namespace "http://xml.juniper.net/junos/10.0R3/junos"; 4 | prefix junos; 5 | 6 | typedef key-attribute-string-type { 7 | type string; 8 | } 9 | 10 | 11 | list dynamic-profiles { 12 | key name; 13 | uses juniper-dynamic-profile-object; 14 | } 15 | 16 | grouping juniper-dynamic-variable-object { 17 | leaf name { 18 | description "Name of variable"; 19 | type string; 20 | } 21 | leaf default-value { 22 | type string; 23 | description "Default value for variable"; 24 | } 25 | leaf mandatory { 26 | description "Variable must be supplied by external server"; 27 | type empty; 28 | } 29 | } 30 | 31 | grouping juniper-dynamic-profile-object { 32 | leaf name { 33 | description "Name for dynamic profile"; 34 | type key-attribute-string-type { 35 | length "1 .. 80"; 36 | } 37 | } 38 | 39 | list variables { 40 | key name; 41 | uses juniper-dynamic-variable-object; 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/lux/tree/small3.yang: -------------------------------------------------------------------------------- 1 | module small3 { 2 | 3 | namespace "http://xml.juniper.net/junos/10.0R3/junos"; 4 | prefix junos; 5 | 6 | list dynamic-profiles { 7 | key name; 8 | uses juniper-dynamic-profile-object; 9 | } 10 | 11 | grouping juniper-dynamic-profile-object { 12 | leaf name { 13 | description "Name for dynamic profile"; 14 | type string; 15 | } 16 | 17 | list variables { 18 | key mandatory; 19 | uses juniper-dynamic-variable-object; 20 | } 21 | } 22 | 23 | grouping juniper-dynamic-variable-object { 24 | leaf name { 25 | description "Name of variable"; 26 | type empty; 27 | } 28 | leaf default-value { 29 | type empty; 30 | description "Default value for variable"; 31 | } 32 | leaf mandatory { 33 | description "Variable must be supplied by external server"; 34 | type string; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/lux/tree/small4.yang: -------------------------------------------------------------------------------- 1 | module small3 { 2 | 3 | namespace "http://xml.juniper.net/junos/10.0R3/junos"; 4 | prefix junos; 5 | 6 | list dynamic-profiles { 7 | key name; 8 | uses testgroup; 9 | } 10 | 11 | grouping testgroup { 12 | leaf name { 13 | description "inget"; 14 | type string; 15 | } 16 | 17 | list inget { 18 | key name; 19 | uses juniper-dynamic-profile-object; 20 | } 21 | } 22 | 23 | grouping juniper-dynamic-profile-object { 24 | leaf name { 25 | description "Name for dynamic profile"; 26 | type string; 27 | } 28 | 29 | list variables { 30 | key mandatory; 31 | uses juniper-dynamic-variable-object; 32 | } 33 | } 34 | 35 | grouping juniper-dynamic-variable-object { 36 | leaf name { 37 | description "Name of variable"; 38 | type empty; 39 | } 40 | leaf default-value { 41 | type empty; 42 | description "Default value for variable"; 43 | } 44 | leaf mandatory { 45 | description "Variable must be supplied by external server"; 46 | type string; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/lux/tree/small5.yang: -------------------------------------------------------------------------------- 1 | module small5 { 2 | namespace urn:q; 3 | prefix q; 4 | 5 | 6 | grouping a { 7 | grouping b { 8 | uses c { 9 | augment d { 10 | container e; 11 | } 12 | } 13 | } 14 | uses b; 15 | } 16 | grouping c { 17 | container d; 18 | } 19 | uses a; 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/tree/small6.lux: -------------------------------------------------------------------------------- 1 | [doc text sx:structure] 2 | 3 | [shell yanger] 4 | !yanger -f tree small6.yang 5 | """??? 6 | module: small6 7 | 8 | augment /parent:parent-container: 9 | +--rw test-list* [test-key] 10 | +--rw test-key string 11 | +--rw dummy? uint16 12 | augment /parent:parent-container-2: 13 | +--rw test-list* [test-key] 14 | +--rw test-key string 15 | +--rw dummy? uint16 16 | """ 17 | -------------------------------------------------------------------------------- /test/lux/tree/small6.yang: -------------------------------------------------------------------------------- 1 | module small6 { 2 | namespace urn:r; 3 | prefix r; 4 | 5 | import parent { 6 | prefix parent; 7 | } 8 | 9 | augment "/parent:parent-container" { 10 | list test-list { 11 | key test-key; 12 | 13 | leaf test-key { 14 | type string; 15 | } 16 | 17 | leaf dummy { 18 | type uint16; 19 | } 20 | } 21 | } 22 | 23 | augment "/parent:parent-container-2" { 24 | list test-list { 25 | key test-key; 26 | 27 | leaf test-key { 28 | type string; 29 | } 30 | 31 | leaf dummy { 32 | type uint16; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/lux/tree/sx.lux: -------------------------------------------------------------------------------- 1 | [doc text sx:structure] 2 | 3 | [shell yanger] 4 | !yanger -f tree sx.yang 5 | """??? 6 | module: sx 7 | 8 | structure address-book: 9 | +-- address* [last first] 10 | +-- last string 11 | +-- first string 12 | +-- street? string 13 | +-- city? string 14 | +-- state? string 15 | """ 16 | -------------------------------------------------------------------------------- /test/lux/tree/sx.yang: -------------------------------------------------------------------------------- 1 | module sx { 2 | yang-version 1.1; 3 | namespace "urn:example:example-module"; 4 | prefix exm; 5 | 6 | import ietf-yang-structure-ext { 7 | prefix sx; 8 | } 9 | 10 | sx:structure address-book { 11 | list address { 12 | key "last first"; 13 | leaf last { 14 | type string; 15 | description "Last name"; 16 | } 17 | leaf first { 18 | type string; 19 | description "First name"; 20 | } 21 | leaf street { 22 | type string; 23 | description "Street name"; 24 | } 25 | leaf city { 26 | type string; 27 | description "City name"; 28 | } 29 | leaf state { 30 | type string; 31 | description "State name"; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/lux/tree/tree_plugin_macro.lux: -------------------------------------------------------------------------------- 1 | # author: kris@tail-f.com 2 | [doc Test of the yanger tree plugin. Comparing it to the predecessor pyang tree] 3 | 4 | # We add --ignore warnings to pyang because otherwise 5 | # pyang will emit warnings that yanger does not emit. 6 | [macro tree_compare FILE] 7 | !yanger -f tree -p ${DIR} ${DIR}/${FILE} | sed 's/ *$//' > test.yanger.tree 8 | !echo ==$?== 9 | ?==0== 10 | 11 | !pyang --no-path-recurse --ignore-errors -f tree -p ${DIR} ${DIR}/${FILE} | sed 's/ *$//' > test.pyang.tree 12 | !echo ==$?== 13 | ?==0== 14 | 15 | !diff -u test.pyang.tree test.yanger.tree 16 | !echo ==$?== 17 | ?==0== 18 | - 19 | [endmacro] 20 | 21 | 22 | [shell test_yanger_tree] 23 | [timeout 20] 24 | 25 | # use some test modules 26 | [global DIR=.] 27 | [invoke tree_compare small2.yang] 28 | [invoke tree_compare small3.yang] 29 | [invoke tree_compare small4.yang] 30 | ## FIXME: grouping expansion must be done differently! 31 | ## In order for the #groupings{} to be correct, I think we must 32 | ## topo sort all groupings and process them in the correct order. 33 | #[invoke tree_compare small5.yang] 34 | 35 | [invoke tree_compare small6.yang] 36 | 37 | [invoke tree_compare a.yang] 38 | [invoke tree_compare x.yang] 39 | 40 | # use pyang test modules 41 | [global DIR=../../../../../pyang/test/test_good] 42 | [invoke tree_compare yt2.yang] 43 | [invoke tree_compare yt3.yang] 44 | [invoke tree_compare yt4.yang] 45 | [invoke tree_compare yt5.yang] 46 | [invoke tree_compare yt6.yang] 47 | [invoke tree_compare yt7.yang] 48 | [invoke tree_compare yt8.yang] 49 | [invoke tree_compare yt9.yang] 50 | [invoke tree_compare yt10.yang] 51 | [invoke tree_compare qs.yang] 52 | [invoke tree_compare q.yang] 53 | [invoke tree_compare w.yang] 54 | [invoke tree_compare xt5.yang] 55 | [invoke tree_compare xt6.yang] 56 | [invoke tree_compare xt7.yang] 57 | [invoke tree_compare xt10.yang] 58 | [invoke tree_compare a.yang] 59 | [invoke tree_compare b.yang] 60 | 61 | # and use some yanger modules 62 | [global DIR=../internal] 63 | [invoke tree_compare mksn.yang] 64 | 65 | # and the complicated ietf-snmp-cfg module 66 | [global DIR=ietf-snmp-cfg] 67 | [invoke tree_compare ietf-snmp.yang] 68 | 69 | [cleanup] 70 | !rm -f test.yanger.tree 71 | !rm -f test.pyang.tree 72 | 73 | -------------------------------------------------------------------------------- /test/lux/tree/x-sub.yang: -------------------------------------------------------------------------------- 1 | submodule x-sub { 2 | belongs-to x { 3 | prefix x; 4 | } 5 | 6 | import a { 7 | prefix a; 8 | } 9 | 10 | augment /a:x { 11 | container foo; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/lux/tree/x.yang: -------------------------------------------------------------------------------- 1 | module x { 2 | namespace "urn:x"; 3 | prefix x; 4 | 5 | include x-sub; 6 | 7 | import y { 8 | prefix y; 9 | } 10 | 11 | augment "/y:pretty-long-identifier-name/y:shorter" 12 | + "/y:another-long-identifier-name" 13 | + "/y:also-short/y:but-this-is-long-again" { 14 | leaf bar { 15 | type string; 16 | } 17 | } 18 | 19 | leaf foo { 20 | type leafref { 21 | path "/y:pretty-long-identifier-name/y:shorter" 22 | + "/y:another-long-identifier-name" 23 | + "/y:also-short/y:but-this-is-long-again/x:bar"; 24 | } 25 | } 26 | container q { 27 | leaf enabled { 28 | type boolean; 29 | } 30 | } 31 | 32 | augment /y:my-notif { 33 | leaf bar { 34 | type string; 35 | } 36 | } 37 | augment /y:my-rpc/y:input { 38 | leaf bar { 39 | type string; 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /test/lux/xpath-in-augment/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/xpath-in-augment/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace urn:a; 3 | prefix a; 4 | 5 | container a { 6 | leaf b { 7 | type string; 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/lux/xpath-in-augment/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | yang-version 1.1; 3 | namespace urn:b; 4 | prefix b; 5 | 6 | import a { 7 | prefix a; 8 | } 9 | 10 | augment /a:a { 11 | when "a:b"; 12 | leaf c { 13 | type string; 14 | must "../a:x = 10"; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/lux/xpath-in-augment/run.lux: -------------------------------------------------------------------------------- 1 | [doc Test that must expr are checked in augment with when in 1.1] 2 | 3 | [shell compilation] 4 | !yanger --print-error-code b.yang 5 | -SH-PROMPT 6 | ?YANG_ERR_XPATH_BAD_REF 7 | - 8 | ?SH-PROMPT 9 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/Makefile: -------------------------------------------------------------------------------- 1 | #Includes for test and build 2 | include ../../support/*_testcases.mk 3 | 4 | .PHONY: build 5 | 6 | YANG = $(wildcard *.yang) 7 | GENLUX = $(YANG:%.yang=%.lux) 8 | 9 | build: $(GENLUX) 10 | 11 | %.lux: %.yang 12 | sh gen_lux.sh $< > $@ 13 | 14 | clean: 15 | rm -f $(GENLUX) 16 | rm -fr lux_logs 17 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/aug-oper-mand.yang: -------------------------------------------------------------------------------- 1 | module aug-oper-mand { 2 | yang-version 1.1; 3 | namespace urn:aom; 4 | prefix aom; 5 | 6 | import new { 7 | prefix new; 8 | } 9 | 10 | /* allowed by YANG-1.1 */ 11 | augment /new:t { 12 | leaf mand { 13 | config false; 14 | type string; 15 | mandatory true; 16 | } 17 | container oper { 18 | config false; 19 | list mand { 20 | key k; 21 | leaf k { 22 | type string; 23 | } 24 | min-elements 1; 25 | } 26 | } 27 | container config { 28 | leaf mand { 29 | config false; 30 | type string; 31 | mandatory true; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/aug-when-mand.yang: -------------------------------------------------------------------------------- 1 | module aug-when-mand { 2 | yang-version 1.1; 3 | namespace urn:awm; 4 | prefix awm; 5 | 6 | import new { 7 | prefix new; 8 | } 9 | 10 | /* allowed by YANG-1.1 */ 11 | augment /new:t { 12 | when true(); 13 | leaf mand { 14 | type string; 15 | mandatory true; 16 | } 17 | } 18 | 19 | /* but not this */ 20 | augment /new:t { 21 | leaf opt { 22 | type string; 23 | } 24 | container np { 25 | when true(); 26 | leaf mand { // LINE: YANG_ERR_MANDATORY_NODE_IN_AUGMENT 27 | type string; 28 | mandatory true; 29 | } 30 | } 31 | } 32 | 33 | /* have to do that like this */ 34 | augment /new:t { 35 | leaf opt1 { 36 | type string; 37 | } 38 | container np1; 39 | } 40 | augment /new:t/awm:np1 { 41 | when true(); 42 | leaf mand { 43 | type string; 44 | mandatory true; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/basic.lux: -------------------------------------------------------------------------------- 1 | [doc Test that yanger can be run] 2 | 3 | [shell yanger] 4 | !yanger -h 5 | ?Usage: yanger 6 | 7 | 8 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/enum-and-bit.yang: -------------------------------------------------------------------------------- 1 | module enum-and-bit { 2 | yang-version 1.1; 3 | namespace urn:a; 4 | prefix a; 5 | 6 | // YANGER_EXTRA_FLAGS: -F enum-and-bit: 7 | 8 | feature foo; 9 | 10 | leaf a { 11 | type enumeration { 12 | enum x { 13 | if-feature foo; 14 | } 15 | } 16 | } 17 | leaf b { 18 | type bits { 19 | bit x { 20 | if-feature foo; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/gen_lux.sh: -------------------------------------------------------------------------------- 1 | ../bad/gen_lux.sh -------------------------------------------------------------------------------- /test/lux/yang-1.1/impinc.yang: -------------------------------------------------------------------------------- 1 | module impinc { 2 | yang-version 1.1; 3 | namespace urn:impinc; 4 | prefix ii; 5 | 6 | import ietf-yang-types { 7 | prefix yang; 8 | description foo; // new in 1.1. 9 | reference "RFC 6991"; // new in 1.1 10 | } 11 | 12 | include incsub { // LINE: YANG_ERR_BAD_INCLUDE_YANG_VERSION 13 | description bar; // new in 1.1. 14 | reference "RFC XXXX"; // new in 1.1 15 | } 16 | 17 | leaf x { 18 | type yang:date-and-time; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/impincyv.yang: -------------------------------------------------------------------------------- 1 | module impincyv { 2 | yang-version 1; 3 | namespace urn:impinc-yv; 4 | prefix iiyv; 5 | 6 | import impyv1 { 7 | prefix iyv1; 8 | } 9 | 10 | import impyv2 { // LINE: YANG_ERR_BAD_IMPORT_YANG_VERSION 11 | revision-date 2020-08-30; 12 | prefix iyv2; 13 | } 14 | 15 | include incsubyv1; 16 | include incsubyv2; // LINE: YANG_ERR_BAD_INCLUDE_YANG_VERSION 17 | 18 | leaf l { 19 | type iyv1:myInt; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/impyv1.yang: -------------------------------------------------------------------------------- 1 | module impyv1 { 2 | namespace urn:impyv1; 3 | yang-version 1.1; 4 | prefix iyv1; 5 | 6 | typedef myInt { 7 | type int32; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/impyv2.yang: -------------------------------------------------------------------------------- 1 | module impyv2 { 2 | namespace urn:impyv2; 3 | yang-version 1.1; 4 | prefix iyv2; 5 | 6 | revision 2020-08-30 { 7 | description "test"; 8 | } 9 | 10 | leaf unkown { 11 | type empty; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/incsub.yang: -------------------------------------------------------------------------------- 1 | submodule incsub { 2 | belongs-to impinc { 3 | prefix ii; 4 | } 5 | 6 | leaf y { 7 | type int32; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/incsubyv1.yang: -------------------------------------------------------------------------------- 1 | submodule incsubyv1 { 2 | belongs-to impincyv { 3 | prefix iiyv; 4 | } 5 | 6 | leaf yv1 { 7 | type int32; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/incsubyv2.yang: -------------------------------------------------------------------------------- 1 | submodule incsubyv2 { 2 | yang-version 1.1; 3 | belongs-to impincyv { 4 | prefix iiyv; 5 | } 6 | 7 | leaf yv2 { 8 | type int32; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/uimp.yang: -------------------------------------------------------------------------------- 1 | module uimp { 2 | namespace urn:ump; 3 | prefix uimp; 4 | yang-version 1.1; 5 | 6 | import u { 7 | prefix u; 8 | } 9 | 10 | container x1 { 11 | leaf y1 { 12 | type string; 13 | } 14 | } 15 | 16 | // FIXME: See FIXME in u.yang 17 | // uses u:ggg; 18 | // 19 | // uses u:ggg2; // error /x1/y2 not defined 20 | // 21 | // leaf h { 22 | // type u:foo; 23 | // } 24 | // leaf h2 { 25 | // type u:foo2; // error; /x2 not defined 26 | // } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /test/lux/yang-1.1/usub.yang: -------------------------------------------------------------------------------- 1 | submodule usub { 2 | belongs-to u { 3 | prefix us; 4 | } 5 | } -------------------------------------------------------------------------------- /test/lux/yin/Makefile: -------------------------------------------------------------------------------- 1 | include ../../support/*_testcases.mk 2 | 3 | build: 4 | 5 | clean: 6 | rm -rf lux_logs _tmp_* 7 | 8 | .PHONY: build clean 9 | -------------------------------------------------------------------------------- /test/lux/yin/parent.yang: -------------------------------------------------------------------------------- 1 | module parent { 2 | namespace urn:parent; 3 | prefix parent; 4 | 5 | container parent-container { 6 | // to be augmented by small6 7 | } 8 | container parent-container-2 { 9 | // to be augmented by small6 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/lux/yin/small6.yang: -------------------------------------------------------------------------------- 1 | module small6 { 2 | namespace urn:r; 3 | prefix rprefix; 4 | 5 | import parent { 6 | prefix parentPrefix; 7 | } 8 | 9 | augment "/parentPrefix:parent-container" { 10 | list test-list { 11 | key test-key; 12 | 13 | leaf test-key { 14 | type string; 15 | } 16 | 17 | leaf dummy { 18 | type uint16; 19 | } 20 | } 21 | } 22 | 23 | augment "/parentPrefix:parent-container-2" { 24 | list test-list { 25 | key test-key; 26 | 27 | leaf test-key { 28 | type string; 29 | } 30 | 31 | leaf dummy { 32 | type uint16; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/a.yang: -------------------------------------------------------------------------------- 1 | module a { 2 | namespace "urn:a"; 3 | prefix a; 4 | 5 | grouping a { 6 | leaf a { 7 | type leafref { 8 | path "/a:x/a:y/a:k1"; 9 | } 10 | } 11 | leaf b { 12 | type leafref { 13 | path "deref(../a)/../a:k2"; 14 | // path "/a:x/a:y[a:k1 = current()/../a]/a:k2"; 15 | } 16 | } 17 | } 18 | 19 | container x { 20 | list y { 21 | key "k1 k2"; 22 | leaf k1 { 23 | type string; 24 | } 25 | leaf k2 { 26 | type string; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/b.yang: -------------------------------------------------------------------------------- 1 | module b { 2 | namespace "urn:b"; 3 | prefix b; 4 | 5 | import a { 6 | prefix a; 7 | } 8 | 9 | container z { 10 | uses a:a; 11 | } 12 | } -------------------------------------------------------------------------------- /test/lux/yin/test_good/q.yang: -------------------------------------------------------------------------------- 1 | module q { 2 | namespace urn:q; 3 | prefix q; 4 | 5 | include qs; 6 | } 7 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/qs.yang: -------------------------------------------------------------------------------- 1 | submodule qs { 2 | belongs-to q { 3 | prefix q; 4 | } 5 | 6 | extension foo { 7 | argument id; 8 | } 9 | 10 | identity foo; 11 | 12 | feature foo; 13 | 14 | grouping g { 15 | leaf x { 16 | type string; 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/w.yang: -------------------------------------------------------------------------------- 1 | module w { 2 | namespace urn:w; 3 | prefix w; 4 | 5 | import q { 6 | prefix qq; 7 | } 8 | 9 | identity g { 10 | base qq:foo; 11 | } 12 | 13 | grouping X { 14 | leaf y { 15 | qq:foo 42; 16 | type uint32; 17 | } 18 | } 19 | 20 | grouping Y { 21 | container z { 22 | if-feature qq:foo; 23 | uses X; 24 | } 25 | } 26 | uses Y { 27 | refine z/y { 28 | default 42; 29 | } 30 | } 31 | 32 | container q { 33 | uses qq:g; 34 | } 35 | leaf t { 36 | type leafref { 37 | path "/q/x"; 38 | } 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/xt10.yang: -------------------------------------------------------------------------------- 1 | module xt10 { 2 | namespace "urn:xt10"; 3 | prefix "xt10"; 4 | 5 | typedef a { 6 | type string; 7 | } 8 | 9 | leaf x { 10 | type decimal64 { 11 | fraction-digits 1; 12 | range "-6.3..0.0"; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/xt5.yang: -------------------------------------------------------------------------------- 1 | module xt5 { 2 | 3 | namespace "urn:test:xt5"; 4 | prefix xt5; 5 | 6 | grouping x { 7 | leaf foo { type empty; mandatory true; } 8 | } 9 | 10 | typedef xc { 11 | type int32; 12 | } 13 | 14 | extension x { 15 | argument name; 16 | } 17 | 18 | leaf foo { type int16; } 19 | 20 | 21 | extension foo { 22 | argument bar { 23 | yin-element true; 24 | } 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/xt6.yang: -------------------------------------------------------------------------------- 1 | module xt6 { 2 | 3 | namespace "urn:test:xt6"; 4 | prefix xt6; 5 | 6 | import xt5 { 7 | prefix xt5; 8 | } 9 | 10 | uses xt5:x; 11 | 12 | xt5:foo "barbar"; 13 | 14 | leaf y { 15 | type xt5:xc; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/xt7.yang: -------------------------------------------------------------------------------- 1 | module xt7 { 2 | prefix x; 3 | namespace "urn:test:xt7"; 4 | 5 | leaf foo { 6 | type int16; 7 | x:foo "some string"; 8 | } 9 | 10 | x:foo "another string"; 11 | 12 | extension foo { 13 | argument bar { 14 | yin-element false; 15 | } 16 | } 17 | 18 | grouping baz { 19 | leaf x { 20 | type int32; 21 | } 22 | } 23 | uses baz { 24 | refine x { 25 | default 42; 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/yt10.yang: -------------------------------------------------------------------------------- 1 | module yt10 { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:yt10"; 4 | 5 | prefix "yt10"; 6 | 7 | import yt9 { prefix yt9; } 8 | 9 | organization "Netconf Central"; 10 | 11 | contact "Andy Bierman"; 12 | 13 | description "YANG test module 9. augment"; 14 | 15 | revision 2008-04-11 { description "initial version"; } 16 | 17 | augment /yt9:con1 { 18 | leaf b1 { type int32; } 19 | 20 | container con2 { 21 | leaf b2 { type string; } 22 | } 23 | } 24 | 25 | container test { 26 | description "Particular configuration to retrieve."; 27 | // mandatory true; 28 | uses Foo; 29 | } 30 | 31 | grouping Foo { 32 | leaf X { type int32; } 33 | leaf Y { type uint32; } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/yt6.yang: -------------------------------------------------------------------------------- 1 | module yt6 { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:yt6"; 4 | prefix "yt6"; 5 | 6 | import ietf-yang-types { prefix y; } 7 | 8 | organization 9 | "YANG Language Design Team"; 10 | 11 | contact 12 | "Andy Bierman"; 13 | 14 | description 15 | "YANG test module 6. Container, augment"; 16 | 17 | 18 | typedef un-1 { 19 | type union { // 16 20 | type union { // 17 21 | type int32; 22 | type binary; 23 | type union { // 20 24 | type string; 25 | type binary; 26 | type boolean; 27 | } 28 | } 29 | type int64; 30 | } 31 | default 9; 32 | } 33 | 34 | augment /foo/a/z { 35 | leaf xxx { type binary; } 36 | } 37 | 38 | augment /foo/a { 39 | case zz { leaf zzz { type int64; } } 40 | } 41 | 42 | 43 | container foo { 44 | leaf un { 45 | type un-1; 46 | config false; 47 | default forty; 48 | } 49 | leaf bar1 { 50 | type y:counter32; 51 | } 52 | leaf bar2 { 53 | type int32; 54 | default 10; 55 | } 56 | leaf bar3 { 57 | type int32; 58 | mandatory true; 59 | } 60 | leaf bar4 { 61 | type int32; 62 | mandatory false; 63 | } 64 | leaf bar5 { 65 | type int32; 66 | mandatory true; 67 | // default 10; pyang says this is illegal 68 | } 69 | leaf bar6 { 70 | type int32; 71 | mandatory false; 72 | default 10; 73 | } 74 | choice a { 75 | default x; 76 | leaf x { type int32; } 77 | leaf y { type string; } 78 | container z; 79 | } 80 | } 81 | 82 | list bar { 83 | config false; 84 | key bar1; 85 | unique zz2; 86 | leaf zz1 { type un-1; mandatory true; } 87 | leaf zz2 { type y:zero-based-counter32; } 88 | leaf-list zz3 { 89 | description testing-one-two-three; 90 | min-elements 4; 91 | max-elements 14; 92 | type y:date-and-time; 93 | ordered-by user; 94 | } 95 | leaf bar1 { type un-1; } 96 | } 97 | 98 | notification notif1 { 99 | description "notification test"; 100 | reference test-notif-1; 101 | status deprecated; 102 | container x { 103 | list y { 104 | reference "RFC 4741"; 105 | leaf xx { type int32; } 106 | leaf zz { type zz_type; } 107 | 108 | key xx; 109 | 110 | max-elements "77"; 111 | min-elements "15"; 112 | } 113 | 114 | leaf yy { type int32; default -123; } 115 | 116 | typedef zz_type { 117 | type enumeration { 118 | enum x; 119 | enum y; 120 | } 121 | } 122 | } 123 | leaf x2 { type instance-identifier; } 124 | anyxml x3 { description test-any; } 125 | } 126 | 127 | notification notif2; 128 | 129 | } 130 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/yt7.yang: -------------------------------------------------------------------------------- 1 | module yt7 { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:yt7"; 4 | prefix "yt7"; 5 | 6 | import ietf-yang-types { prefix y; } 7 | 8 | organization 9 | "YANG Language Design Team"; 10 | 11 | contact 12 | "ietf@andybierman.com"; 13 | 14 | description 15 | "YANG test module 7."; 16 | 17 | revision 2008-02-08 { 18 | description "initial version."; 19 | } 20 | 21 | rpc rpc1 { 22 | description rpc-test; 23 | reference "RFC 4741"; 24 | input { 25 | leaf a { type y:counter32; } 26 | leaf b { type int32; } 27 | container foo { 28 | presence "enable foo service"; 29 | } 30 | } 31 | output { 32 | leaf x { type y:zero-based-counter32; } 33 | container y { 34 | container yy { 35 | leaf yyy { type empty; } 36 | anyxml zzz; 37 | container zz; 38 | } 39 | } 40 | } 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/yt8.yang: -------------------------------------------------------------------------------- 1 | module yt8 { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:yt8"; 4 | prefix "yt8"; 5 | 6 | organization 7 | "YANG Language Design Team"; 8 | 9 | contact 10 | "ietf@andybierman.com"; 11 | 12 | description 13 | "YANG test module 8."; 14 | 15 | revision 2008-02-12 { 16 | description "Initial revision."; 17 | } 18 | 19 | typedef foo { 20 | type int32 { 21 | range "-42 | -2 .. +7 | 8 | 41 | 42" { 22 | } 23 | } 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test/lux/yin/test_good/yt9.yang: -------------------------------------------------------------------------------- 1 | module yt9 { 2 | 3 | namespace "urn:ietf:params:xml:ns:yang:yt9"; 4 | 5 | prefix "yt9"; 6 | 7 | organization "Netconf Central"; 8 | 9 | contact "Andy Bierman"; 10 | 11 | description "YANG test module 9. augment"; 12 | 13 | revision 2008-04-11 { description "initial version"; } 14 | 15 | leaf a1 { type int32; } 16 | 17 | container con1 { 18 | leaf a2 { type string; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/lux/yin/test_tailf_info/config.yang: -------------------------------------------------------------------------------- 1 | module config { 2 | yang-version 1.1; 3 | namespace "http://ekinops.com/otns/config"; 4 | prefix otnsc; 5 | 6 | import tailf-common { 7 | prefix tailf; 8 | } 9 | 10 | list interface { 11 | description "OTN Interface list"; 12 | tailf:info "OTN Interface list"; 13 | key 'name'; 14 | leaf name { 15 | description "(otu4|otu2|otu2e|odu4|odu2|odu2e|odu1|odu0|oduflex|e1glan|e10glan|e10glanrt|e10gwan|e100glan|fc8g|fc10g|stm64|ochgroup|och):\\d+/\\d+/\\d+/\\d+(\\.\\d+){0,}"; 16 | tailf:info "(otu4|otu2|otu2e|odu4|odu2|odu2e|odu1|odu0|oduflex|e1glan|e10glan|e10glanrt|e10gwan|e100glan|fc8g|fc10g|stm64|ochgroup|och):\\d+/\\d+/\\d+/\\d+(\\.\\d+){0,}"; 17 | type string { 18 | pattern "(otu4|otu2|otu2e|odu4|odu2|odu2e|odu1|odu0|oduflex|e1glan|e10glan|e10glanrt|e10gwan|e100glan|fc8g|fc10g|stm64|ochgroup|och):\\d+/\\d+/\\d+/\\d+(\\.\\d+){0,}"; 19 | } 20 | } 21 | } 22 | } // config module 23 | -------------------------------------------------------------------------------- /test/lux/yin/yin_plugin_macro.lux: -------------------------------------------------------------------------------- 1 | # author: lbevemyr@cisco.com 2 | [doc Test of the yanger yin plugin. Comparing it to the predecessor pyang yin.] 3 | 4 | [macro yin_compare FILE] 5 | ~yanger -f yin -p ${DIR} ${DIR}/${FILE} 6 | ! | sed 's/ *$//' > test.yanger.yin 7 | !echo ==$?== 8 | ?==0== 9 | 10 | ~pyang --ignore-errors -f yin -p ${DIR} ${DIR}/${FILE} 11 | ! | sed 's/ *$//' > test.pyang.yin 12 | !echo ==$?== 13 | ?==0== 14 | 15 | !diff -u test.pyang.yin test.yanger.yin 16 | !echo ==$?== 17 | ?==0== 18 | - 19 | [endmacro] 20 | 21 | 22 | [shell test_yanger_yin] 23 | [timeout 20] 24 | 25 | [global DIR=../tree] 26 | [invoke yin_compare small2.yang] 27 | [invoke yin_compare small3.yang] 28 | [invoke yin_compare small4.yang] 29 | [invoke yin_compare small5.yang] 30 | [invoke yin_compare a.yang] 31 | 32 | # use pyang test modules 33 | [global DIR=./test_good] 34 | [invoke yin_compare yt5.yang] 35 | [invoke yin_compare yt6.yang] 36 | [invoke yin_compare yt7.yang] 37 | [invoke yin_compare yt8.yang] 38 | [invoke yin_compare yt9.yang] 39 | [invoke yin_compare yt10.yang] 40 | [invoke yin_compare qs.yang] 41 | [invoke yin_compare q.yang] 42 | [invoke yin_compare w.yang] 43 | [invoke yin_compare xt5.yang] 44 | [invoke yin_compare xt6.yang] 45 | [invoke yin_compare xt7.yang] 46 | [invoke yin_compare xt10.yang] 47 | [invoke yin_compare a.yang] 48 | [invoke yin_compare b.yang] 49 | 50 | 51 | # test tailf-modules 52 | [global DIR=./test_tailf_info] 53 | [invoke yin_compare config.yang] 54 | 55 | # use some test modules 56 | [global DIR=.] 57 | [invoke yin_compare small6.yang] 58 | 59 | [cleanup] 60 | !rm -f test.yanger.yin 61 | !rm -f test.pyang.yin 62 | 63 | -------------------------------------------------------------------------------- /test/lux/yin/yin_plugin_macro_pretty_strings.lux: -------------------------------------------------------------------------------- 1 | # author: lbevemyr@cisco.com 2 | [doc Test of the yanger yin plugin with the pretty strings option.] 3 | 4 | [macro yin_compare FILE] 5 | ~yanger -f yin -p ${DIR} ${DIR}/${FILE} --yin-pretty-strings 6 | ! | sed 's/ *$//' > test.yanger.yin 7 | !echo ==$?== 8 | ?==0== 9 | 10 | ~pyang --ignore-errors -f yin -p ${DIR} ${DIR}/${FILE} --yin-pretty-strings 11 | ! | sed 's/ *$//' > test.pyang.yin 12 | !echo ==$?== 13 | ?==0== 14 | 15 | !diff -u test.pyang.yin test.yanger.yin 16 | !echo ==$?== 17 | ?==0== 18 | - 19 | [endmacro] 20 | 21 | 22 | [shell test_yanger_yin] 23 | [timeout 20] 24 | 25 | [global DIR=../tree] 26 | [invoke yin_compare small2.yang] 27 | [invoke yin_compare small3.yang] 28 | [invoke yin_compare small4.yang] 29 | [invoke yin_compare small5.yang] 30 | [invoke yin_compare a.yang] 31 | 32 | # use pyang test modules 33 | [global DIR=./test_good] 34 | [invoke yin_compare yt5.yang] 35 | [invoke yin_compare yt6.yang] 36 | [invoke yin_compare yt7.yang] 37 | [invoke yin_compare yt8.yang] 38 | [invoke yin_compare yt9.yang] 39 | [invoke yin_compare yt10.yang] 40 | [invoke yin_compare qs.yang] 41 | [invoke yin_compare q.yang] 42 | [invoke yin_compare w.yang] 43 | [invoke yin_compare xt5.yang] 44 | [invoke yin_compare xt6.yang] 45 | [invoke yin_compare xt7.yang] 46 | [invoke yin_compare xt10.yang] 47 | [invoke yin_compare a.yang] 48 | [invoke yin_compare b.yang] 49 | 50 | # use some test modules 51 | [global DIR=.] 52 | [invoke yin_compare small6.yang] 53 | 54 | [cleanup] 55 | !rm -f test.yanger.yin 56 | !rm -f test.pyang.yin 57 | 58 | -------------------------------------------------------------------------------- /test/support/eunit.mk: -------------------------------------------------------------------------------- 1 | 2 | ERL=erl 3 | ERLC=erlc 4 | 5 | EXTRA_EUNIT_BUILD ?= 6 | EXTRA_ERL_FLAGS ?= -pa ../../ebin 7 | EXTRA_ERLC_FLAGS ?= 8 | 9 | TEST_SRC ?= $(wildcard ./*.erl) 10 | TEST_SUITES ?= $(wildcard ./*_tests.erl) 11 | TEST_MODULES2 ?= $(subst ./,,$(subst .erl,,$(TEST_SUITES))) 12 | TEST_MODULES ?= $(shell echo $(TEST_MODULES2) | sed -e 's/ /, /g') 13 | TEST_BEAM ?= $(subst .erl,.beam,$(subst ./,ebin/test/,$(TEST_SRC))) 14 | 15 | SRC_DIRS=$(shell pwd) 16 | 17 | # Use absolute path for yanger/ebin using pwd to ensure 18 | # that code:priv_dir resolves correct. 19 | TEST_EXTRA_ERL_FLAGS=-pa $(shell cd ../../ebin && pwd) $(EXTRA_ERL_FLAGS) \ 20 | -pa ebin/test -pa ebin/app 21 | 22 | test: build $(APP_BEAM) $(TEST_BEAM) 23 | @$(ERL) $(TEST_EXTRA_ERL_FLAGS) -noinput \ 24 | -eval "eunit:test([$(TEST_MODULES)], [verbose])" \ 25 | -s init stop 26 | 27 | test-%: build $(APP_BEAM) $(TEST_BEAM) 28 | env ERL="$(ERL)" EXTRA_ERL_FLAGS="$(TEST_EXTRA_ERL_FLAGS)" \ 29 | ../support/run_eunit.sh test-single $(subst test-,,$@) 30 | 31 | # Mandatory targets 32 | build: ebin/test ebin/app $(EXTRA_EUNIT_BUILD) $(TEST_BEAM) 33 | @echo "Build complete" 34 | 35 | clean: 36 | -rm -rf $(BEAM) test-reports ebin 37 | 38 | ###################################################################### 39 | # Internal targets 40 | 41 | ebin/test: 42 | mkdir -p ebin/test 43 | 44 | ebin/app: 45 | mkdir -p ebin/app 46 | 47 | ebin/test/%.beam: %.erl 48 | $(ERLC) -DTEST -I ../../../ -I ../../include $(EXTRA_ERLC_FLAGS) \ 49 | +debug_info -o ebin/test $< 50 | 51 | ebin/app/%.beam: ../../src/%.erl 52 | $(ERLC) -DTEST -I ../../../ -I ../../include $(EXTRA_ERLC_FLAGS) \ 53 | +export_all +debug_info -o ebin/app $< 54 | -------------------------------------------------------------------------------- /test/support/lux_testarea.mk: -------------------------------------------------------------------------------- 1 | # Targets for building and running tests within a testarea 2 | 3 | # Default values for make script 4 | SUMMARY_LOG=lux_summary.log.html 5 | SUT_RUN_TARGETS=default 6 | LUX=lux 7 | LOG_DIR=lux/ 8 | 9 | ifeq ($(LUX_FILES),) 10 | LUX_FILES=. 11 | endif 12 | 13 | # Finds which test cases should be run 14 | ifeq ($(LUXSUBDIRS),) 15 | FILES = $(shell $(LUX) --mode list $(LUX_FILES)) 16 | ifneq ($(FILES),) 17 | LUXSUBDIRS=$(shell for d in $(FILES); do echo `dirname $$d`; done|sort -u) 18 | else 19 | LUXSUBDIRS=empty 20 | endif 21 | endif 22 | 23 | # Builds a testarea 24 | build_testarea: 25 | @if [ "$(SUT_RUN_TARGETS)" = "default" ]; then \ 26 | if [ "$(LUXSUBDIRS)" != "empty" ]; then \ 27 | for d in $(LUXSUBDIRS); do \ 28 | echo "cd $$d" ; \ 29 | (cd $$d && $(MAKE) build EXECTARGET="no") || exit 1; \ 30 | done ; \ 31 | fi; \ 32 | fi; 33 | 34 | .PHONY: build_testarea 35 | 36 | # Cleans a test area note that it will only clean SUT_RUN_TARGETS=default 37 | clean_testarea: 38 | @rm -fr lux_logs; \ 39 | if [ "$(LUXSUBDIRS)" != "empty" ]; then \ 40 | for d in $(LUXSUBDIRS); do \ 41 | ( \ 42 | (cd $$d && $(MAKE) clean EXECTARGET="no" ) || exit 1 \ 43 | ); \ 44 | done; \ 45 | fi; 46 | .PHONY: clean_testarea 47 | 48 | # Runs a testarea 49 | test_testarea: 50 | for type in $(SUT_RUN_TARGETS); do \ 51 | if [ "$$type" = "default" ]; then \ 52 | RUN_TYPE_SUFFIX=""; \ 53 | echo "Default no need to use SUT_RUN_TARGETS"; \ 54 | else \ 55 | RUN_TYPE_SUFFIX="_$$type"; \ 56 | if [ "$(LUXSUBDIRS)" != "" ]; then \ 57 | $(MAKE) $$type; \ 58 | else \ 59 | echo "No need to build SUT_RUN_TARGET= $$type SKIPPED"; \ 60 | fi ; \ 61 | fi ; \ 62 | LUXARGS="$(LUX_ARGS)" ; \ 63 | ($(LUX) $$LUXARGS $(LUX_FILES)) || failed="true"; \ 64 | done; \ 65 | if [ "$$failed" = "true" ]; then exit 1; fi 66 | 67 | 68 | .PHONY: test_testarea 69 | 70 | lux_desc: 71 | @env $(LUX) --config_name Docspec --mode=doc --skip_skip $(LUX_FILES) 72 | .PHONY: lux_desc 73 | -------------------------------------------------------------------------------- /test/support/lux_testcases.mk: -------------------------------------------------------------------------------- 1 | #Targets for building and running tests within a testarea 2 | 3 | #Default values for make script 4 | SUMMARYLOG=lux.summary.log.html 5 | SUT_RUN_TARGET=default 6 | LUX=lux 7 | LUX_FILES?=. 8 | LUX_FLAGS_DEFAULT="--progress=verbose --debug" 9 | 10 | LUX_FLAGSs = $(shell echo $$LUX_FLAGS) 11 | 12 | #Set the PATH varible 13 | PATH := $(TEST_DIR)/bin:$(PATH) 14 | 15 | all: build test 16 | 17 | . PHONY: all 18 | 19 | #Runs a testcase 20 | test: dotest 21 | .PHONY: test 22 | 23 | dotest: 24 | if [ "$(LUX_FLAGSs)" != "" ]; then \ 25 | LUX_FLAGSx=$(LUX_FLAGSs) ; \ 26 | fi ; env "LUX_FLAGS=$$LUX_FLAGSx" $(LUX) $(LUX_FILES) 27 | .PHONY: dotest 28 | -------------------------------------------------------------------------------- /vsn.mk: -------------------------------------------------------------------------------- 1 | VSN=1.2.1 2 | --------------------------------------------------------------------------------