public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
blob 2627b5798f2bd042d8e53254219f5173ddb7a776 1622 bytes (raw)

 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
 
#! /usr/bin/env python3

# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>

"""
Test A Simple Socket Transport

meta/static_ifup - Static address configuration
"""

import contextlib
import ipaddress

import exeter

from tasst import nstool


IFNAME = 'testveth'
IFNAME_PEER = 'vethpeer'
TEST_IPS = set([ipaddress.ip_interface('192.0.2.1/24'),
                ipaddress.ip_interface('2001:db8:9a55::1/112'),
                ipaddress.ip_interface('10.1.2.3/8')])


@contextlib.contextmanager
def setup_ns():
    with nstool.unshare_snh('ns', '-Un') as ns:
        ns.veth(IFNAME, IFNAME_PEER)
        ns.ifup(IFNAME, *TEST_IPS, dad='disable')
        yield ns


@exeter.test
def test_addr():
    with setup_ns() as ns:
        exeter.assert_eq(set(ns.addrs(IFNAME, scope='global')), TEST_IPS)


@exeter.test
def test_routes4():
    with setup_ns() as ns:
        expected_routes = set(i.network for i in TEST_IPS
                              if isinstance(i, ipaddress.IPv4Interface))
        actual_routes = set(ipaddress.ip_interface(r['dst']).network
                            for r in ns.routes4(dev=IFNAME))
        exeter.assert_eq(expected_routes, actual_routes)


@exeter.test
def test_routes6():
    with setup_ns() as ns:
        expected_routes = set(i.network for i in TEST_IPS
                              if isinstance(i, ipaddress.IPv6Interface))
        actual_routes = set(ipaddress.ip_interface(r['dst']).network
                            for r in ns.routes6(dev=IFNAME))
        exeter.assert_eq(expected_routes, actual_routes)

debug log:

solving 2627b579 ...
found 2627b579 in https://archives.passt.top/passt-dev/20240805123701.1720730-17-david@gibson.dropbear.id.au/
found 0c6375d4 in https://archives.passt.top/passt-dev/20240805123701.1720730-16-david@gibson.dropbear.id.au/

applying [1/2] https://archives.passt.top/passt-dev/20240805123701.1720730-16-david@gibson.dropbear.id.au/
diff --git a/test/tasst/selftest/static_ifup.py b/test/tasst/selftest/static_ifup.py
new file mode 100644
index 00000000..0c6375d4


applying [2/2] https://archives.passt.top/passt-dev/20240805123701.1720730-17-david@gibson.dropbear.id.au/
diff --git a/test/tasst/selftest/static_ifup.py b/test/tasst/selftest/static_ifup.py
index 0c6375d4..2627b579 100644

Checking patch test/tasst/selftest/static_ifup.py...
Applied patch test/tasst/selftest/static_ifup.py cleanly.
Checking patch test/tasst/selftest/static_ifup.py...
Applied patch test/tasst/selftest/static_ifup.py cleanly.

index at:
100644 2627b5798f2bd042d8e53254219f5173ddb7a776	test/tasst/selftest/static_ifup.py

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).