2018-01-11 19:23:21 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright(c) 2017 Intel Corporation
|
|
|
|
|
2020-07-10 10:10:54 +00:00
|
|
|
from __future__ import print_function
|
2018-01-11 19:23:21 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import argparse
|
|
|
|
import subprocess
|
|
|
|
import shlex
|
|
|
|
|
|
|
|
from threading import Timer
|
|
|
|
|
|
|
|
def kill(process):
|
2020-07-10 10:10:54 +00:00
|
|
|
print("ERROR: Test app timed out")
|
2018-01-11 19:23:21 +00:00
|
|
|
process.kill()
|
|
|
|
|
2020-07-10 10:10:47 +00:00
|
|
|
if sys.version_info.major < 3:
|
|
|
|
print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
|
|
|
|
print("Please use Python 3 instead", file=sys.stderr)
|
|
|
|
|
2018-01-11 19:23:21 +00:00
|
|
|
if "RTE_SDK" in os.environ:
|
|
|
|
dpdk_path = os.environ["RTE_SDK"]
|
|
|
|
else:
|
|
|
|
dpdk_path = "../.."
|
|
|
|
|
|
|
|
if "RTE_TARGET" in os.environ:
|
|
|
|
dpdk_target = os.environ["RTE_TARGET"]
|
|
|
|
else:
|
2019-03-06 16:22:42 +00:00
|
|
|
dpdk_target = "x86_64-native-linux-gcc"
|
2018-01-11 19:23:21 +00:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='BBdev Unit Test Application',
|
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
|
|
|
parser.add_argument("-p", "--testapp-path",
|
|
|
|
help="specifies path to the bbdev test app",
|
|
|
|
default=dpdk_path + "/" + dpdk_target + "/app/testbbdev")
|
|
|
|
parser.add_argument("-e", "--eal-params",
|
|
|
|
help="EAL arguments which are passed to the test app",
|
2018-04-26 14:31:14 +00:00
|
|
|
default="--vdev=baseband_null0")
|
2018-01-11 19:23:21 +00:00
|
|
|
parser.add_argument("-t", "--timeout",
|
|
|
|
type=int,
|
|
|
|
help="Timeout in seconds",
|
|
|
|
default=300)
|
|
|
|
parser.add_argument("-c", "--test-cases",
|
|
|
|
nargs="+",
|
|
|
|
help="Defines test cases to run. Run all if not specified")
|
|
|
|
parser.add_argument("-v", "--test-vector",
|
|
|
|
nargs="+",
|
|
|
|
help="Specifies paths to the test vector files.",
|
|
|
|
default=[dpdk_path +
|
2018-05-09 14:37:01 +00:00
|
|
|
"/app/test-bbdev/test_vectors/bbdev_null.data"])
|
2018-01-11 19:23:21 +00:00
|
|
|
parser.add_argument("-n", "--num-ops",
|
|
|
|
type=int,
|
|
|
|
help="Number of operations to process on device.",
|
|
|
|
default=32)
|
|
|
|
parser.add_argument("-b", "--burst-size",
|
|
|
|
nargs="+",
|
|
|
|
type=int,
|
|
|
|
help="Operations enqueue/dequeue burst size.",
|
|
|
|
default=[32])
|
|
|
|
parser.add_argument("-l", "--num-lcores",
|
|
|
|
type=int,
|
|
|
|
help="Number of lcores to run.",
|
|
|
|
default=16)
|
2019-07-03 15:24:09 +00:00
|
|
|
parser.add_argument("-i", "--init-device",
|
|
|
|
action='store_true',
|
|
|
|
help="Initialise PF device with default values.")
|
2018-01-11 19:23:21 +00:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if not os.path.exists(args.testapp_path):
|
2020-07-10 10:10:54 +00:00
|
|
|
print("No such file: " + args.testapp_path)
|
2018-01-11 19:23:21 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
params = [args.testapp_path]
|
|
|
|
if args.eal_params:
|
|
|
|
params.extend(shlex.split(args.eal_params))
|
|
|
|
|
|
|
|
params.extend(["--"])
|
|
|
|
|
|
|
|
if args.num_ops:
|
|
|
|
params.extend(["-n", str(args.num_ops)])
|
|
|
|
|
|
|
|
if args.num_lcores:
|
|
|
|
params.extend(["-l", str(args.num_lcores)])
|
|
|
|
|
|
|
|
if args.test_cases:
|
|
|
|
params.extend(["-c"])
|
|
|
|
params.extend([",".join(args.test_cases)])
|
|
|
|
|
2019-07-03 15:24:09 +00:00
|
|
|
if args.init_device:
|
|
|
|
params.extend(["-i"])
|
|
|
|
|
|
|
|
|
2018-01-11 19:23:21 +00:00
|
|
|
exit_status = 0
|
|
|
|
for vector in args.test_vector:
|
|
|
|
for burst_size in args.burst_size:
|
|
|
|
call_params = params[:]
|
|
|
|
call_params.extend(["-v", vector])
|
|
|
|
call_params.extend(["-b", str(burst_size)])
|
|
|
|
params_string = " ".join(call_params)
|
|
|
|
|
|
|
|
print("Executing: {}".format(params_string))
|
|
|
|
app_proc = subprocess.Popen(call_params)
|
|
|
|
if args.timeout > 0:
|
|
|
|
timer = Timer(args.timeout, kill, [app_proc])
|
|
|
|
timer.start()
|
|
|
|
|
|
|
|
try:
|
|
|
|
app_proc.communicate()
|
|
|
|
except:
|
|
|
|
print("Error: failed to execute: {}".format(params_string))
|
|
|
|
finally:
|
|
|
|
timer.cancel()
|
|
|
|
|
|
|
|
if app_proc.returncode != 0:
|
|
|
|
exit_status = 1
|
|
|
|
print("ERROR TestCase failed. Failed test for vector {}. Return code: {}".format(
|
|
|
|
vector, app_proc.returncode))
|
|
|
|
|
|
|
|
sys.exit(exit_status)
|