From c6eae929fd74f11ab13d469a38bffd4e8ba50fb5 Mon Sep 17 00:00:00 2001 From: Nicolas Benech Date: Tue, 25 Sep 2018 14:37:16 -0400 Subject: gpu: nvgpu: posix: Multithreading for unit tests Add a -j argument to enable running unit tests on several threads. Also adds signal handling to prevent a fatal error in one thread from killing the whole unit test framework. JIRA NVGPU-1043 Change-Id: I891a547640cd005a50ffa5c06367ed46c54de012 Signed-off-by: Nicolas Benech Reviewed-on: https://git-master.nvidia.com/r/1847740 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- userspace/src/args.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'userspace/src/args.c') diff --git a/userspace/src/args.c b/userspace/src/args.c index d91c6f6e..cf17c983 100644 --- a/userspace/src/args.c +++ b/userspace/src/args.c @@ -36,11 +36,12 @@ static struct option core_opts[] = { { "no-color", 0, NULL, 'C' }, { "unit-load-path", 1, NULL, 'L' }, + { "num-threads", 1, NULL, 'j' }, { NULL, 0, NULL, 0 } }; -static const char *core_opts_str = "hvqCL:"; +static const char *core_opts_str = "hvqCL:j:"; void core_print_help(struct unit_fw *fw) { @@ -63,6 +64,8 @@ void core_print_help(struct unit_fw *fw) " corrupt that file.\n", " -L, --unit-load-path \n", " Path to where the unit test libraries reside.\n", +" -j, --num-threads \n", +" Number of threads to use while running all tests.\n", "\n", "Note: mandatory arguments to long arguments are mandatory for short\n", "arguments as well.\n", @@ -79,6 +82,7 @@ NULL static void set_arg_defaults(struct unit_fw_args *args) { args->unit_load_path = DEFAULT_ARG_UNIT_LOAD_PATH; + args->thread_count = 1; } /* @@ -121,6 +125,13 @@ int core_parse_args(struct unit_fw *fw, int argc, char **argv) case 'L': args->unit_load_path = optarg; break; + case 'j': + args->thread_count = strtol(optarg, NULL, 10); + if (args->thread_count == 0) { + core_err(fw, "Invalid number of threads\n"); + return -1; + } + break; case '?': args->help = true; return -1; -- cgit v1.2.2