-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·67 lines (53 loc) · 1.86 KB
/
test
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
62
63
64
65
66
67
#!/usr/bin/env python3
import os
import subprocess
import sys
import re
EXECUTABLE_NAME = "3700router"
RUN_SCRIPT_NAME = "run"
CONFIG_DIR = "configs"
def die(message):
print("ERROR: %s" % message)
sys.exit(-1)
def get_files():
if not os.path.exists(EXECUTABLE_NAME):
die("Could not find bridge program '%s'" % EXECUTABLE_NAME)
if not os.access(EXECUTABLE_NAME, os.X_OK):
die("Could not execute bridge program '%s'" % EXECUTABLE_NAME)
if not os.path.exists(RUN_SCRIPT_NAME):
die("Could not find simulator '%s'" % EXECUTABLE_NAME)
if not os.access(RUN_SCRIPT_NAME, os.X_OK):
die("Could not execute simulator '%s'" % RUN_SCRIPT_NAME)
get_files()
def runTest(config):
print("%s" % ("Test: %s" % (config)).ljust(60, ' '), end='')
result = subprocess.check_output([os.path.join(os.getcwd(), RUN_SCRIPT_NAME), os.path.join(CONFIG_DIR, config)]).decode('utf-8')
pattern = re.compile("Simulation complete. Errors detected\n\n(.*)", re.DOTALL)
m = re.search(pattern, result)
if m:
print("[FAIL]\n%s" % m.group(1))
else:
pattern = re.compile("Simulation complete. No errors detected; congratulations", re.DOTALL)
if re.search(pattern, result):
print("[PASS]")
else:
print("[FAIL]\n%s" % result)
print("Milestone tests")
runTest("1-1-simple-send.conf")
runTest("1-2-simple-send.conf")
print("\nFinal tests")
runTest("2-1-loop-select-hpref.conf")
runTest("2-2-loop-select-sorg.conf")
runTest("2-3-loop-select-aspath.conf")
runTest("2-4-loop-select-orig.conf")
runTest("2-5-loop-select-ip.conf")
runTest("3-1-simple-revoke.conf")
runTest("3-2-bad-route.conf")
runTest("4-1-peering.conf")
runTest("4-2-provider.conf")
runTest("4-3-provider-peer.conf")
runTest("5-1-provider-default-route.conf")
runTest("5-2-longest-prefix.conf")
runTest("6-1-coalesce-simple.conf")
runTest("6-2-coalesce-complex.conf")
runTest("6-3-disaggregate.conf")