Merging upstream version 3.5.5 (Closes: #1098233).
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c86ae7dcba
commit
6af28b7e8e
144 changed files with 43534 additions and 11497 deletions
|
@ -13,6 +13,8 @@
|
|||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -23,17 +25,8 @@
|
|||
|
||||
#include <libyang/libyang.h>
|
||||
|
||||
#include <log.h>
|
||||
#include <messages_p.h>
|
||||
#include <messages_server.h>
|
||||
#include <session_client.h>
|
||||
#include <session_server.h>
|
||||
#include "tests/config.h"
|
||||
#include "ln2_test.h"
|
||||
|
||||
/* millisec */
|
||||
#define NC_ACCEPT_TIMEOUT 5000
|
||||
/* millisec */
|
||||
#define NC_PS_POLL_TIMEOUT 5000
|
||||
/* sec */
|
||||
#define CLIENT_SSH_AUTH_TIMEOUT 10
|
||||
|
||||
|
@ -71,8 +64,8 @@ server_thread(void *arg)
|
|||
const char *data;
|
||||
int poll;
|
||||
|
||||
nc_assert(!nc_server_init(args.ctx));
|
||||
nc_assert(nc_accept_inout(args.in, args.out, "test", &sess) == NC_MSG_HELLO);
|
||||
nc_assert(!nc_server_init());
|
||||
nc_assert(nc_accept_inout(args.in, args.out, "test", args.ctx, &sess) == NC_MSG_HELLO);
|
||||
nc_session_inc_notif_status(sess);
|
||||
data =
|
||||
"<n1 xmlns=\"n1\">\n"
|
||||
|
@ -90,9 +83,15 @@ server_thread(void *arg)
|
|||
ps = nc_ps_new();
|
||||
nc_assert(ps);
|
||||
nc_ps_add_session(ps, sess);
|
||||
|
||||
/* get for ietf-yang-library data; delete-config in test */
|
||||
poll = nc_ps_poll(ps, 1000, &sess);
|
||||
nc_server_notif_send(sess, notif, 1000);
|
||||
nc_assert(poll == NC_PSPOLL_RPC);
|
||||
poll = nc_ps_poll(ps, 1000, &sess);
|
||||
nc_assert(poll == NC_PSPOLL_RPC);
|
||||
|
||||
nc_server_notif_send(sess, notif, 1000);
|
||||
|
||||
nc_ps_clear(ps, 1, NULL);
|
||||
nc_ps_free(ps);
|
||||
|
||||
|
@ -128,7 +127,7 @@ main(void)
|
|||
int pipes[4];
|
||||
struct nc_session *sess;
|
||||
struct lyd_node *op, *envp;
|
||||
struct ly_ctx *ctx;
|
||||
struct ly_ctx *server_ctx, *client_ctx;
|
||||
struct nc_rpc *rpc;
|
||||
uint64_t msgid;
|
||||
NC_MSG_TYPE msgtype;
|
||||
|
@ -145,19 +144,23 @@ main(void)
|
|||
thread_arg.in = pipes[0];
|
||||
thread_arg.out = pipes[3];
|
||||
|
||||
/* Create context */
|
||||
nc_assert(ly_ctx_new(TESTS_DIR "/data/modules", 0, &ctx) == LY_SUCCESS);
|
||||
nc_assert(ly_ctx_load_module(ctx, "ietf-netconf", NULL, features));
|
||||
nc_assert(ly_ctx_load_module(ctx, "notif1", NULL, NULL));
|
||||
thread_arg.ctx = ctx;
|
||||
/* Create both contexts */
|
||||
nc_assert(ly_ctx_new(TESTS_DIR "/data/modules", 0, &server_ctx) == LY_SUCCESS);
|
||||
nc_assert(ly_ctx_load_module(server_ctx, "ietf-netconf", NULL, features));
|
||||
nc_assert(ly_ctx_load_module(server_ctx, "notif1", NULL, NULL));
|
||||
thread_arg.ctx = server_ctx;
|
||||
nc_set_global_rpc_clb(rpc_clb);
|
||||
|
||||
nc_assert(ly_ctx_new(TESTS_DIR "/data/modules", 0, &client_ctx) == LY_SUCCESS);
|
||||
nc_assert(ly_ctx_load_module(client_ctx, "ietf-netconf", NULL, features));
|
||||
nc_assert(ly_ctx_load_module(client_ctx, "notif1", NULL, NULL));
|
||||
|
||||
/* Start server thread */
|
||||
pthread_create(&t[0], NULL, server_thread, &thread_arg);
|
||||
nc_client_init();
|
||||
|
||||
/* Listen for notifications */
|
||||
sess = nc_connect_inout(pipes[2], pipes[1], ctx);
|
||||
sess = nc_connect_inout(pipes[2], pipes[1], client_ctx);
|
||||
nc_assert(sess);
|
||||
pthread_create(&t[1], NULL, notif_thread, sess);
|
||||
|
||||
|
@ -181,7 +184,8 @@ main(void)
|
|||
|
||||
/* Cleanup */
|
||||
nc_session_free(sess, NULL);
|
||||
ly_ctx_destroy(ctx);
|
||||
ly_ctx_destroy(server_ctx);
|
||||
ly_ctx_destroy(client_ctx);
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
close(pipes[i]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue