summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYuichi Ito <ito.yuichi0@gmail.com>2014-06-23 14:41:05 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-06-23 17:10:24 +0900
commit013cc84ce533ffa2072a695e6c48420ea20d50ee (patch)
treec86a85ca848969b389238b9ac29a0f0c3121b066
parentb9034c18bf894d66ba6b3836480f749ae5ac9354 (diff)
sw test tool: Enable using user-specified versions to parse
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/tests/switch/tester.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/ryu/tests/switch/tester.py b/ryu/tests/switch/tester.py
index d104a58c..d3e22d3e 100644
--- a/ryu/tests/switch/tester.py
+++ b/ryu/tests/switch/tester.py
@@ -1284,6 +1284,18 @@ class Test(stringify.StringifyMixin):
data.serialize()
return str(data.data)
+ # get ofproto modules using user-specified versions
+ (target_ofproto, target_parser) = ofproto_protocol._versions[
+ OfTester.target_ver]
+ (tester_ofproto, tester_parser) = ofproto_protocol._versions[
+ OfTester.tester_ver]
+ target_dp = DummyDatapath()
+ target_dp.ofproto = target_ofproto
+ target_dp.ofproto_parser = target_parser
+ tester_dp = DummyDatapath()
+ tester_dp.ofproto = tester_ofproto
+ tester_dp.ofproto_parser = tester_parser
+
# parse 'description'
description = buf.get(KEY_DESC)
@@ -1298,9 +1310,9 @@ class Test(stringify.StringifyMixin):
raise ValueError(
'"%s" block allows only the followings: %s' % (
KEY_PREREQ, allowed_mod))
- cls = getattr(ofproto_v1_3_parser, key)
- msg = cls.from_jsondict(value, datapath=DummyDatapath())
- msg.version = ofproto_v1_3.OFP_VERSION
+ cls = getattr(target_parser, key)
+ msg = cls.from_jsondict(value, datapath=target_dp)
+ msg.version = target_ofproto.OFP_VERSION
msg.msg_type = msg.cls_msg_type
msg.xid = 0
prerequisite.append(msg)
@@ -1346,9 +1358,9 @@ class Test(stringify.StringifyMixin):
for throughput in test[KEY_EGRESS][KEY_THROUGHPUT]:
one = {}
mod = {'match': {'OFPMatch': throughput[KEY_MATCH]}}
- cls = getattr(ofproto_v1_3_parser, KEY_FLOW)
+ cls = getattr(tester_parser, KEY_FLOW)
msg = cls.from_jsondict(
- mod, datapath=DummyDatapath(),
+ mod, datapath=tester_dp,
cookie=THROUGHPUT_COOKIE,
priority=THROUGHPUT_PRIORITY)
one[KEY_FLOW] = msg