Skip to content

Commit d50ca05

Browse files
test: NAT test can now be run (a bit sloppy but works)
1 parent dedc9ac commit d50ca05

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

test/net/integration/nat/service.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222
using namespace net;
2323

24+
void verify() {
25+
static int i = 0;
26+
if(++i == 4)
27+
printf("SUCCESS\n");
28+
}
2429

2530
void ip_forward(Inet<IP4>& stack, IP4::IP_packet_ptr pckt) {
2631
stack.ip_obj().ship(std::move(pckt));
@@ -49,19 +54,23 @@ void Service::start()
4954

5055
internet_host.tcp().listen(80, [](auto conn) {
5156
printf("Internet page received a new connection! (%s)\n", conn->to_string().c_str());
57+
verify();
5258
});
5359

5460
laptop1.tcp().connect({ internet_host.ip_addr(), 80 }, [](auto conn) {
5561
printf("Laptop1 connected to internet web page! (%s)\n", conn->to_string().c_str());
62+
verify();
5663
});
5764

5865
nat.add_entry(8080, { laptop1.ip_addr(), 80 });
5966

6067
laptop1.tcp().listen(80, [](auto conn) {
6168
printf("Laptop1 received a new connection! (%s)\n", conn->to_string().c_str());
69+
verify();
6270
});
6371

6472
internet_client.tcp().connect({ laptop1.ip_addr(), 80 }, [](auto conn) {
6573
printf("Bob (internet) connected to Laptop1! (%s)\n", conn->to_string().c_str());
74+
verify();
6675
});
6776
}

test/net/integration/nat/test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#! /usr/bin/env python
2+
3+
import sys
4+
import os
5+
6+
includeos_src = os.environ.get('INCLUDEOS_SRC',
7+
os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0])
8+
sys.path.insert(0,includeos_src)
9+
10+
from vmrunner import vmrunner
11+
vmrunner.vms[0].cmake().boot(10).clean()

test/net/integration/nat/vm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"image" : "test_dhcp_server.img",
2+
"image" : "test_nat.img",
33
"net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"},
44
{"device" : "virtio", "mac" : "c0:01:0a:00:00:2f"},
55
{"device" : "virtio", "mac" : "c0:01:0a:00:00:20"},

0 commit comments

Comments
 (0)