diff --git a/CHANGELOG.md b/CHANGELOG.md index 0718eb21..7c37aa27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,7 @@ * Many hand-crafted validation messages have been removed and replaced with generic validations, which may lead to changed rpc-error messages. * CLICON_XML_SORT option (in clixon-config.yang) has been removed and set to true permanently. Unsorted XML lists leads to slower performance and old obsolete code can be removed. * Strict namespace setting can be a problem when upgrading existing database files, such as startup-db or persistent running-db, or any other saved XML file. +* Removed obsolete `-x` command-line option to clixon_cli. * Removed `delete-config` support for candidate db since it is not supported in RFC6241. * Switched the order of `error-type` and `error-tag` in all netconf and restconf error messages to comply to RFC order. * XML namespace handling is corrected (see major changes) @@ -129,14 +130,15 @@ * `=" command-line option to all programs: backend, cli, netconf, restconf. diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 0bf2a7f8..31f7eafe 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -77,7 +77,10 @@ #define BACKEND_LOGFILE "/usr/local/var/clixon_backend.log" -/*! Terminate. Cannot use h after this */ +/*! Clean and close all state of backend (but dont exit). + * Cannot use h after this + * @param[in] h Clixon handle + */ static int backend_terminate(clicon_handle h) { @@ -87,8 +90,11 @@ backend_terminate(clicon_handle h) char *sockpath = clicon_sock(h); cxobj *x; struct stat st; + int ss; clicon_debug(1, "%s", __FUNCTION__); + if ((ss = clicon_socket_get(h)) != -1) + close(ss); if ((yspec = clicon_dbspec_yang(h)) != NULL) yspec_free(yspec); if ((yspec = clicon_config_yang(h)) != NULL) @@ -931,10 +937,11 @@ main(int argc, goto done; } - /* Initialize server socket */ + /* Initialize server socket and save it to handle */ if ((ss = backend_server_socket(h)) < 0) goto done; - + if (clicon_socket_set(h, ss) < 0) + goto done; if (debug) clicon_option_dump(h, debug); @@ -945,8 +952,6 @@ main(int argc, retval = 0; done: clicon_log(LOG_NOTICE, "%s: %u Terminated retval:%d", __PROGRAM__, getpid(), retval); - if (ss != -1) - close(ss); backend_terminate(h); /* Cannot use h after this */ return retval; diff --git a/apps/cli/cli_handle.c b/apps/cli/cli_handle.c index 34a92c4d..e2f25121 100644 --- a/apps/cli/cli_handle.c +++ b/apps/cli/cli_handle.c @@ -83,7 +83,7 @@ struct cli_handle { /* ------ end of common handle ------ */ cligen_handle cl_cligen; /* cligen handle */ - cli_syntax_t *cl_stx; /* syntax structure */ + cli_syntax_t *cl_stx; /* CLI syntax structure */ }; /*! Return a clicon handle for other CLICON API calls diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index fba80de1..905fb5b8 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -71,11 +71,12 @@ #include "cli_handle.h" /* Command line options to be passed to getopt(3) */ -#define CLI_OPTS "hD:f:xl:F:1a:u:d:m:qp:GLy:c:U:o:" +#define CLI_OPTS "hD:f:l:F:1a:u:d:m:qp:GLy:c:U:o:" -#define CLI_LOGFILE "/tmp/clixon_cli.log" - -/*! terminate cli application */ +/*! Clean and close all state of cli process (but dont exit). + * Cannot use h after this + * @param[in] h Clixon handle + */ static int cli_terminate(clicon_handle h) { @@ -144,63 +145,6 @@ cli_interactive(clicon_handle h) return retval; } -/*! Read file as configuration file and print xml file for migrating to new fmt - * @see clicon_option_readfile_xml - */ -static int -dump_configfile_xml_fn(FILE *fout, - const char *filename) -{ - struct stat st; - char opt[1024]; - char val[1024]; - char line[1024]; - char *cp; - FILE *f = NULL; - int retval = -1; - char *suffix; - - if (filename == NULL || !strlen(filename)){ - clicon_err(OE_UNIX, 0, "Not specified"); - goto done; - } - if ((suffix = rindex(filename, '.')) != NULL && - strcmp((suffix+1), "xml") == 0){ - clicon_err(OE_CFG, 0, "Configfile %s should not be XML", filename); - goto done; - } - if (stat(filename, &st) < 0){ - clicon_err(OE_UNIX, errno, "%s", filename); - goto done; - } - if (!S_ISREG(st.st_mode)){ - clicon_err(OE_UNIX, 0, "%s is not a regular file", filename); - goto done; - } - if ((f = fopen(filename, "r")) == NULL) { - clicon_err(OE_UNIX, errno, "configure file: %s", filename); - return -1; - } - clicon_debug(2, "%s: Reading config file %s", __FUNCTION__, filename); - fprintf(fout, "\n"); - while (fgets(line, sizeof(line), f)) { - if ((cp = strchr(line, '\n')) != NULL) /* strip last \n */ - *cp = '\0'; - /* Trim out comments, strip whitespace, and remove CR */ - if ((cp = strchr(line, '#')) != NULL) - memcpy(cp, "\n", 2); - if (sscanf(line, "%s %s", opt, val) < 2) - continue; - fprintf(fout, "\t<%s>%s\n", opt, val, opt); - } - fprintf(fout, "\n"); - retval = 0; - done: - if (f) - fclose(f); - return retval; -} - static void usage(clicon_handle h, char *argv0) @@ -213,7 +157,6 @@ usage(clicon_handle h, "\t-h \t\tHelp\n" "\t-D \tDebug level\n" "\t-f \tConfig-file (mandatory)\n" - "\t-x\t\tDump configuration file as XML on stdout (migration utility)\n" "\t-F \tRead commands from file (default stdin)\n" "\t-1\t\tDo not enter interactive mode\n" "\t-a UNIX|IPv4|IPv6\tInternal backend socket family\n" @@ -251,7 +194,6 @@ main(int argc, char **argv) int help = 0; int logdst = CLICON_LOG_STDERR; char *restarg = NULL; /* what remains after options */ - int dump_configfile_xml = 0; yang_spec *yspec; yang_spec *yspecfg = NULL; /* For config XXX clixon bug */ struct passwd *pw; @@ -265,6 +207,7 @@ main(int argc, char **argv) /* Initiate CLICON handle */ if ((h = cli_handle_init()) == NULL) goto done; + /* Set username to clicon handle. Use in all communication to backend * Note, can be overridden by -U */ @@ -301,9 +244,6 @@ main(int argc, char **argv) usage(h, argv[0]); clicon_option_str_set(h, "CLICON_CONFIGFILE", optarg); break; - case 'x': /* dump config file as xml (migration from .conf file)*/ - dump_configfile_xml++; - break; case 'l': /* Log destination: s|e|o|f */ if ((logdst = clicon_log_opt(optarg[0])) < 0) usage(h, argv[0]); @@ -320,14 +260,6 @@ main(int argc, char **argv) clicon_debug_init(debug, NULL); - /* Use cli as util tool to dump config file as xml for migration */ - if (dump_configfile_xml) { - clicon_hash_t *copt = clicon_options(h); - char *configfile = hash_value(copt, "CLICON_CONFIGFILE", NULL); - if (dump_configfile_xml_fn(stdout, configfile) < 0) - goto done; - } - /* Create top-level yang spec and store as option */ if ((yspecfg = yspec_new()) == NULL) goto done; @@ -345,7 +277,6 @@ main(int argc, char **argv) switch (c) { case 'D' : /* debug */ case 'f': /* config file */ - case 'x': /* dump config file as xml */ case 'l': /* Log destination */ break; /* see above */ case 'F': /* read commands from file */ diff --git a/apps/netconf/netconf_main.c b/apps/netconf/netconf_main.c index b6c1e930..27794d65 100644 --- a/apps/netconf/netconf_main.c +++ b/apps/netconf/netconf_main.c @@ -283,6 +283,10 @@ send_hello(clicon_handle h, return retval; } +/*! Clean and close all state of netconf process (but dont exit). + * Cannot use h after this + * @param[in] h Clixon handle + */ static int netconf_terminate(clicon_handle h) { diff --git a/apps/restconf/restconf_lib.c b/apps/restconf/restconf_lib.c index ec6689c4..161d80bc 100644 --- a/apps/restconf/restconf_lib.c +++ b/apps/restconf/restconf_lib.c @@ -471,12 +471,20 @@ api_return_err(clicon_handle h, return retval; } +/*! Clean and close all state of restconf process (but dont exit). + * Cannot use h after this + * @param[in] h Clixon handle + */ int restconf_terminate(clicon_handle h) { yang_spec *yspec; cxobj *x; + int fs; /* fgcx socket */ + clicon_debug(1, "%s", __FUNCTION__); + if ((fs = clicon_socket_get(h)) != -1) + close(fs); clixon_plugin_exit(h); rpc_callback_delete_all(); clicon_rpc_close_session(h); @@ -490,3 +498,4 @@ restconf_terminate(clicon_handle h) clicon_log_exit(); return 0; } + diff --git a/apps/restconf/restconf_main.c b/apps/restconf/restconf_main.c index f4de845a..dc21b5aa 100644 --- a/apps/restconf/restconf_main.c +++ b/apps/restconf/restconf_main.c @@ -694,6 +694,8 @@ main(int argc, clicon_err(OE_CFG, errno, "FCGX_OpenSocket"); goto done; } + if (clicon_socket_set(h, sock) < 0) + goto done; /* umask settings may interfer: we want group to write: this is 774 */ if (chmod(sockpath, S_IRWXU|S_IRWXG|S_IROTH) < 0){ clicon_err(OE_UNIX, errno, "chmod"); diff --git a/docker/Makefile.in b/docker/Makefile.in index b7711d98..51443a4e 100644 --- a/docker/Makefile.in +++ b/docker/Makefile.in @@ -44,23 +44,38 @@ SUBDIRS = base SUBDIRS += system #SUBDIRS += cluster -.PHONY: all clean distclean depend install-include install uninstall test +.PHONY: all clean distclean depend install-include install uninstall test $(SUBDIRS) all: $(SUBDIRS) +$(SUBDIRS): + (cd $@; $(MAKE) $(MFLAGS) all) + clean: + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done distclean: clean rm -f Makefile *~ .depend + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done test: - (cd system && $(MAKE) $(MFLAGS) test) + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done depend: + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@); done install-include: + for i in $(SUBDIRS); \ + do (cd $$i && $(MAKE) $(MFLAGS) $@||exit 1); done; install: + for i in $(SUBDIRS); \ + do (cd $$i && $(MAKE) $(MFLAGS) $@)||exit 1; done uninstall: - + for i in $(SUBDIRS); \ + do (cd $$i; $(MAKE) $(MFLAGS) $@)||exit 1; done diff --git a/lib/clixon/clixon_options.h b/lib/clixon/clixon_options.h index 4168b9ed..cefc0f6b 100644 --- a/lib/clixon/clixon_options.h +++ b/lib/clixon/clixon_options.h @@ -198,4 +198,8 @@ int clicon_xmldb_handle_set(clicon_handle h, void *xh); char *clicon_username_get(clicon_handle h); int clicon_username_set(clicon_handle h, void *username); +/* Set and get socket fd (ie backend server socket / restconf fcgx socket */ +int clicon_socket_get(clicon_handle h); +int clicon_socket_set(clicon_handle h, int s); + #endif /* _CLIXON_OPTIONS_H_ */ diff --git a/lib/src/clixon_handle.c b/lib/src/clixon_handle.c index 45a53ebe..2951de31 100644 --- a/lib/src/clixon_handle.c +++ b/lib/src/clixon_handle.c @@ -66,6 +66,17 @@ * @note If you change here, you must also change the structs below: * @see struct cli_handle * @see struct backend_handle + * This is the internal definition of a "Clixon handle" which in its external + * form is "clicon_handle" and is used in most Clixon API calls. + * Some details: + * 1) the internal structure contains a header (defined here) whereas higher + * order libs (eg cli and backend) introduce more fields appended to this + * struct. + * 2) ch_options accessed via clicon_data() are clixon config options are + * string values appearing in the XML configfile accessed with -f. + * Alternatively, these could be accessed via clicon_conf_xml() + * 3) ch_data accessed via clicon_data() is more general purpose for any data. + * that is, not only strings. And has separate namespace from options. */ struct clicon_handle { int ch_magic; /* magic (HDR) */ diff --git a/lib/src/clixon_hash.c b/lib/src/clixon_hash.c index 4769abfa..69f5fce2 100644 --- a/lib/src/clixon_hash.c +++ b/lib/src/clixon_hash.c @@ -202,7 +202,7 @@ hash_value(clicon_hash_t *hash, * * @param[in] hash Hash table * @param[in] key Variable name - * @param[in] val Variable value + * @param[in] val Variable value (pointer to) * @param[in] vlen Length of variable value * @retval variable New hash structure on success * @retval NULL Failure diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c index 4b412e20..88b2d8ae 100644 --- a/lib/src/clixon_json.c +++ b/lib/src/clixon_json.c @@ -224,7 +224,6 @@ json_str_escape_cdata(cbuf *cb, char *str) { int retval = -1; - char *snew = NULL; int i; int esc = 0; /* cdata escape */ @@ -261,12 +260,8 @@ json_str_escape_cdata(cbuf *cb, cprintf(cb, "%c", str[i]); break; } - if ((snew = strdup(cbuf_get(cb))) ==NULL){ - clicon_err(OE_XML, errno, "strdup"); - goto done; - } retval = 0; - done: + // done: return retval; } diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index 2ef5b7e6..24b5c309 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -32,7 +32,12 @@ ***** END LICENSE BLOCK ***** * - * CLICON options + * This file contains access functions for two types of clixon vars: + * - options, ie string based variables from Clixon configuration files. + * Accessed with clicon_options(h). + * - data. Free-typed values for runtime getting and setting. + * Accessed with clicon_data(h). + * Consider splitting? */ #ifdef HAVE_CONFIG_H #include "clixon_config.h" /* generated by config & autoconf */ @@ -359,6 +364,8 @@ clicon_option_str(clicon_handle h, * @param[in] h clicon_handle * @param[in] name option name * @param[in] val option value, must be null-terminated string + * @retval 0 OK + * @retval -1 Error */ int clicon_option_str_set(clicon_handle h, @@ -744,7 +751,7 @@ clicon_conf_xml(clicon_handle h) return NULL; } - /*! Set YANG specification for Clixon system options and features +/*! Set YANG specification for Clixon system options and features * ys must be a malloced pointer */ int @@ -883,3 +890,35 @@ clicon_username_set(clicon_handle h, } +/*! Get socket fd (ie backend server socket / restconf fcgx socket) + * @param[in] h Clicon handle + * @retval -1 No open socket + * @retval s Socket + */ +int +clicon_socket_get(clicon_handle h) +{ + clicon_hash_t *cdat = clicon_data(h); + void *p; + + if ((p = hash_value(cdat, "socket", NULL)) == NULL) + return -1; + return *(int*)p; +} + +/*! Set socket fd (ie backend server socket / restconf fcgx socket) + * @param[in] h Clicon handle + * @param[in] s Open socket (or -1 to close) + * @retval 0 OK + * @retval -1 Error + */ +int +clicon_socket_set(clicon_handle h, + int s) +{ + clicon_hash_t *cdat = clicon_data(h); + + if (s == -1) + return hash_del(cdat, "socket"); + return hash_add(cdat, "socket", &s, sizeof(int))==NULL?-1:0; +} diff --git a/test/README.md b/test/README.md index 1d147dd2..cb41e85f 100644 --- a/test/README.md +++ b/test/README.md @@ -57,7 +57,7 @@ These tests use valgrind to check for memory leaks: mem.sh cli mem.sh netconf mem.sh backend -# mem.sh restconf # NYI + mem.sh restconf ``` ## Site.sh diff --git a/test/lib.sh b/test/lib.sh index 8e3cd52f..d17f5891 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -52,8 +52,9 @@ testname= # : ${valgrindtest=0} -# Valgrind log file. This is usually removed automatically -: ${valgrindfile=$(mktemp)} +# Valgrind log file. This should be removed automatically. Note that mktemp +# actually creates a file so do not call it by default +#: ${valgrindfile=$(mktemp)} # If set to 0, override starting of clixon_backend in test (you bring your own) : ${BE:=1} @@ -135,9 +136,9 @@ start_backend(){ if [ $valgrindtest -eq 2 ]; then # Start in background since daemon version creates two traces: parent, # child. If background then only the single relevant. - sudo $clixon_backend -F $* -D $DBG & + sudo $clixon_backend -F -D $DBG $* & else - sudo $clixon_backend $* -D $DBG + sudo $clixon_backend -D $DBG $* fi if [ $? -ne 0 ]; then err @@ -155,6 +156,22 @@ stop_backend(){ fi } +start_restconf(){ + # Start in background + sudo su -c "$clixon_restconf $RCLOG -D $DBG $*" -s /bin/sh www-data & + if [ $? -ne 0 ]; then + err + fi +} + +stop_restconf(){ + sudo pkill -u www-data -f "/www-data/clixon_restconf" + if [ $valgrindtest -eq 3 ]; then + sleep 1 + checkvalgrind + fi +} + # Increment test number and print a nice string new(){ if [ $valgrindtest -eq 1 ]; then diff --git a/test/mem.sh b/test/mem.sh index 4c2e45f8..e570d96d 100755 --- a/test/mem.sh +++ b/test/mem.sh @@ -15,12 +15,12 @@ case "$PROGRAM" in 'cli') valgrindtest=1 RCWAIT=1 - clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli" + clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli" ;; 'netconf') valgrindtest=1 RCWAIT=1 - clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf" + clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf" ;; 'backend') valgrindtest=2 # This means backend valgrind test @@ -28,10 +28,19 @@ case "$PROGRAM" in perfnr=100 # test_perf.sh restconf put more or less stops perfreq=10 - clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./clixon.supp --track-fds=yes --trace-children=yes --log-file=$valgrindfile clixon_backend" + clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=yes --log-file=$valgrindfile clixon_backend" +;; + 'restconf') + valgrindtest=3 # This means backend valgrind test + sudo chmod 660 $valgrindfile + sudo chown www-data $valgrindfile + RCWAIT=5 # valgrind restconf needs some time to get up + clixon_restconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile /www-data/clixon_restconf" + ;; *) echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks + rm -f $valgrindfile exit -1 ;; esac diff --git a/test/test_choice.sh b/test/test_choice.sh index 37d05cc3..53d2a4ea 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -106,7 +106,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -sudo su -c "$clixon_restconf -f $RCLOG $cfg -y $fyang -D $DBG" -s /bin/sh www-data & +start_restconf -f $cfg -y $fyang new "waiting" sleep $RCWAIT @@ -194,7 +194,7 @@ new "netconf validate mandatory" expecteof "$clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" "^]]>]]>$" new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm.sh b/test/test_nacm.sh index 37a971cf..caba05e3 100755 --- a/test/test_nacm.sh +++ b/test/test_nacm.sh @@ -127,7 +127,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & +start_restconf -f $cfg -- -a new "waiting" sleep $RCWAIT @@ -178,7 +178,7 @@ new "guest edit nacm" expecteq "$(curl -u guest:bar -sS -X PUT -d '{"nacm-example:x": 3}' http://localhost/restconf/data/nacm-example:x)" 0 '{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "access denied"}}} ' new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh index ef3742f0..072d0049 100755 --- a/test/test_nacm_ext.sh +++ b/test/test_nacm_ext.sh @@ -146,7 +146,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon (-a is enable http basic auth)" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & +start_restconf -f $cfg -- -a new "waiting" sleep $RCWAIT @@ -207,7 +207,7 @@ new "cli rpc as guest" expectfn "$clixon_cli -1 -U guest -l o -f $cfg rpc ipv4" 255 "protocol access-denied access denied" new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh index 5624cb44..b18e3540 100755 --- a/test/test_nacm_module_read.sh +++ b/test/test_nacm_module_read.sh @@ -142,7 +142,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & +start_restconf -f $cfg -- -a new "waiting" sleep $RCWAIT @@ -272,7 +272,8 @@ expecteq "$(curl -u guest:bar -sS -X GET http://localhost/restconf/data/clixon-e new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf + if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_module_write.sh b/test/test_nacm_module_write.sh index 3462fd3f..53bf1da3 100755 --- a/test/test_nacm_module_write.sh +++ b/test/test_nacm_module_write.sh @@ -150,7 +150,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & +start_restconf -f $cfg -- -a new "waiting" sleep $RCWAIT @@ -254,7 +254,7 @@ new "default delete list deny" expecteq "$(curl -u wilma:bar -sS -X DELETE http://localhost/restconf/data/clixon-example:translate=key42)" 0 '{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "default deny"}}} ' new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh index a918511b..2a4487f0 100755 --- a/test/test_nacm_protocol.sh +++ b/test/test_nacm_protocol.sh @@ -150,7 +150,7 @@ sudo pkill -u www-data -f "/www-data/clixon_restconf" sleep 1 new "start restconf daemon (-a is enable basic authentication)" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG -- -a" -s /bin/sh www-data & +start_restconf -f $cfg -- -a new "waiting" sleep $RCWAIT @@ -216,7 +216,7 @@ new "permit-edit-config: guest fail restconf" expecteq "$(curl -u guest:bar -sS -X PUT -d '{"nacm-example:x": 2}' http://localhost/restconf/data/nacm-example:x)" 0 '{"ietf-restconf:errors" : {"error": {"error-type": "application","error-tag": "access-denied","error-severity": "error","error-message": "default deny"}}} ' new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_perf.sh b/test/test_perf.sh index 1bb88806..89985e0b 100755 --- a/test/test_perf.sh +++ b/test/test_perf.sh @@ -70,7 +70,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" -sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & +start_restconf -f $cfg -y $fyang new "waiting" sleep $RCWAIT @@ -169,7 +169,7 @@ new "netconf get large leaf-list config" expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg -y $fyang" 0 "]]>]]>" '^01' new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_restconf.sh b/test/test_restconf.sh index 43c5c96b..84ed9212 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -51,7 +51,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & +start_restconf -f $cfg new "waiting" sleep $RCWAIT @@ -265,7 +265,7 @@ if [ -z "$match" ]; then fi new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh index 54d1ae3a..e4e8de20 100755 --- a/test/test_restconf2.sh +++ b/test/test_restconf2.sh @@ -83,7 +83,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" -sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & +start_restconf -f $cfg -y $fyang new "waiting" sleep $RCWAIT @@ -182,7 +182,7 @@ new "restconf POST type x3" expectfn 'curl -s -X GET http://localhost/restconf/data/example:types' 0 '{"example:types": {"tint": 42,"tdec64": 42.123,"tbool": false,"tstr": "str"}}' new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_rpc.sh b/test/test_rpc.sh index af543edc..084c136e 100755 --- a/test/test_rpc.sh +++ b/test/test_rpc.sh @@ -48,7 +48,7 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & +start_restconf -f $cfg new "waiting" sleep $RCWAIT @@ -149,7 +149,7 @@ new "netconf edit-config missing config should fail" expecteof "$clixon_netconf -qf $cfg" 0 ']]>]]>' '^applicationdata-missingmissing-choiceedit-contenterror]]>]]>$' new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_stream.sh b/test/test_stream.sh index e9613887..e04a2041 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -118,7 +118,7 @@ new "kill old restconf daemon" sudo pkill -u www-data -f "/www-data/clixon_restconf" new "start restconf daemon" -sudo su -c "$clixon_restconf -f $cfg -y $fyang $RCLOG -D $DBG" -s /bin/sh www-data & +start_restconf -f $cfg -y $fyang new "waiting" sleep $RCWAIT @@ -274,7 +274,7 @@ echo "Eg: curl -H \"Accept: text/event-stream\" -s -X GET http://localhost/sub/E #----------------- sleep 5 new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh index d0f78a05..7e73b145 100755 --- a/test/test_yang_namespace.sh +++ b/test/test_yang_namespace.sh @@ -82,7 +82,10 @@ new "kill old restconf daemon" sudo pkill -u www-data clixon_restconf new "start restconf daemon" -sudo su -c "$clixon_restconf -f $cfg $RCLOG -D $DBG" -s /bin/sh www-data & +start_restconf -f $cfg + +new "waiting" +sleep $RCWAIT new "netconf set x in example1" expecteof "$clixon_netconf -qf $cfg" 0 '42]]>]]>' '^]]>]]>$' @@ -128,7 +131,7 @@ if [ -z "$match" ]; then fi new "Kill restconf daemon" -sudo pkill -u www-data -f "/www-data/clixon_restconf" +stop_restconf if [ $BE -eq 0 ]; then exit # BE diff --git a/test/clixon.supp b/test/valgrind-clixon.supp similarity index 65% rename from test/clixon.supp rename to test/valgrind-clixon.supp index c2201ab3..80d26160 100644 --- a/test/clixon.supp +++ b/test/valgrind-clixon.supp @@ -1,12 +1,12 @@ { - supp2 + supp1 Memcheck:Leak match-leak-kinds: reachable fun:* fun:_dl_new_object } { - supp3 + supp2 Memcheck:Leak match-leak-kinds: reachable fun:* @@ -14,16 +14,31 @@ fun:expand_dynamic_string_token } { - supp44 + supp3 Memcheck:Leak match-leak-kinds: reachable fun:* fun:_dlerror_run } { - supp5 + supp4 Memcheck:Leak match-leak-kinds: reachable fun:* fun:_dl_check_map_versions } +{ + supp5 + Memcheck:Leak + match-leak-kinds: reachable + fun:* + fun:* + fun:_dl_map_object +} +{ + supp6-fcgi + Memcheck:Leak + match-leak-kinds: reachable + fun:* + fun:OS_LibInit +}