diff options
author | Hanoh Haim <hhaim@cisco.com> | 2016-02-03 11:36:58 +0200 |
---|---|---|
committer | Hanoh Haim <hhaim@cisco.com> | 2016-02-03 11:36:58 +0200 |
commit | dda9b08e2b57f785b71bccf4dab57ef4b2fb1dc3 (patch) | |
tree | 62eb7cb4d3c1ae8c7f38b0d48f4a0ca5f683e76e /scripts/automation/trex_control_plane | |
parent | 2e8a6255330ae7babdd0ace9889fa89796ac3687 (diff) |
sanity check for var does not exists
Diffstat (limited to 'scripts/automation/trex_control_plane')
-rw-r--r-- | scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py b/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py index fda77cf7..79616ad7 100644 --- a/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py +++ b/scripts/automation/trex_control_plane/client_utils/scapy_packet_builder.py @@ -441,6 +441,12 @@ class CTRexVmDescBase(object): print yaml.dump(self.get_json(), default_flow_style=False) + def get_var_ref (self): + ''' + virtual function return a ref var name + ''' + return None + def get_var_name(self): ''' virtual function return the varible name if exists @@ -520,6 +526,9 @@ class CTRexVmDescWrFlowVar(CTRexVmDescBase): self.is_big =is_big; assert(type(is_big)==bool); + def get_var_ref (self): + return self.name + def get_obj (self): return CTRexVmInsWrFlowVar(self.name,self.pkt_offset+self.offset_fixup,self.add_val,self.is_big) @@ -622,15 +631,22 @@ class CScapyTRexPktBuilder(object): # make sure we have varibles once vars={}; + + # add it add var to dit for desc in obj.commands: - print desc.__dict__ var_name = desc.get_var_name() - print var_name if var_name : if vars.has_key(var_name): - raise CTRexPacketBuildException(-11,("varible %s define twice ") % (var_name) ); + raise CTRexPacketBuildException(-11,("variable %s define twice ") % (var_name) ); else: vars[var_name]=1 + + # check that all write exits + for desc in obj.commands: + var_name = desc.get_var_ref() + if var_name : + if not vars.has_key(var_name): + raise CTRexPacketBuildException(-11,("variable %s does not exists ") % (var_name) ); desc.compile(self); for desc in obj.commands: |