File: test_context_change.c

package info (click to toggle)
sysrepo 4.5.1-1
  • links: PTS
  • area: main
  • in suites: experimental
  • size: 6,824 kB
  • sloc: ansic: 86,774; sh: 145; makefile: 29
file content (634 lines) | stat: -rw-r--r-- 17,920 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/**
 * @file test_context_change.c
 * @author Michal Vasko <mvasko@cesnet.cz>
 * @brief test for runtime context changes
 *
 * @copyright
 * Copyright (c) 2018 - 2025 Deutsche Telekom AG.
 * Copyright (c) 2018 - 2025 CESNET, z.s.p.o.
 *
 * This source code is licensed under BSD 3-Clause License (the "License").
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://opensource.org/licenses/BSD-3-Clause
 */

#define _GNU_SOURCE

#include <poll.h>
#include <pthread.h>
#include <sched.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

#include <cmocka.h>
#include <libyang/libyang.h>

#include "common.h"
#include "sysrepo.h"
#include "tests/tcommon.h"

struct state {
    sr_conn_ctx_t *conn;
    ATOMIC_T cb_called;
    pthread_barrier_t barrier;
};

static int
setup(void **state)
{
    struct state *st;
    const char *schema_paths[] = {
        TESTS_SRC_DIR "/files/mod1.yang",
        TESTS_SRC_DIR "/files/mod3.yang",
        NULL
    };
    const char *mod1_features[] = {"f1", NULL};
    const char *mod3_features[] = {"f1", NULL};
    const char **features[] = {
        mod1_features,
        mod3_features,
    };

    st = calloc(1, sizeof *st);
    *state = st;

    if (sr_connect(0, &(st->conn)) != SR_ERR_OK) {
        return 1;
    }

    if (sr_install_modules(st->conn, schema_paths, TESTS_SRC_DIR "/files", features) != SR_ERR_OK) {
        return 1;
    }

    return 0;
}

static int
teardown(void **state)
{
    struct state *st = (struct state *)*state;
    const char *module_names[] = {
        "mod1",
        NULL
    };

    sr_remove_modules(st->conn, module_names, 0);

    sr_disconnect(st->conn);
    free(st);
    return 0;
}

static int
setup_f(void **state)
{
    struct state *st = (struct state *)*state;

    ATOMIC_STORE_RELAXED(st->cb_called, 0);
    pthread_barrier_init(&st->barrier, NULL, 2);
    return 0;
}

static int
teardown_f(void **state)
{
    struct state *st = (struct state *)*state;

    pthread_barrier_destroy(&st->barrier);
    return 0;
}

/* TEST */
static int
module_change_st_called_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *xpath,
        sr_event_t event, uint32_t request_id, void *private_data)
{
    struct state *st = (struct state *)private_data;

    (void)session;
    (void)sub_id;
    (void)module_name;
    (void)xpath;
    (void)event;
    (void)request_id;

    ATOMIC_INC_RELAXED(st->cb_called);
    return SR_ERR_OK;
}

static int
oper_deviation_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *module_name, const char *path,
        const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data)
{
    struct state *st = (struct state *)private_data;

    (void)session;
    (void)sub_id;
    (void)module_name;
    (void)path;
    (void)request_xpath;
    (void)request_id;
    (void)parent;

    ATOMIC_INC_RELAXED(st->cb_called);
    return SR_ERR_OK;
}

static void *
context_change_deviation_thread(void *arg)
{
    struct state *st = (struct state *)arg;
    int ret;

    /* wait until subscriptions are created */

    /* sync #1 */
    pthread_barrier_wait(&st->barrier);

    /* try to install new module, should fail */
    ret = sr_install_module(st->conn, TESTS_SRC_DIR "/files/mod2.yang", TESTS_SRC_DIR "/files", NULL);
    assert_int_equal(ret, SR_ERR_OPERATION_FAILED);

    /* sync #2 */
    pthread_barrier_wait(&st->barrier);

    /* try to install the module again, should still fail */
    ret = sr_install_module(st->conn, TESTS_SRC_DIR "/files/mod2.yang", TESTS_SRC_DIR "/files", NULL);
    assert_int_equal(ret, SR_ERR_OPERATION_FAILED);

    /* sync #3 */
    pthread_barrier_wait(&st->barrier);

    /* sync #4 */
    pthread_barrier_wait(&st->barrier);

    /* try to install the module, succeeds */
    ret = sr_install_module(st->conn, TESTS_SRC_DIR "/files/mod2.yang", TESTS_SRC_DIR "/files", NULL);
    assert_int_equal(ret, SR_ERR_OK);

    /* remove the module */
    ret = sr_remove_module(st->conn, "mod2", 0);
    assert_int_equal(ret, SR_ERR_OK);

    /* sync #5 */
    pthread_barrier_wait(&st->barrier);

    return NULL;
}

static void *
subscribe_deviation_thread(void *arg)
{
    struct state *st = (struct state *)arg;
    sr_session_ctx_t *sess;
    sr_subscription_ctx_t *subscr = NULL;
    sr_data_t *data;
    int ret;
    uint32_t sub_id1, sub_id2;

    ret = sr_session_start(st->conn, SR_DS_RUNNING, &sess);
    assert_int_equal(ret, SR_ERR_OK);

    /* subscribe to 2 leaves, one oper sub */
    ret = sr_module_change_subscribe(sess, "mod1", "/mod1:cont/l1", module_change_st_called_cb, st, 0, 0, &subscr);
    assert_int_equal(ret, SR_ERR_OK);
    sub_id1 = sr_subscription_get_last_sub_id(subscr);
    ret = sr_oper_get_subscribe(sess, "mod1", "/mod1:cont/l1", oper_deviation_cb, st, 0, &subscr);
    assert_int_equal(ret, SR_ERR_OK);
    sub_id2 = sr_subscription_get_last_sub_id(subscr);
    ret = sr_module_change_subscribe(sess, "mod1", "/mod1:cont/l3", module_change_st_called_cb, st, 0, 0, &subscr);
    assert_int_equal(ret, SR_ERR_OK);

    /* sync #1 */
    pthread_barrier_wait(&st->barrier);

    /* do arbitrary changes */
    ret = sr_set_item_str(sess, "/mod1:cont/l1", "val1", NULL, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_set_item_str(sess, "/mod1:cont/l3", "val1", NULL, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);

    /* get oper data */
    sr_session_switch_ds(sess, SR_DS_OPERATIONAL);
    ret = sr_get_data(sess, "/mod1:cont/l1", 0, 0, 0, &data);
    assert_int_equal(ret, SR_ERR_OK);
    sr_release_data(data);
    assert_int_equal(st->cb_called, 5);

    /* sync #2 */
    pthread_barrier_wait(&st->barrier);

    /* unsubscribe the first subscription */
    ret = sr_unsubscribe_sub(subscr, sub_id1);
    assert_int_equal(ret, SR_ERR_OK);

    /* sync #3 */
    pthread_barrier_wait(&st->barrier);

    /* unsubscribe the second subscription */
    ret = sr_unsubscribe_sub(subscr, sub_id2);
    assert_int_equal(ret, SR_ERR_OK);

    /* sync #4 */
    pthread_barrier_wait(&st->barrier);

    /* do some more changes on the second subscription  */
    sr_session_switch_ds(sess, SR_DS_RUNNING);
    ret = sr_set_item_str(sess, "/mod1:cont/l3", "val2", NULL, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_set_item_str(sess, "/mod1:cont/l3", "val3", NULL, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);
    assert_int_equal(st->cb_called, 9);

    /* sync #5 */
    pthread_barrier_wait(&st->barrier);

    /* cleanup */
    ret = sr_unsubscribe(subscr);
    assert_int_equal(ret, SR_ERR_OK);

    ret = sr_delete_item(sess, "/mod1:cont", 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);

    sr_session_stop(sess);
    return NULL;
}

static void
test_deviation(void **state)
{
    pthread_t tid[2];

    pthread_create(&tid[0], NULL, context_change_deviation_thread, *state);
    pthread_create(&tid[1], NULL, subscribe_deviation_thread, *state);

    pthread_join(tid[0], NULL);
    pthread_join(tid[1], NULL);
}

/* TEST */
static int
rpc_feature_change_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *op_path, const struct lyd_node *input,
        sr_event_t event, uint32_t request_id, struct lyd_node *output, void *private_data)
{
    struct state *st = (struct state *)private_data;

    (void)session;
    (void)sub_id;
    (void)op_path;
    (void)input;
    (void)event;
    (void)request_id;
    (void)output;

    ATOMIC_INC_RELAXED(st->cb_called);
    return SR_ERR_OK;
}

static void
notif_feature_change_cb(sr_session_ctx_t *session, uint32_t sub_id, const sr_ev_notif_type_t notif_type,
        const struct lyd_node *notif, struct timespec *timestamp, void *private_data)
{
    struct state *st = (struct state *)private_data;

    (void)session;
    (void)sub_id;
    (void)notif_type;
    (void)notif;
    (void)timestamp;

    ATOMIC_INC_RELAXED(st->cb_called);
}

static void *
context_change_feature_change_thread(void *arg)
{
    struct state *st = (struct state *)arg;
    int ret;

    /* wait until subscriptions are created */

    /* sync #1 */
    pthread_barrier_wait(&st->barrier);

    /* try to enable f2, should fail */
    ret = sr_enable_module_feature(st->conn, "mod1", "f2");
    assert_int_equal(ret, SR_ERR_OPERATION_FAILED);

    /* try to disable f1, should fail */
    ret = sr_disable_module_feature(st->conn, "mod1", "f1");
    assert_int_equal(ret, SR_ERR_OPERATION_FAILED);

    /* sync #2 */
    pthread_barrier_wait(&st->barrier);

    /* sync #3 */
    pthread_barrier_wait(&st->barrier);

    /* try to disable f1, should still fail */
    ret = sr_disable_module_feature(st->conn, "mod1", "f1");
    assert_int_equal(ret, SR_ERR_OPERATION_FAILED);

    /* sync #4 */
    pthread_barrier_wait(&st->barrier);

    /* sync #5 */
    pthread_barrier_wait(&st->barrier);

    /* try to disable f1, succeeds */
    ret = sr_disable_module_feature(st->conn, "mod1", "f1");
    assert_int_equal(ret, SR_ERR_OK);

    /* sync #6 */
    pthread_barrier_wait(&st->barrier);

    /* enable f1 back */
    ret = sr_enable_module_feature(st->conn, "mod1", "f1");
    assert_int_equal(ret, SR_ERR_OK);

    return NULL;
}

static void *
subscribe_feature_change_thread(void *arg)
{
    struct state *st = (struct state *)arg;
    sr_session_ctx_t *sess;
    sr_subscription_ctx_t *subscr = NULL;
    sr_data_t *data;
    const struct ly_ctx *ly_ctx;
    struct lyd_node *ly_notif, *ly_action;
    int ret;
    uint32_t sub_id1, sub_id2;

    ret = sr_session_start(st->conn, SR_DS_RUNNING, &sess);
    assert_int_equal(ret, SR_ERR_OK);

    /* subscribe to 2 leaves, action, and notif */
    ret = sr_module_change_subscribe(sess, "mod1", "/mod1:cont/l2", module_change_st_called_cb, st, 0, 0, &subscr);
    assert_int_equal(ret, SR_ERR_OK);
    sub_id1 = sr_subscription_get_last_sub_id(subscr);
    ret = sr_module_change_subscribe(sess, "mod1", "/mod1:cont/l3", module_change_st_called_cb, st, 0, 0, &subscr);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_rpc_subscribe_tree(sess, "/mod1:cont/a", rpc_feature_change_cb, st, 0, 0, &subscr);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_notif_subscribe_tree(sess, "mod1", "/mod1:cont/n/l5 = 5", NULL, NULL, notif_feature_change_cb, st,
            0, &subscr);
    assert_int_equal(ret, SR_ERR_OK);
    sub_id2 = sr_subscription_get_last_sub_id(subscr);

    /* sync #1 */
    pthread_barrier_wait(&st->barrier);

    /* sync #2 */
    pthread_barrier_wait(&st->barrier);

    /* unsubscribe the first subscription */
    ret = sr_unsubscribe_sub(subscr, sub_id1);
    assert_int_equal(ret, SR_ERR_OK);

    /* sync #3 */
    pthread_barrier_wait(&st->barrier);

    /* sync #4 */
    pthread_barrier_wait(&st->barrier);

    /* send notif */
    ly_ctx = sr_acquire_context(st->conn);
    assert_int_equal(LY_SUCCESS, lyd_new_path(NULL, ly_ctx, "/mod1:cont/n/l5", "5", 0, &ly_notif));
    ret = sr_notif_send_tree(sess, ly_notif, 0, 1);
    lyd_free_tree(ly_notif);
    sr_release_context(st->conn);
    assert_int_equal(ret, SR_ERR_OK);
    assert_int_equal(st->cb_called, 1);

    /* unsubscribe the second subscription */
    ret = sr_unsubscribe_sub(subscr, sub_id2);
    assert_int_equal(ret, SR_ERR_OK);

    /* sync #5 */
    pthread_barrier_wait(&st->barrier);

    /* do some changes in the data */
    ret = sr_set_item_str(sess, "/mod1:cont/l3", "val1", NULL, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);
    assert_int_equal(st->cb_called, 4);

    /* send action */
    ly_ctx = sr_acquire_context(st->conn);
    assert_int_equal(LY_SUCCESS, lyd_new_path(NULL, ly_ctx, "/mod1:cont/a/l4", "50", 0, &ly_action));
    ret = sr_rpc_send_tree(sess, ly_action, 0, &data);
    lyd_free_tree(ly_action);
    sr_release_context(st->conn);
    sr_release_data(data);
    assert_int_equal(ret, SR_ERR_OK);
    assert_int_equal(st->cb_called, 5);

    /* sync #6 */
    pthread_barrier_wait(&st->barrier);

    /* cleanup */
    ret = sr_unsubscribe(subscr);
    assert_int_equal(ret, SR_ERR_OK);

    ret = sr_delete_item(sess, "/mod1:cont", 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);

    sr_session_stop(sess);
    return NULL;
}

static void
test_feature_change(void **state)
{
    pthread_t tid[2];

    pthread_create(&tid[0], NULL, context_change_feature_change_thread, *state);
    pthread_create(&tid[1], NULL, subscribe_feature_change_thread, *state);

    pthread_join(tid[0], NULL);
    pthread_join(tid[1], NULL);
}

/* TEST */
static void
test_push_oper(void **state)
{
    struct state *st = (struct state *)*state;
    sr_session_ctx_t *sess;
    sr_data_t *data;
    struct lyd_node *edit;
    char *str;
    int ret;

    ret = sr_session_start(st->conn, SR_DS_OPERATIONAL, &sess);
    assert_int_equal(ret, SR_ERR_OK);

    /* create l1 and l2 leaf in push oper data */
    ret = sr_set_item_str(sess, "/mod1:cont/l1", "val", NULL, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_set_item_str(sess, "/mod1:cont/l2", "val2", NULL, 0);
    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);

    /* read the data back */
    ret = sr_get_data(sess, "/mod1:*", 0, 0, 0, &data);
    assert_int_equal(ret, SR_ERR_OK);
    lyd_print_mem(&str, data->tree, LYD_XML, LYD_PRINT_SIBLINGS | LYD_PRINT_SHRINK);
    sr_release_data(data);

    assert_string_equal(str,
            "<cont xmlns=\"urn:mod1\">"
            "<l1>val</l1>"
            "<l2>val2</l2>"
            "</cont>");
    free(str);

    /* disable f1 */
    ret = sr_disable_module_feature(st->conn, "mod1", "f1");
    assert_int_equal(ret, SR_ERR_OK);

    /* check push oper data now, l2 leaf was disabled */
    ret = sr_get_data(sess, "/mod1:*", 0, 0, 0, &data);
    assert_int_equal(ret, SR_ERR_OK);
    lyd_print_mem(&str, data->tree, LYD_XML, LYD_PRINT_SIBLINGS | LYD_PRINT_SHRINK);
    sr_release_data(data);

    assert_string_equal(str,
            "<cont xmlns=\"urn:mod1\">"
            "<l1>val</l1>"
            "<l2>val2</l2>"
            "</cont>");
    free(str);

    /* remove the node manually */
    str = "<cont xmlns=\"urn:mod1\">"
            "<l1>val</l1>"
            "</cont>";
    ret = lyd_parse_data_mem(sr_acquire_context(st->conn), str, LYD_XML, LYD_PARSE_ONLY, 0, &edit);
    sr_release_context(st->conn);
    assert_int_equal(ret, LY_SUCCESS);
    ret = sr_edit_batch(sess, edit, "replace");
    lyd_free_siblings(edit);

    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);

    ret = sr_get_data(sess, "/mod1:*", 0, 0, 0, &data);
    assert_int_equal(ret, SR_ERR_OK);
    lyd_print_mem(&str, data->tree, LYD_XML, LYD_PRINT_SIBLINGS | LYD_PRINT_SHRINK);
    sr_release_data(data);

    assert_string_equal(str,
            "<cont xmlns=\"urn:mod1\">"
            "<l1>val</l1>"
            "</cont>");
    free(str);

    /* enable f1 back */
    ret = sr_enable_module_feature(st->conn, "mod1", "f1");
    assert_int_equal(ret, SR_ERR_OK);

}

