app/eventdev: enable fast free offload
[dpdk.git] / app / test-bbdev / test-bbdev.py
1 #!/usr/bin/env python3
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 dpdk_path = "../.."
19 dpdk_target = "build"
20
21 parser = argparse.ArgumentParser(
22                     description='BBdev Unit Test Application',
23                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
24 parser.add_argument("-p", "--testapp-path",
25                     help="specifies path to the bbdev test app",
26                     default=dpdk_path + "/" + dpdk_target + "/app/dpdk-test-bbdev")
27 parser.add_argument("-e", "--eal-params",
28                     help="EAL arguments which are passed to the test app",
29                     default="--vdev=baseband_null0")
30 parser.add_argument("-t", "--timeout",
31                     type=int,
32                     help="Timeout in seconds",
33                     default=300)
34 parser.add_argument("-c", "--test-cases",
35                     nargs="+",
36                     help="Defines test cases to run. Run all if not specified")
37 parser.add_argument("-v", "--test-vector",
38                     nargs="+",
39                     help="Specifies paths to the test vector files.",
40                     default=[dpdk_path +
41                     "/app/test-bbdev/test_vectors/bbdev_null.data"])
42 parser.add_argument("-n", "--num-ops",
43                     type=int,
44                     help="Number of operations to process on device.",
45                     default=32)
46 parser.add_argument("-b", "--burst-size",
47                     nargs="+",
48                     type=int,
49                     help="Operations enqueue/dequeue burst size.",
50                     default=[32])
51 parser.add_argument("-l", "--num-lcores",
52                     type=int,
53                     help="Number of lcores to run.",
54                     default=16)
55 parser.add_argument("-i", "--init-device",
56                     action='store_true',
57                     help="Initialise PF device with default values.")
58
59 args = parser.parse_args()
60
61 if not os.path.exists(args.testapp_path):
62     print("No such file: " + args.testapp_path)
63     sys.exit(1)
64
65 params = [args.testapp_path]
66 if args.eal_params:
67     params.extend(shlex.split(args.eal_params))
68
69 params.extend(["--"])
70
71 if args.num_ops:
72     params.extend(["-n", str(args.num_ops)])
73
74 if args.num_lcores:
75     params.extend(["-l", str(args.num_lcores)])
76
77 if args.test_cases:
78     params.extend(["-c"])
79     params.extend([",".join(args.test_cases)])
80
81 if args.init_device:
82     params.extend(["-i"])
83
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)