X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Ftrex%2Ftrex_stateless_stop.py;h=3fc599a5a499dfe12a3fbf0db6047946b5b678ca;hb=bab0b570345ceb6ffeaec9e47a50e62d7303387e;hp=9421356bc1b814f35c3274236ac94048d2c688a9;hpb=ff820e3d53434889aacde2373314c3be8d00f765;p=csit.git diff --git a/resources/tools/trex/trex_stateless_stop.py b/resources/tools/trex/trex_stateless_stop.py index 9421356bc1..3fc599a5a4 100755 --- a/resources/tools/trex/trex_stateless_stop.py +++ b/resources/tools/trex/trex_stateless_stop.py @@ -23,18 +23,29 @@ Requirements: Functionality: 1. Stop any running traffic +2. Optionally restore reference counter values. +3. Return conter differences. """ +import argparse +from collections import OrderedDict # Needed to parse xstats representation. import sys import json -sys.path.insert(0, "/opt/trex-core-2.54/scripts/automation/"+\ +sys.path.insert(0, "/opt/trex-core-2.61/scripts/automation/"+\ "trex_control_plane/interactive/") from trex.stl.api import * def main(): """Stop traffic if any is running. Report xstats.""" + parser = argparse.ArgumentParser() + parser.add_argument( + "--xstat0", type=str, default="", help="Reference xstat object if any.") + parser.add_argument( + "--xstat1", type=str, default="", help="Reference xstat object if any.") + args = parser.parse_args() + client = STLClient() try: # connect to server @@ -44,7 +55,15 @@ def main(): # TODO: Support unidirection. client.stop(ports=[0, 1]) - # read the stats after the test + # Read the stats after the test, + # we need to update values before the last trial started. + if args.xstat0: + snapshot = eval(args.xstat0) + client.ports[0].get_xstats().reference_stats = snapshot + if args.xstat1: + snapshot = eval(args.xstat1) + client.ports[1].get_xstats().reference_stats = snapshot + # Now we can call the official method to get differences. xstats0 = client.get_xstats(0) xstats1 = client.get_xstats(1)