From 9b6bb3ecbfc3e1f3487cb59c4653ccffe5106a29 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 27 Sep 2021 16:31:21 +0200 Subject: [PATCH] - Added transaction_arg_set() - Modifed coverage script --- CHANGELOG.md | 10 +++---- apps/backend/backend_plugin.c | 2 +- apps/backend/clixon_backend_plugin.h | 4 +-- apps/backend/clixon_backend_transaction.c | 33 +++++++++++++++-------- apps/backend/clixon_backend_transaction.h | 1 + test/cicd/coverage.sh | 16 ++++++----- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 513f435b..177eeba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ ## 5.3.0 27 September, 2021 -The 5.3 release has pagination support, YANG/auto-clilinkref changes and lots of bug fixes. +The 5.3 release has pagination support, Linkref changes in validation and auto-cli, and lots of bug fixes. ### New features @@ -50,10 +50,10 @@ The 5.3 release has pagination support, YANG/auto-clilinkref changes and lots of * New http media: application/yang-collection+xml/json * Updated state callback signature containing parameters for pagination * See API changes below - * See [User manual pagination](https://clixon-docs.readthedocs.io/en/latest/misc.html#pagination) * Work-in-progress * Enable remaining attriute with LIST_PAGINATION_REMAINING compile-time option * sort/direction/where etc not supported + * For documentation: [User manual pagination](https://clixon-docs.readthedocs.io/en/latest/misc.html#pagination) * YANG Leafref feature update * Closer adherence to RFC 7950. Some of this is changed behavior, some is new feature. * Validation uses referred node @@ -75,12 +75,12 @@ Users may have to change how they access the system * Looser leafref validation checks * Leafref required-instance must be set to make strict data-node check - * See changes under new feature "YANG leafref feature update" + * See changes under new feature "YANG leafref feature update" above * Native Restconf * Native restconf is now default, not fcgi/nginx * To configure with fcgi, you need to explicitly configure: `--with-restconf=fcgi` - * SSL client certs failures are returned as http 405 errors, not fail during SSL negotiation -* New clixon-config@2021-07-11.yang revision + * SSL client certs failures are returned as http `405` errors, not fail during SSL negotiation +* New `clixon-config@2021-07-11.yang` revision * Added: `CLICON_RESTCONF_HTTP2_PLAIN` * Removed default of `CLICON_RESTCONF_INSTALLDIR` * The default behaviour is changed to use the config `$(sbindir)` to locate `clixon_restconf` when starting restconf internally diff --git a/apps/backend/backend_plugin.c b/apps/backend/backend_plugin.c index 9e1e68b5..53d980c1 100644 --- a/apps/backend/backend_plugin.c +++ b/apps/backend/backend_plugin.c @@ -506,7 +506,7 @@ transaction_free(transaction_data_t *td) * @retval -1 Error */ int -plugin_transaction_begin_one(clixon_plugin_t *cp, +plugin_transaction_begin_one(clixon_plugin_t *cp, clicon_handle h, transaction_data_t *td) { diff --git a/apps/backend/clixon_backend_plugin.h b/apps/backend/clixon_backend_plugin.h index ec83b7a0..5bcb8766 100644 --- a/apps/backend/clixon_backend_plugin.h +++ b/apps/backend/clixon_backend_plugin.h @@ -43,14 +43,14 @@ */ /*! Transaction data describing a system transition from a src to target state - * Clicon internal, presented as void* to app's callback in the 'transaction_data' + * Clixon internal, presented as void* to app's callback in the 'transaction_data' * type in clicon_backend_api.h * The struct contains source and target XML tree (e.g. candidate/running) * But primarily a set of XML tree vectors (dvec, avec, cvec) and associated lengths * These contain the difference between src and target XML, ie "what has changed". * It is up to the validate callbacks to ensure that these changes are OK * It is up to the commit callbacks to enforce these changes in the "state" of - *the system. + * the system. */ typedef struct { uint64_t td_id; /* Transaction id */ diff --git a/apps/backend/clixon_backend_transaction.c b/apps/backend/clixon_backend_transaction.c index ffc97d43..48f25c27 100644 --- a/apps/backend/clixon_backend_transaction.c +++ b/apps/backend/clixon_backend_transaction.c @@ -81,12 +81,23 @@ transaction_id(transaction_data td) /*! Get plugin/application specific callback argument * @param[in] td transaction_data * @retval arg callback argument - * @note NYI */ void * transaction_arg(transaction_data td) { - return ((transaction_data_t *)td)->td_arg; + return ((transaction_data_t *)td)->td_arg; +} + +/*! Set plugin/application specific callback argument + * @param[in] td transaction_data + * @param[in] arg callback argument + */ +int +transaction_arg_set(transaction_data td, + void *arg) +{ + ((transaction_data_t *)td)->td_arg = arg; + return 0; } /*! Get source database xml tree @@ -96,7 +107,7 @@ transaction_arg(transaction_data td) cxobj * transaction_src(transaction_data td) { - return ((transaction_data_t *)td)->td_src; + return ((transaction_data_t *)td)->td_src; } /*! Get target database xml tree @@ -106,7 +117,7 @@ transaction_src(transaction_data td) cxobj * transaction_target(transaction_data td) { - return ((transaction_data_t *)td)->td_target; + return ((transaction_data_t *)td)->td_target; } /*! Get delete xml vector, ie vector of xml nodes that are deleted src->target @@ -116,7 +127,7 @@ transaction_target(transaction_data td) cxobj ** transaction_dvec(transaction_data td) { - return ((transaction_data_t *)td)->td_dvec; + return ((transaction_data_t *)td)->td_dvec; } /*! Get length of delete xml vector @@ -127,7 +138,7 @@ transaction_dvec(transaction_data td) size_t transaction_dlen(transaction_data td) { - return ((transaction_data_t *)td)->td_dlen; + return ((transaction_data_t *)td)->td_dlen; } /*! Get add xml vector, ie vector of xml nodes that are added src->target @@ -137,7 +148,7 @@ transaction_dlen(transaction_data td) cxobj ** transaction_avec(transaction_data td) { - return ((transaction_data_t *)td)->td_avec; + return ((transaction_data_t *)td)->td_avec; } /*! Get length of add xml vector @@ -148,7 +159,7 @@ transaction_avec(transaction_data td) size_t transaction_alen(transaction_data td) { - return ((transaction_data_t *)td)->td_alen; + return ((transaction_data_t *)td)->td_alen; } /*! Get source changed xml vector, ie vector of xml nodes that changed @@ -162,7 +173,7 @@ transaction_alen(transaction_data td) cxobj ** transaction_scvec(transaction_data td) { - return ((transaction_data_t *)td)->td_scvec; + return ((transaction_data_t *)td)->td_scvec; } /*! Get target changed xml vector, ie vector of xml nodes that changed @@ -176,7 +187,7 @@ transaction_scvec(transaction_data td) cxobj ** transaction_tcvec(transaction_data td) { - return ((transaction_data_t *)td)->td_tcvec; + return ((transaction_data_t *)td)->td_tcvec; } /*! Get length of changed xml vector @@ -187,7 +198,7 @@ transaction_tcvec(transaction_data td) size_t transaction_clen(transaction_data td) { - return ((transaction_data_t *)td)->td_clen; + return ((transaction_data_t *)td)->td_clen; } /*! Print transaction on FILE for debug diff --git a/apps/backend/clixon_backend_transaction.h b/apps/backend/clixon_backend_transaction.h index 7c8cd13c..8a4095ca 100644 --- a/apps/backend/clixon_backend_transaction.h +++ b/apps/backend/clixon_backend_transaction.h @@ -51,6 +51,7 @@ */ uint64_t transaction_id(transaction_data td); void *transaction_arg(transaction_data td); +int transaction_arg_set(transaction_data td, void *arg); cxobj *transaction_src(transaction_data td); cxobj *transaction_target(transaction_data td); cxobj **transaction_dvec(transaction_data td); diff --git a/test/cicd/coverage.sh b/test/cicd/coverage.sh index 1afa9b9c..fe90e998 100755 --- a/test/cicd/coverage.sh +++ b/test/cicd/coverage.sh @@ -13,8 +13,8 @@ TOKEN=$1 # LINKAGE=static # Configure (clixon) -CFLAGS="-g -Wall" INSTALLFLAGS="" ./configure -sudo ldconfig +#CFLAGS="-g -Wall" INSTALLFLAGS="" ./configure +#sudo ldconfig LDFLAGS=-coverage LINKAGE=static CFLAGS="-g -Wall -coverage" INSTALLFLAGS="" ./configure # Build @@ -27,17 +27,19 @@ sudo make install-include (cd example; sudo make install) (cd util; sudo make install) -# Kludge for netconf to add as non-root -(cd test; ./test_netconf_hello.sh) +# Kludge for netconf to touch all gcda files as root +(cd test; sudo ./test_netconf_hello.sh) || true find . -name "*.gcda" | xargs sudo chmod 777 +# Run restconf as root (cd test; clixon_restconf="clixon_restconf -r" ./sum.sh) # Push coverage -# PUSH $TOKEN +bash <(curl -s https://codecov.io/bash) -t ${TOKEN} -# remove all coverage files (after gcov push) +# Remove all coverage files (after gcov push) find . -name "*.gcda" | xargs rm +find . -name "*.gcno" | xargs rm -sleep 1 # ensure OK is last +sleep 1 # ensure OK is last echo OK