compress/qat: add info retrieval function
[dpdk.git] / app / test-bbdev / test-bbdev.py
1 #!/usr/bin/env python
2
3 # SPDX-License-Identifier: BSD-3-Clause
4 # Copyright(c) 2017 Intel Corporation
5
6 import sys
7 import os
8 import argparse
9 import subprocess
10 import shlex
11
12 from threading import Timer
13
14 def kill(process):
15     print "ERROR: Test app timed out"
16     process.kill()
17
18 if "RTE_SDK" in os.environ:
19     dpdk_path = os.environ["RTE_SDK"]
20 else:
21     dpdk_path = "../.."
22
23 if "RTE_TARGET" in os.environ:
24     dpdk_target = os.environ["RTE_TARGET"]
25 else:
26     dpdk_target = "x86_64-native-linuxapp-gcc"
27
28 parser = argparse.ArgumentParser(
29                     description='BBdev Unit Test Application',
30                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
31 parser.add_argument("-p", "--testapp-path",
32                     help="specifies path to the bbdev test app",
33                     default=dpdk_path + "/" + dpdk_target + "/app/testbbdev")
34 parser.add_argument("-e", "--eal-params",
35                     help="EAL arguments which are passed to the test app",
36                     default="--vdev=baseband_null0")
37 parser.add_argument("-t", "--timeout",
38                     type=int,
39                     help="Timeout in seconds",
40                     default=300)
41 parser.add_argument("-c", "--test-cases",
42                     nargs="+",
43                     help="Defines test cases to run. Run all if not specified")
44 parser.add_argument("-v", "--test-vector",
45                     nargs="+",
46                     help="Specifies paths to the test vector files.",
47                     default=[dpdk_path +
48                     "/app/test-bbdev/test_vectors/bbdev_null.data"])
49 parser.add_argument("-n", "--num-ops",
50                     type=int,
51                     help="Number of operations to process on device.",
52                     default=32)
53 parser.add_argument("-b", "--burst-size",
54                     nargs="+",
55                     type=int,
56                     help="Operations enqueue/dequeue burst size.",
57                     default=[32])
58 parser.add_argument("-l", "--num-lcores",
59                     type=int,
60                     help="Number of lcores to run.",
61                     default=16)
62
63 args = parser.parse_args()
64
65 if not os.path.exists(args.testapp_path):
66     print "No such file: " + args.testapp_path
67     sys.exit(1)
68
69 params = [args.testapp_path]
70 if args.eal_params:
71     params.extend(shlex.split(args.eal_params))
72
73 params.extend(["--"])
74
75 if args.num_ops:
76     params.extend(["-n", str(args.num_ops)])
77
78 if args.num_lcores:
79     params.extend(["-l", str(args.num_lcores)])
80
81 if args.test_cases:
82     params.extend(["-c"])
83     params.extend([",".join(args.test_cases)])
84
85 exit_status = 0
86 for vector in args.test_vector:
87     for burst_size in args.burst_size:
88         call_params = params[:]
89         call_params.extend(["-v", vector])
90         call_params.extend(["-b", str(burst_size)])
91         params_string = " ".join(call_params)
92
93         print("Executing: {}".format(params_string))
94         app_proc = subprocess.Popen(call_params)
95         if args.timeout > 0:
96             timer = Timer(args.timeout, kill, [app_proc])
97             timer.start()
98
99         try:
100             app_proc.communicate()
101         except:
102             print("Error: failed to execute: {}".format(params_string))
103         finally:
104             timer.cancel()
105
106         if app_proc.returncode != 0:
107             exit_status = 1
108             print("ERROR TestCase failed. Failed test for vector {}. Return code: {}".format(
109                 vector, app_proc.returncode))
110
111 sys.exit(exit_status)