@@ -108,8 +108,6 @@ static void
108108test_lock_fail (void * * state )
109109{
110110 struct np2_test * st = * state ;
111- const char * template ;
112- char * error ;
113111
114112 /* Lock from first session */
115113 st -> rpc = nc_rpc_lock (NC_DATASTORE_RUNNING );
@@ -123,81 +121,9 @@ test_lock_fail(void **state)
123121 st -> rpc = nc_rpc_lock (NC_DATASTORE_RUNNING );
124122 st -> msgtype = nc_send_rpc (st -> nc_sess2 , st -> rpc , 1000 , & st -> msgid );
125123 assert_int_equal (st -> msgtype , NC_MSG_RPC );
126- ASSERT_ERROR_REPLY_SESS2 (st );
127-
128- /* Check error message */
129- assert_int_equal (LY_SUCCESS , lyd_print_mem (& st -> str , st -> envp , LYD_XML , 0 ));
130- template =
131- "<rpc-reply "
132- "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "
133- "message-id=\"%" PRIu64 "\">\n"
134- " <rpc-error>\n"
135- " <error-type>protocol</error-type>\n"
136- " <error-tag>lock-denied</error-tag>\n"
137- " <error-severity>error</error-severity>\n"
138- " <error-message xml:lang=\"en\">Access to the requested lock is denied"
139- " because the lock is currently held by another entity.</error-message>\n"
140- " <error-info>\n"
141- " <session-id>%" PRIu32 "</session-id>\n"
142- " </error-info>\n"
143- " </rpc-error>\n"
144- "</rpc-reply>\n" ;
145- assert_int_not_equal (-1 , asprintf (& error , template , st -> msgid , nc_session_get_id (st -> nc_sess )));
146- assert_string_equal (st -> str , error );
147-
148- free (error );
149- FREE_TEST_VARS (st );
150- }
151-
152- static int
153- setup_test_lock_changes (void * * state )
154- {
155- struct np2_test * st = * state ;
124+ st -> msgtype = nc_recv_reply (st -> nc_sess2 , st -> rpc , st -> msgid , 100 , & st -> envp , & st -> op );
125+ assert_int_equal (st -> msgtype , NC_MSG_WOULDBLOCK );
156126
157- st -> rpc = nc_rpc_lock (NC_DATASTORE_RUNNING );
158- assert_non_null (st -> rpc );
159- st -> msgtype = nc_send_rpc (st -> nc_sess , st -> rpc , 1000 , & st -> msgid );
160- assert_int_equal (st -> msgtype , NC_MSG_RPC );
161- ASSERT_OK_REPLY (st );
162- FREE_TEST_VARS (st );
163- return 0 ;
164- }
165-
166- static int
167- teardown_test_lock_changes (void * * state )
168- {
169- struct np2_test * st = * state ;
170- const char * data =
171- "<first xmlns=\"ed1\" xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xc:operation=\"remove\"/>" ;
172-
173- SEND_EDIT_RPC (st , data );
174- ASSERT_OK_REPLY (st );
175- FREE_TEST_VARS (st );
176-
177- st -> rpc = nc_rpc_unlock (NC_DATASTORE_RUNNING );
178- st -> msgtype = nc_send_rpc (st -> nc_sess , st -> rpc , 1000 , & st -> msgid );
179- assert_int_equal (st -> msgtype , NC_MSG_RPC );
180- ASSERT_OK_REPLY (st );
181- FREE_TEST_VARS (st );
182- return 0 ;
183- }
184-
185- static void
186- test_lock_changes (void * * state )
187- {
188- struct np2_test * st = * state ;
189-
190- /* Send RPC editing module edit1 on the same session, should succeed */
191- SEND_EDIT_RPC (st , "<first xmlns=\"ed1\">TestFirst</first>" );
192- ASSERT_OK_REPLY (st );
193- FREE_TEST_VARS (st );
194-
195- /* Send RPC editing module edit1 on another session, should fail */
196- st -> rpc = nc_rpc_edit (NC_DATASTORE_RUNNING , NC_RPC_EDIT_DFLTOP_MERGE , NC_RPC_EDIT_TESTOPT_SET ,
197- NC_RPC_EDIT_ERROPT_ROLLBACK , "<first xmlns=\"ed1\">TestFirst</first>" , NC_PARAMTYPE_CONST );
198- st -> msgtype = nc_send_rpc (st -> nc_sess2 , st -> rpc , 1000 , & st -> msgid );
199- assert_int_equal (NC_MSG_RPC , st -> msgtype );
200- ASSERT_ERROR_REPLY_SESS2 (st );
201127 FREE_TEST_VARS (st );
202128}
203129
@@ -244,35 +170,14 @@ static void
244170test_unlock_fail (void * * state )
245171{
246172 struct np2_test * st = * state ;
247- const char * template ;
248- char * error ;
249173
250174 /* Try unlocking a lock by a different session, should fail */
251175 st -> rpc = nc_rpc_unlock (NC_DATASTORE_RUNNING );
252176 st -> msgtype = nc_send_rpc (st -> nc_sess2 , st -> rpc , 1000 , & st -> msgid );
253177 assert_int_equal (st -> msgtype , NC_MSG_RPC );
178+ st -> msgtype = nc_recv_reply (st -> nc_sess2 , st -> rpc , st -> msgid , 100 , & st -> envp , & st -> op );
179+ assert_int_equal (st -> msgtype , NC_MSG_WOULDBLOCK );
254180
255- /* Check error message */
256- ASSERT_ERROR_REPLY_SESS2 (st );
257- assert_int_equal (LY_SUCCESS , lyd_print_mem (& st -> str , st -> envp , LYD_XML , 0 ));
258- template =
259- "<rpc-reply "
260- "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" "
261- "message-id=\"%" PRIu64 "\">\n"
262- " <rpc-error>\n"
263- " <error-type>protocol</error-type>\n"
264- " <error-tag>lock-denied</error-tag>\n"
265- " <error-severity>error</error-severity>\n"
266- " <error-message xml:lang=\"en\">Access to the requested lock is denied"
267- " because the lock is currently held by another entity.</error-message>\n"
268- " <error-info>\n"
269- " <session-id>%" PRIu32 "</session-id>\n"
270- " </error-info>\n"
271- " </rpc-error>\n"
272- "</rpc-reply>\n" ;
273- assert_int_not_equal (-1 , asprintf (& error , template , st -> msgid , nc_session_get_id (st -> nc_sess )));
274- assert_string_equal (st -> str , error );
275- free (error );
276181 FREE_TEST_VARS (st );
277182}
278183
@@ -434,7 +339,6 @@ main(int argc, char **argv)
434339 const struct CMUnitTest tests [] = {
435340 cmocka_unit_test_teardown (test_lock_basic , teardown_test_lock ),
436341 cmocka_unit_test_teardown (test_lock_fail , teardown_test_lock ),
437- cmocka_unit_test_setup_teardown (test_lock_changes , setup_test_lock_changes , teardown_test_lock_changes ),
438342 cmocka_unit_test_setup (test_unlock , setup_test_unlock ),
439343 cmocka_unit_test_setup_teardown (test_unlock_fail , setup_test_unlock , teardown_test_unlock_fail ),
440344 cmocka_unit_test (test_get ),
0 commit comments