|
Lines 28-33
Link Here
|
| 28 |
#define TEST_CONFIG_WIRELESS_DHCP TEST_CONFIGS_DIR "/ifaces-config/wl" |
28 |
#define TEST_CONFIG_WIRELESS_DHCP TEST_CONFIGS_DIR "/ifaces-config/wl" |
| 29 |
#define TEST_CONFIG_IPV6 TEST_CONFIGS_DIR "/ifaces-config/ipv6" |
29 |
#define TEST_CONFIG_IPV6 TEST_CONFIGS_DIR "/ifaces-config/ipv6" |
| 30 |
#define TEST_CONFIG_BRIDGE TEST_CONFIGS_DIR "/ifaces-config/bridge" |
30 |
#define TEST_CONFIG_BRIDGE TEST_CONFIGS_DIR "/ifaces-config/bridge" |
|
|
31 |
#define TEST_CONFIG_VLAN_STATIC TEST_CONFIGS_DIR "/ifaces-config/ens19.100" |
| 32 |
#define TEST_CONFIG_VLAN_L2 TEST_CONFIGS_DIR "/ifaces-config/ens19.200" |
| 31 |
|
33 |
|
| 32 |
static void |
34 |
static void |
| 33 |
verify_setting_connection(NMSettingConnection *s_con, const char *expected_id, |
35 |
verify_setting_connection(NMSettingConnection *s_con, const char *expected_id, |
|
Lines 1475-1480
test_read_bridge_ignored(void)
Link Here
|
| 1475 |
test_read_bridge(TEST_CONFIG_BRIDGE, NULL, TRUE, TRUE, "System bridge"); |
1476 |
test_read_bridge(TEST_CONFIG_BRIDGE, NULL, TRUE, TRUE, "System bridge"); |
| 1476 |
} |
1477 |
} |
| 1477 |
|
1478 |
|
|
|
1479 |
static void |
| 1480 |
test_read_vlan(const char * iface_path, |
| 1481 |
const char * expected_id, |
| 1482 |
const char * expected_iface_name, |
| 1483 |
guint32 expected_vid, |
| 1484 |
const char * expected_ipv4_method, |
| 1485 |
guint32 expected_num_ipv4addr, |
| 1486 |
const test_ip_address_t *expected_ipv4addresses) |
| 1487 |
{ |
| 1488 |
NMConnection * connection; |
| 1489 |
NMSettingConnection *s_con; |
| 1490 |
NMSettingVlan * s_vlan; |
| 1491 |
NMSettingIPConfig * s_ip4; |
| 1492 |
NMSettingIPConfig * s_ip6; |
| 1493 |
GError * error = NULL; |
| 1494 |
gboolean ignored = TRUE; |
| 1495 |
|
| 1496 |
connection = read_connection(iface_path, NULL, &ignored, &error); |
| 1497 |
|
| 1498 |
g_assert_false(ignored); |
| 1499 |
g_assert_no_error(error); |
| 1500 |
g_assert(connection); |
| 1501 |
nmtst_assert_connection_verifies(connection); |
| 1502 |
|
| 1503 |
s_con = nm_connection_get_setting_connection(connection); |
| 1504 |
verify_setting_connection(s_con, expected_id, TRUE); |
| 1505 |
g_assert_cmpstr(nm_setting_connection_get_connection_type(s_con), |
| 1506 |
==, |
| 1507 |
NM_SETTING_VLAN_SETTING_NAME); |
| 1508 |
g_assert_cmpstr(nm_setting_connection_get_interface_name(s_con), ==, expected_iface_name); |
| 1509 |
|
| 1510 |
s_vlan = nm_connection_get_setting_vlan(connection); |
| 1511 |
g_assert(s_vlan); |
| 1512 |
g_assert_cmpstr(nm_setting_vlan_get_parent(s_vlan), ==, "ens19"); |
| 1513 |
g_assert_cmpuint(nm_setting_vlan_get_id(s_vlan), ==, expected_vid); |
| 1514 |
|
| 1515 |
s_ip4 = nm_connection_get_setting_ip4_config(connection); |
| 1516 |
verify_setting_ip(s_ip4, |
| 1517 |
expected_id, |
| 1518 |
expected_ipv4_method, |
| 1519 |
expected_num_ipv4addr, |
| 1520 |
expected_ipv4addresses, |
| 1521 |
NULL, |
| 1522 |
0, |
| 1523 |
NULL, |
| 1524 |
0, |
| 1525 |
NULL, |
| 1526 |
0, |
| 1527 |
NULL); |
| 1528 |
|
| 1529 |
s_ip6 = nm_connection_get_setting_ip6_config(connection); |
| 1530 |
verify_setting_ip(s_ip6, |
| 1531 |
expected_id, |
| 1532 |
NM_SETTING_IP6_CONFIG_METHOD_IGNORE, |
| 1533 |
0, |
| 1534 |
NULL, |
| 1535 |
NULL, |
| 1536 |
0, |
| 1537 |
NULL, |
| 1538 |
0, |
| 1539 |
NULL, |
| 1540 |
0, |
| 1541 |
NULL); |
| 1542 |
|
| 1543 |
g_object_unref(connection); |
| 1544 |
} |
| 1545 |
|
| 1546 |
static void |
| 1547 |
test_read_vlan_static(void) |
| 1548 |
{ |
| 1549 |
const test_ip_address_t addresses[1] = {{"192.168.0.1", 24}}; |
| 1550 |
|
| 1551 |
test_read_vlan(TEST_CONFIG_VLAN_STATIC, |
| 1552 |
"System ens19.100", |
| 1553 |
"ens19.100", |
| 1554 |
100, |
| 1555 |
NM_SETTING_IP4_CONFIG_METHOD_MANUAL, |
| 1556 |
1, |
| 1557 |
addresses); |
| 1558 |
} |
| 1559 |
|
| 1560 |
static void |
| 1561 |
test_read_vlan_l2(void) |
| 1562 |
{ |
| 1563 |
test_read_vlan(TEST_CONFIG_VLAN_L2, |
| 1564 |
"System ens19.200", |
| 1565 |
"ens19.200", |
| 1566 |
200, |
| 1567 |
NM_SETTING_IP4_CONFIG_METHOD_DISABLED, |
| 1568 |
0, |
| 1569 |
NULL); |
| 1570 |
} |
| 1571 |
|
| 1478 |
static void |
1572 |
static void |
| 1479 |
test_read_eth_dhcp_no_type(void) |
1573 |
test_read_eth_dhcp_no_type(void) |
| 1480 |
{ |
1574 |
{ |
|
Lines 1533-1538
main(int argc, char **argv)
Link Here
|
| 1533 |
|
1610 |
|
| 1534 |
g_test_add_func(TPATH "test_read_bridge_ignored", test_read_bridge_ignored); |
1611 |
g_test_add_func(TPATH "test_read_bridge_ignored", test_read_bridge_ignored); |
| 1535 |
|
1612 |
|
|
|
1613 |
g_test_add_func(TPATH "test_read_vlan_static", test_read_vlan_static); |
| 1614 |
g_test_add_func(TPATH "test_read_vlan_l2", test_read_vlan_l2); |
| 1615 |
|
| 1536 |
g_test_add_func(TPATH "test_read_eth_dhcp_no_type", test_read_eth_dhcp_no_type); |
1616 |
g_test_add_func(TPATH "test_read_eth_dhcp_no_type", test_read_eth_dhcp_no_type); |
| 1537 |
|
1617 |
|
| 1538 |
return g_test_run(); |
1618 |
return g_test_run(); |