Keyword "min" (not only "max") can be used in built-in types "range" and "length" statements.

This commit is contained in:
Olof hagsand 2019-01-06 22:11:59 +01:00
parent bd67a2a5f2
commit c7e847cd24
14 changed files with 469 additions and 405 deletions

View file

@ -2,8 +2,9 @@
This directory contains testing code for clixon and the example
application. Assumes setup of http daemon as describe under apps/restonf
- clixon A top-level script clones clixon in /tmp and starts all.sh. You can copy this file (review it first) and place as cron script
- Jenkinsfile Makefile for Jenkins tests. Build clixon and run tests.
- all.sh Run through all tests named 'test*.sh' in this directory. Therefore, if you place a test in this directory matching 'test*.sh' it will be run automatically. By default the script will exit on first error. Run as `all.sh summary` to continue and print a summary on all tests.
- site.sh Add your site-specific modifications here
- test_nacm.sh Auth tests using internal NACM
- test_nacm_ext.sh Auth tests using external NACM (separate file)
- test_cli.sh CLI tests
@ -12,6 +13,7 @@ application. Assumes setup of http daemon as describe under apps/restonf
- test_yang.sh Yang tests for constructs not in the example.
- test_leafref.sh Yang leafref tests
- test_datastore.sh Datastore tests
- and many more...
Example runs:
```

View file

@ -3,9 +3,6 @@
# Note that the openconfig test suites are patched to counter CLixon issues as follows:
# - release/models/mpls/openconfig-mpls-te.yang
# issue: https://github.com/clicon/clixon/issues/60
# - release/models/wifi/types/openconfig-wifi-types.yang
# issue: https://github.com/clicon/clixon/issues/59
#
# Yang specifics: multi-keys and empty type
APPNAME=example

View file

@ -1,8 +1,10 @@
#!/bin/bash
# Advanced union types and generated code
# and enum w values
# XXX NO SUPPORT FOR lists of ranges and lengths !!!
APPNAME=example
# include err() and new() functions and creates $dir
. ./lib.sh
cfg=$dir/conf_yang.xml
@ -123,57 +125,47 @@ module example{
enum down;
}
}
leaf length1 {
type string {
length "1";
}
}
/* leaf length2 {
type string {
length "max";
}
}
leaf length3 {
type string {
length "min";
}
}*/
leaf length4 {
type string {
length "4..4000";
}
}
/* leaf length5 {
type string {
length "min..max";
}
}*/
leaf num1 {
type int32 {
range "1";
}
}
/* leaf num2 {
type int32 {
range "min";
}
}
leaf num3 {
type int32 {
range "max";
}
}
*/
leaf num4 {
leaf num2 {
type int32 {
range "4..4000";
}
}
/* leaf num5 {
type int32 {
leaf num3 {
type uint8 {
range "min..max";
}
}*/
}
leaf num4 { /* XXX multiple ranges not supported yet - only first*/
type uint8 {
range "1 .. 2 | 42";
}
}
leaf len1 {
type string {
length "2";
}
}
leaf len2 {
type string {
length "4..4000";
}
}
leaf len3 {
type string {
length "min..max";
}
}
leaf len4 {
type string {
range "1 .. 2 | 42";
}
}
typedef mybits {
description "Test adding several bits";
type bits {
@ -303,6 +295,70 @@ expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><can
new "cli bits validate"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang validate" 0 "^$"
#----------------int ranges---------------------
new "cli range test num1 1 OK"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 1" 0 "^$"
#new "cli range test num1 -100 ok" # XXX - cant be given on cmd line
#expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 \-100" 0 "^$"
new "cli range test num1 2 error"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num1 2" 255 "^$"
new "netconf range set num1 -1"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><num1 xmlns="urn:example:clixon">-1</num1></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf validate num1 -1 wrong"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>num1</bad-element></error-info><error-severity>error</error-severity><error-message>Number out of range: -1</error-message></rpc-error></rpc-reply>]]>]]>$'
new "cli range test num2 1000 ok"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 1000" 0 "^$"
new "cli range test num2 3 error"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 3" 255 "^$"
new "cli range test num2 5000 error"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num2 5000" 255 "^$"
new "cli range test num3 42 ok"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 42" 0 "^$"
new "cli range test num3 260 error"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set num3 260" 255 "^$"
#----------------string ranges---------------------
new "cli length test len1 1 error"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 x" 255 "^$"
new "cli length test len1 2 OK"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 xy" 0 "^$"
new "cli length test len1 3 error"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len1 hej" 255 "^$"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf length set len1 1"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 '<rpc><edit-config><target><candidate/></target><config><len1 xmlns="urn:example:clixon">x</len1></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf validate len1 1 wrong"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" '^<rpc-reply><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>len1</bad-element></error-info><error-severity>error</error-severity><error-message>string length out of range: 1</error-message></rpc-error></rpc-reply>]]>]]>$'
new "cli length test len2 42 ok"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 hejhophdsakjhkjsadhkjsahdkjsad" 0 "^$"
new "netconf discard-changes"
expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "cli length test len2 3 error"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len2 ab" 255 "^$"
new "cli range test len3 42 ok"
expectfn "$clixon_cli -1f $cfg -l o -y $fyang set len3 hsakjdhkjsahdkjsahdksahdksajdhsakjhd" 0 "^$"
if [ $BE -eq 0 ]; then
exit # BE
fi