summaryrefslogtreecommitdiffstats
path: root/scripts/stl_test_example.py
blob: 7974758dbecb611f47fba2ddbbbfe233ee5fcc7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# simple test that uses simple API with stateless TRex
#from stl_test_api import BasicTestAPI
api_path = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(api_path, '../automation/trex_control_plane/client/'))

from trex_stateless_client import CTRexStatelessClient, LoggerApi

c = CTRexStatelessClient()
try:
    c.connect()
    #before_ipackets = x.get_stats().get_rel('ipackets')
    c.cmd_start_line("-f stl/imix_1pkt.yaml -m 5mpps -d 1")
    c.cmd_wait_on_traffic()
finally:
    c.disconnect()

#x = BasicTestAPI()
#
#try:
#    x.connect()
#
#    before_ipackets = x.get_stats().get_rel('ipackets')
#
#    print "input packets before test: %s" % before_ipackets
#
#    x.inject_profile("stl/imix_1pkt.yaml", rate = "5mpps", duration = 1)
#    x.wait_while_traffic_on()
#
#    after_ipackets = x.get_stats().get_rel('ipackets')
#
#    print "input packets after test: %s" % after_ipackets
#
#    if (after_ipackets - before_ipackets) == 5000000:
#        print "Test passed :-)\n"
#    else:
#        print "Test failed :-(\n"
#
#finally:
#    x.disconnect()