From 7631c3f0a3de444102380822d808fbe57b98d534 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 6 Oct 2021 08:36:34 +0200 Subject: [PATCH] coverage: added tests for all ints --- apps/backend/backend_client.c | 11 +++++++- codecov.yml | 1 - test/test_order.sh | 49 ++++++++++++++++++++++++++++++----- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index bf880838..cad66831 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -206,10 +206,17 @@ clixon_stats_get_db(clicon_handle h, cxobj *xt = NULL; uint64_t nr = 0; size_t sz = 0; + cxobj *xn = NULL; /* This is the db cache */ - if ((xt = xmldb_cache_get(h, dbname)) == NULL){ + if ((xt = xmldb_cache_get(h, dbname)) == NULL){ + /* Trigger cache if no exist */ + if (xmldb_get(h, dbname, NULL, "/", &xn) < 0) + goto done; + xt = xmldb_cache_get(h, dbname); + } + if (xt == NULL){ cprintf(cb, "%s00", dbname); } else{ @@ -221,6 +228,8 @@ clixon_stats_get_db(clicon_handle h, } retval = 0; done: + if (xn) + xml_free(xn); return retval; } diff --git a/codecov.yml b/codecov.yml index 7492cf38..3405e629 100644 --- a/codecov.yml +++ b/codecov.yml @@ -20,6 +20,5 @@ comment: require_changes: no ignore: - - "util/" - "example/" diff --git a/test/test_order.sh b/test/test_order.sh index fb10efe9..d937a8da 100755 --- a/test/test_order.sh +++ b/test/test_order.sh @@ -96,10 +96,39 @@ module order-example{ type string; ordered-by system; } - leaf-list ints{ + /* Follow list of all int types mostly to get coverage */ + leaf-list myint8{ + type int8; + ordered-by system; + } + leaf-list myint16{ + type int16; + ordered-by system; + } + leaf-list myint32{ type int32; ordered-by system; } + leaf-list myint64{ + type int64; + ordered-by system; + } + leaf-list myuint8{ + type uint8; + ordered-by system; + } + leaf-list myuint16{ + type uint16; + ordered-by system; + } + leaf-list myuint32{ + type uint32; + ordered-by system; + } + leaf-list myuint64{ + type uint64; + ordered-by system; + } list listints{ ordered-by system; key a; @@ -257,13 +286,21 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1102]]>]]>$" -new "put leaf-list int (10,2,1)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO -1021 +for s in int uint; do + for t in 8 16 32 64; do + type=$s$t + new "put leaf-list $type (10,2,1)" + expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO +1021 ]]>]]>" "^]]>]]>$" -new "check leaf-list int order (1,2,10)" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1210]]>]]>$" + new "check leaf-list $type order (1,2,10)" + expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^1210]]>]]>$" + done +done + +new "netconf validate ints" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" new "put list int (10,2,1)" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO