File: test_netplan_openvswitch.c

package info (click to toggle)
netplan.io 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,268 kB
  • sloc: python: 34,640; ansic: 14,096; xml: 4,989; javascript: 2,165; sh: 513; makefile: 118
file content (61 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (3)
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
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>

#include <cmocka.h>

#include "netplan.h"
#include "util-internal.h"
#include "validation.h"

#include "test_utils.h"

void
test_write_ovs_bond_interfaces_null_bridge(__unused void** state)
{

    NetplanNetDefinition* netdef = g_malloc0(sizeof(NetplanNetDefinition));

    netdef->bridge = NULL;
    assert_null(write_ovs_bond_interfaces(NULL, netdef, NULL, NULL));

    g_free(netdef);
}

void
test_validate_ovs_target(__unused void** state)
{
    assert_true(validate_ovs_target(TRUE, "10.2.3.4:12345"));
    assert_true(validate_ovs_target(TRUE, "10.2.3.4"));
    assert_true(validate_ovs_target(TRUE, "[::1]:12345"));
    assert_true(validate_ovs_target(TRUE, "[::1]"));

    assert_true(validate_ovs_target(FALSE, "12345:10.2.3.4"));
    assert_true(validate_ovs_target(FALSE, "12345:[::1]"));
}

int
setup(__unused void** state)
{
    return 0;
}

int
tear_down(__unused void** state)
{
    return 0;
}

int
main()
{

    const struct CMUnitTest tests[] = {
        cmocka_unit_test(test_write_ovs_bond_interfaces_null_bridge),
        cmocka_unit_test(test_validate_ovs_target),
    };

    return cmocka_run_group_tests(tests, setup, tear_down);

}