static void test_nc_rpc_lock(void **state) { (void)state; struct nc_rpc *rpc = NULL; struct nc_rpc_lock *lock_rpc = NULL; rpc = nc_rpc_lock(NC_DATASTORE_RUNNING); assert_non_null(rpc); assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_LOCK); lock_rpc = (struct nc_rpc_lock *)rpc; assert_int_equal(lock_rpc->type, NC_RPC_LOCK); assert_int_equal(lock_rpc->target, NC_DATASTORE_RUNNING); nc_rpc_free(rpc); }
static int setup_write(void **state) { (void) state; /* unused */ int fd; struct wr *w; w = malloc(sizeof *w); w->session = calloc(1, sizeof *w->session); w->session->ctx = ly_ctx_new(TESTS_DIR"../schemas"); w->session->ti_lock = malloc(sizeof *w->session->ti_lock); pthread_mutex_init(w->session->ti_lock, NULL); /* ietf-netconf */ fd = open(TESTS_DIR"../schemas/ietf-netconf.yin", O_RDONLY); if (fd == -1) { free(w); return -1; } lys_parse_fd(w->session->ctx, fd, LYS_IN_YIN); close(fd); w->session->status = NC_STATUS_RUNNING; w->session->version = NC_VERSION_10; w->session->msgid = 999; w->session->ti_type = NC_TI_FD; w->session->ti.fd.in = STDIN_FILENO; w->session->ti.fd.out = STDOUT_FILENO; /* get rpc to write */ w->rpc = nc_rpc_lock(NC_DATASTORE_RUNNING); assert_non_null(w->rpc); w->session->ti.fd.in = -1; *state = w; return 0; }