diff --git a/test/test_c++.sh b/test/test_c++.sh index edb43d22..8f6fa256 100755 --- a/test/test_c++.sh +++ b/test/test_c++.sh @@ -6,6 +6,28 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi cfile=$dir/c++.cpp +APPNAME=example +cfg=$dir/conf.xml + +test -d $dir/backend || mkdir $dir/backend + +cat < $cfg + + $cfg + /usr/local/share/clixon + $IETFRFC + clixon-example + $dir/backend + /usr/local/lib/$APPNAME/clispec + /usr/local/lib/$APPNAME/cli + $APPNAME + false + /usr/local/var/$APPNAME/$APPNAME.sock + /usr/local/var/$APPNAME/$APPNAME.pidfile + /usr/local/var/$APPNAME + +EOF + cat< $cfile #include #include @@ -64,7 +86,7 @@ static netconf_test api(clixon_plugin_init, plugin_start, plugin_exit); /*! Local example netconf rpc callback */ -int netconf_client_rpc(clicon_handle h, +int example_rpc(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg, @@ -107,7 +129,7 @@ clixon_plugin_api* clixon_plugin_init(clicon_handle h) { clicon_debug(1, "%s netconf", __FUNCTION__); /* Register local netconf rpc client (note not backend rpc client) */ - if (rpc_callback_register(h, netconf_client_rpc, NULL, "urn:example:clixon", "client-rpc") < 0) + if (rpc_callback_register(h, example_rpc, NULL, "urn:example:clixon", "example") < 0) return NULL; return api.get_api(); @@ -116,8 +138,35 @@ clixon_plugin_api* clixon_plugin_init(clicon_handle h) EOF new "C++ compile" -expectpart "$($CXX -g -Wall -rdynamic -fPIC -shared $cfile -o c++.o)" 0 "" +expectpart "$($CXX -g -Wall -rdynamic -fPIC -shared $cfile -o $dir/backend/c++.so)" 0 "" + +new "test params: -f $cfg" +if [ $BE -ne 0 ]; then + new "kill old backend" + sudo clixon_backend -zf $cfg + if [ $? -ne 0 ]; then + err + fi + new "start backend -s init -f $cfg" + start_backend -s init -f $cfg +fi + +new "wait backend" +wait_backend + +new "Netconf runtime test" +expecteof "$clixon_netconf -qf $cfg" 0 '0]]>]]>' '^042]]>]]>$' + +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg +fi -rm -f c++.o rm -rf $dir