/* TEST */
static void
test_context_change_no_diff(void **state)
{
    struct state *st = (struct state *)*state;
    sr_session_ctx_t *sess;
    sr_data_t *data;
    int ret;
    char *str1 = NULL;
    const char *str2 = "<cont xmlns=\"urn:mod3\">\n"
            "  <l1>imback</l1>\n"
            "</cont>\n";
    const struct ly_ctx *ctx = NULL;
    const struct lys_module *mod = NULL;
    LY_ERR lerr;

    ret = sr_session_start(st->conn, SR_DS_RUNNING, &sess);
    assert_int_equal(ret, SR_ERR_OK);

    ctx = sr_acquire_context(st->conn);

    mod = ly_ctx_get_module_implemented(ctx, "mod3");
    assert_int_not_equal(mod, NULL);

    sr_release_context(st->conn);

    lerr = lys_feature_value(mod, "f1");
    if (lerr == LY_SUCCESS) {
        /* disable feature */
        ret = sr_disable_module_feature(st->conn, "mod3", "f1");
        assert_int_equal(ret, SR_ERR_OK);
    }

    /* fails, feature is disabled */
    ret = sr_set_item_str(sess, "/mod3:cont/l2", "val1", NULL, 0);
    assert_int_equal(ret, SR_ERR_LY);

    /* enable feature (change context on default data) */
    ret = sr_enable_module_feature(st->conn, "mod3", "f1");
    assert_int_equal(ret, SR_ERR_OK);

    /* store some data */
    ret = sr_set_item_str(sess, "/mod3:cont/l2", "val1", NULL, 0);

    assert_int_equal(ret, SR_ERR_OK);
    ret = sr_apply_changes(sess, 0);
    assert_int_equal(ret, SR_ERR_OK);

    /* disable feature (change context on some data) */
    ret = sr_disable_module_feature(st->conn, "mod3", "f1");
    assert_int_equal(ret, SR_ERR_OK);

    /* check if data is correct */
    ret = sr_get_data(sess, "/mod3:*", 0, 0, 0, &data);
    assert_int_equal(ret, SR_ERR_OK);

    ret = lyd_print_mem(&str1, data->tree, LYD_XML, LYD_PRINT_WD_ALL);
    assert_int_equal(ret, LY_SUCCESS);
    sr_release_data(data);

    /* compare */
    assert_string_equal(str1, str2);
    free(str1);
}

/* MAIN */
int
main(void)
{
    const struct CMUnitTest tests[] = {
        cmocka_unit_test_setup_teardown(test_deviation, setup_f, teardown_f),
        cmocka_unit_test_setup_teardown(test_feature_change, setup_f, teardown_f),
        cmocka_unit_test(test_push_oper),
        cmocka_unit_test(test_context_change_no_diff),
    };

    setenv("CMOCKA_TEST_ABORT", "1", 1);
    test_log_init();
    return cmocka_run_group_tests(tests, setup, teardown);
}