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
| | #! /usr/bin/env python3
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# test/pasta/ndp.py - pasta NDP functionality
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>
import contextlib
import dataclasses
from typing import Iterator
import exeter
import tunbridge
import tasst
@dataclasses.dataclass
class UnconfiguredScenario(exeter.Scenario):
"""Tests for a pasta instance without --config-net"""
host: tunbridge.Site
guest: tunbridge.Site
ifname: str
addr6: tunbridge.ip.AddrMask6
gw6: tunbridge.ip.Addr6
@exeter.scenariotest
def test_ifname(self) -> None:
ifs = tunbridge.ip.ifs(self.guest)
exeter.assert_eq(set(ifs), {'lo', self.ifname})
@tunbridge.ndp.NdpScenario.subscenario
def test_ndp(self) -> tunbridge.ndp.NdpScenario:
tunbridge.ip.ifup(self.guest, self.ifname)
return tunbridge.ndp.NdpScenario(client=self.guest,
ifname=self.ifname,
network=self.addr6.network,
gateway=self.gw6)
@UnconfiguredScenario.test
@contextlib.contextmanager
def simh_pasta_setup() -> Iterator[UnconfiguredScenario]:
with (tunbridge.sample.simple_host('host') as simh,
tunbridge.sample.isolated('guest', simh.site) as guest):
assert simh.ip6 is not None
assert simh.gw6_ll is not None
with tasst.pasta.pasta(simh.site, guest):
yield UnconfiguredScenario(host=simh.site,
guest=guest,
ifname=simh.ifname,
addr6=simh.ip6,
gw6=simh.gw6_ll)
if __name__ == '__main__':
exeter.main()
|