xref: /dpdk/app/test-bbdev/test-bbdev.py (revision 2ce6cb49be35d93b23e715624531fedf69c50d75)
13f6f8362SLouise Kilheeney#!/usr/bin/env python3
2f714a188SAmr Mokhtar
3f714a188SAmr Mokhtar# SPDX-License-Identifier: BSD-3-Clause
4f714a188SAmr Mokhtar# Copyright(c) 2017 Intel Corporation
5f714a188SAmr Mokhtar
6f714a188SAmr Mokhtarimport sys
7f714a188SAmr Mokhtarimport os
8f714a188SAmr Mokhtarimport argparse
9f714a188SAmr Mokhtarimport subprocess
10f714a188SAmr Mokhtarimport shlex
11f714a188SAmr Mokhtar
12f714a188SAmr Mokhtarfrom threading import Timer
13f714a188SAmr Mokhtar
14f714a188SAmr Mokhtardef kill(process):
15c3fabbe9SLouise Kilheeney    print("ERROR: Test app timed out")
16f714a188SAmr Mokhtar    process.kill()
17f714a188SAmr Mokhtar
18f714a188SAmr Mokhtardpdk_path = "../.."
19c2c92c5dSCiara Powerdpdk_target = "build"
20f714a188SAmr Mokhtar
21f714a188SAmr Mokhtarparser = argparse.ArgumentParser(
22f714a188SAmr Mokhtar                    description='BBdev Unit Test Application',
23f714a188SAmr Mokhtar                    formatter_class=argparse.ArgumentDefaultsHelpFormatter)
24f714a188SAmr Mokhtarparser.add_argument("-p", "--testapp-path",
25f714a188SAmr Mokhtar                    help="specifies path to the bbdev test app",
26c2c92c5dSCiara Power                    default=dpdk_path + "/" + dpdk_target + "/app/dpdk-test-bbdev")
27f714a188SAmr Mokhtarparser.add_argument("-e", "--eal-params",
28e49b23ddSNicolas Chautru                    help="EAL arguments which must be passed to the test app",
29e49b23ddSNicolas Chautru                    default="--vdev=baseband_null0 -a00:00.0")
307e655a88SHernan Vargasparser.add_argument("-T", "--timeout",
31f714a188SAmr Mokhtar                    type=int,
32f714a188SAmr Mokhtar                    help="Timeout in seconds",
33e49b23ddSNicolas Chautru                    default=600)
34f714a188SAmr Mokhtarparser.add_argument("-c", "--test-cases",
35f714a188SAmr Mokhtar                    nargs="+",
36f714a188SAmr Mokhtar                    help="Defines test cases to run. Run all if not specified")
37f714a188SAmr Mokhtarparser.add_argument("-v", "--test-vector",
38f714a188SAmr Mokhtar                    nargs="+",
39f714a188SAmr Mokhtar                    help="Specifies paths to the test vector files.",
40f714a188SAmr Mokhtar                    default=[dpdk_path +
41ae828b8cSKamil Chalupnik                    "/app/test-bbdev/test_vectors/bbdev_null.data"])
42f714a188SAmr Mokhtarparser.add_argument("-n", "--num-ops",
43f714a188SAmr Mokhtar                    type=int,
44f714a188SAmr Mokhtar                    help="Number of operations to process on device.",
45f714a188SAmr Mokhtar                    default=32)
46f714a188SAmr Mokhtarparser.add_argument("-b", "--burst-size",
47f714a188SAmr Mokhtar                    nargs="+",
48f714a188SAmr Mokhtar                    type=int,
49f714a188SAmr Mokhtar                    help="Operations enqueue/dequeue burst size.",
50f714a188SAmr Mokhtar                    default=[32])
51e49b23ddSNicolas Chautruparser.add_argument("-s", "--snr",
52e49b23ddSNicolas Chautru                    type=int,
53e49b23ddSNicolas Chautru                    help="SNR in dB for BLER tests",
54e49b23ddSNicolas Chautru                    default=0)
557e655a88SHernan Vargasparser.add_argument("-t", "--iter-max",
567e655a88SHernan Vargas                    type=int,
577e655a88SHernan Vargas                    help="Max iterations",
587e655a88SHernan Vargas                    default=6)
59f714a188SAmr Mokhtarparser.add_argument("-l", "--num-lcores",
60f714a188SAmr Mokhtar                    type=int,
61f714a188SAmr Mokhtar                    help="Number of lcores to run.",
62f714a188SAmr Mokhtar                    default=16)
63d819c083SNicolas Chautruparser.add_argument("-i", "--init-device",
64d819c083SNicolas Chautru                    action='store_true',
65d819c083SNicolas Chautru                    help="Initialise PF device with default values.")
66f714a188SAmr Mokhtar
67f714a188SAmr Mokhtarargs = parser.parse_args()
68f714a188SAmr Mokhtar
69f714a188SAmr Mokhtarif not os.path.exists(args.testapp_path):
70c3fabbe9SLouise Kilheeney    print("No such file: " + args.testapp_path)
71f714a188SAmr Mokhtar    sys.exit(1)
72f714a188SAmr Mokhtar
73f714a188SAmr Mokhtarparams = [args.testapp_path]
74f714a188SAmr Mokhtarif args.eal_params:
75f714a188SAmr Mokhtar    params.extend(shlex.split(args.eal_params))
76f714a188SAmr Mokhtar
77f714a188SAmr Mokhtarparams.extend(["--"])
78f714a188SAmr Mokhtar
79e49b23ddSNicolas Chautruif args.snr:
80e49b23ddSNicolas Chautru    params.extend(["-s", str(args.snr)])
81e49b23ddSNicolas Chautru
82e49b23ddSNicolas Chautruif args.iter_max:
83e49b23ddSNicolas Chautru    params.extend(["-t", str(args.iter_max)])
84e49b23ddSNicolas Chautru
85f714a188SAmr Mokhtarif args.num_ops:
86f714a188SAmr Mokhtar    params.extend(["-n", str(args.num_ops)])
87f714a188SAmr Mokhtar
88f714a188SAmr Mokhtarif args.num_lcores:
89f714a188SAmr Mokhtar    params.extend(["-l", str(args.num_lcores)])
90f714a188SAmr Mokhtar
91f714a188SAmr Mokhtarif args.test_cases:
92f714a188SAmr Mokhtar    params.extend(["-c"])
93f714a188SAmr Mokhtar    params.extend([",".join(args.test_cases)])
94f714a188SAmr Mokhtar
95d819c083SNicolas Chautruif args.init_device:
96d819c083SNicolas Chautru    params.extend(["-i"])
97d819c083SNicolas Chautru
98d819c083SNicolas Chautru
99f714a188SAmr Mokhtarexit_status = 0
100f714a188SAmr Mokhtarfor vector in args.test_vector:
101f714a188SAmr Mokhtar    for burst_size in args.burst_size:
102f714a188SAmr Mokhtar        call_params = params[:]
103f714a188SAmr Mokhtar        call_params.extend(["-v", vector])
104f714a188SAmr Mokhtar        call_params.extend(["-b", str(burst_size)])
105f714a188SAmr Mokhtar        params_string = " ".join(call_params)
106f714a188SAmr Mokhtar
107f714a188SAmr Mokhtar        print("Executing: {}".format(params_string))
108f714a188SAmr Mokhtar        try:
109262c9d13SHernan Vargas            output = subprocess.run(call_params, timeout=args.timeout, universal_newlines=True)
110262c9d13SHernan Vargas        except subprocess.TimeoutExpired as e:
111*2ce6cb49SHernan Vargas            print("===========================================================")
112262c9d13SHernan Vargas            print("Starting Test Suite : BBdev TimeOut Tests")
113*2ce6cb49SHernan Vargas            print("INFO: One of the tests timed out {}".format(e))
114*2ce6cb49SHernan Vargas            print("INFO: Unexpected Error")
115*2ce6cb49SHernan Vargas            print("+ ------------------------------------------------------- +")
116262c9d13SHernan Vargas            print("== test: timeout")
117262c9d13SHernan Vargas            print("Unexpected Error")
118*2ce6cb49SHernan Vargas            print("TestCase [ 0] : timeout failed")
119*2ce6cb49SHernan Vargas            print(" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +")
120*2ce6cb49SHernan Vargas            print(" + Tests Failed :       1")
121*2ce6cb49SHernan Vargas            print(" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +")
122*2ce6cb49SHernan Vargas            exit_status = 1
123262c9d13SHernan Vargas        if output.returncode < 0:
124*2ce6cb49SHernan Vargas            print("===========================================================")
125262c9d13SHernan Vargas            print("Starting Test Suite : BBdev Exception Tests")
126*2ce6cb49SHernan Vargas            print("INFO: One of the tests returned {}".format(output.returncode))
127*2ce6cb49SHernan Vargas            print("INFO: Unexpected Error")
128*2ce6cb49SHernan Vargas            print("+ ------------------------------------------------------- +")
129262c9d13SHernan Vargas            print("== test: exception")
130262c9d13SHernan Vargas            print("Unexpected Error")
131*2ce6cb49SHernan Vargas            print("TestCase [ 0] : exception failed")
132*2ce6cb49SHernan Vargas            print(" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +")
133*2ce6cb49SHernan Vargas            print(" + Tests Failed :       1")
134*2ce6cb49SHernan Vargas            print(" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +")
135*2ce6cb49SHernan Vargas            exit_status = 1
136f714a188SAmr Mokhtarsys.exit(exit_status)
137