blob: e8ff2cda109e21d0cf222786cac37dfbccedee1d [file] [log] [blame]
Rich Lanea06d0c32013-03-25 08:52:03 -07001#!/usr/bin/python
2# Copyright 2013, Big Switch Networks, Inc.
3#
4# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
5# the following special exception:
6#
7# LOXI Exception
8#
9# As a special exception to the terms of the EPL, you may distribute libraries
10# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
11# that copyright and licensing notices generated by LoxiGen are not altered or removed
12# from the LoxiGen Libraries and the notice provided below is (i) included in
13# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
14# documentation for the LoxiGen Libraries, if distributed in binary form.
15#
16# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
17#
18# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
19# a copy of the EPL at:
20#
21# http://www.eclipse.org/legal/epl-v10.html
22#
23# Unless required by applicable law or agreed to in writing, software
24# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
26# EPL for the specific language governing permissions and limitations
27# under the EPL.
28
29#
30# Some test code for identifiers.py
31#
32
33import sys
34sys.path.append("..")
35sys.path.append("../loxi_front_end")
36sys.path.append("../loxi_utils")
37
38from identifiers import *
39
40test_dict = {}
41group_dict = {}
42
43for ver, filename in [
44 (1, '../canonical/openflow.h-1.0'),
45 (2, '../canonical/openflow.h-1.1'),
46 (3, '../canonical/openflow.h-1.2'),
47 (4, '../canonical/openflow.h-1.3')]:
48
49 f = open(filename, 'r')
50 all_lines = f.readlines()
51 contents = " ".join(all_lines)
52
53 add_identifiers(test_dict, group_dict, ver, contents)
54
55version_list = [1,2,3,4]
56print "Merged %d entries from files" % len(test_dict)
57
58for ident, info in test_dict.items():
59 print """
60Name %s:
61 common %s
62 num vals %d
63 all agree %s
64 defined agree %s
65 ofp name %s
66 group %s""" % (ident, str(info["common_value"]),
67 len(info["values_by_version"]),
68 all_versions_agree(test_dict, version_list, ident),
69 defined_versions_agree(test_dict, version_list, ident),
70 info["ofp_name"], info["ofp_group"])
71
72 for version, value in info["values_by_version"].items():
73 print " version %d value %s" % (version, value)
74
75for ident, loxi_list in group_dict.items():
76 print "Group %s:" % ident
77 for loxi_name in loxi_list:
78 print " %s" % loxi_name