Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpino committed Mar 27, 2018
1 parent 8010951 commit c55b21b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/program/lwaftr/tests/subcommands/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from subprocess import PIPE, Popen
import time
import unittest
import re

from test_env import BENCHDATA_DIR, DATA_DIR, ENC, SNABB_CMD, \
DAEMON_STARTUP_WAIT, BaseTestCase, nic_names
Expand Down Expand Up @@ -239,14 +240,13 @@ def test_snabb_get_state_summation(self):
for line in state:
if "softwire-state" not in line:
continue
[cname, cvalue] = line.split(" ")
cname = os.path.basename(cname)
cvalue = int(cvalue)

path = [elem for elem in line.split("/") if elem]
cname = path[-1].split()[0]
cvalue = int(path[-1].split()[1])

if path[0].startswith("instance"):
if line.startswith("/softwire-config"):
instance[cname] = instance.get(cname, 0) + cvalue
elif len(path) < 3:
elif line.startswith("/softwire-state"):
summed[cname] = cvalue

# Now assert they're the same :)
Expand All @@ -268,12 +268,13 @@ def test_snabb_get_state_lists_instances(self):

instances = set()
for line in state:
path = [elem for elem in line.split("/") if elem]
if not path[0].startswith("instance"):
[key, value] = line.split(" ")
if key.startswith("/softwire-config") and "instance" not in key:
continue

device_name = path[0][path[0].find("=")+1:-1]
instances.add(device_name)
m = re.search(r"\[device=(.*)\]", key)
if m:
device_name = m.group(1)
instances.add(device_name)

self.assertTrue(len(instances) == 2)
self.assertTrue("test" in instances)
Expand Down

0 comments on commit c55b21b

Please sign in to comment.