summaryrefslogtreecommitdiffstats
path: root/userspace/src/args.c
diff options
context:
space:
mode:
authorNicolas Benech <nbenech@nvidia.com>2018-09-25 14:37:16 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-27 17:04:17 -0400
commitc6eae929fd74f11ab13d469a38bffd4e8ba50fb5 (patch)
tree12525d29aa8934cba58c703e67bf1aa8928ccacd /userspace/src/args.c
parent442cb2b1db40ae23bbcfda0624c0546da186694c (diff)
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 <nbenech@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1847740 Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'userspace/src/args.c')
-rw-r--r--userspace/src/args.c13
1 files changed, 12 insertions, 1 deletions
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[] = {
36 { "no-color", 0, NULL, 'C' }, 36 { "no-color", 0, NULL, 'C' },
37 37
38 { "unit-load-path", 1, NULL, 'L' }, 38 { "unit-load-path", 1, NULL, 'L' },
39 { "num-threads", 1, NULL, 'j' },
39 40
40 { NULL, 0, NULL, 0 } 41 { NULL, 0, NULL, 0 }
41}; 42};
42 43
43static const char *core_opts_str = "hvqCL:"; 44static const char *core_opts_str = "hvqCL:j:";
44 45
45void core_print_help(struct unit_fw *fw) 46void core_print_help(struct unit_fw *fw)
46{ 47{
@@ -63,6 +64,8 @@ void core_print_help(struct unit_fw *fw)
63" corrupt that file.\n", 64" corrupt that file.\n",
64" -L, --unit-load-path <PATH>\n", 65" -L, --unit-load-path <PATH>\n",
65" Path to where the unit test libraries reside.\n", 66" Path to where the unit test libraries reside.\n",
67" -j, --num-threads <COUNT>\n",
68" Number of threads to use while running all tests.\n",
66"\n", 69"\n",
67"Note: mandatory arguments to long arguments are mandatory for short\n", 70"Note: mandatory arguments to long arguments are mandatory for short\n",
68"arguments as well.\n", 71"arguments as well.\n",
@@ -79,6 +82,7 @@ NULL
79static void set_arg_defaults(struct unit_fw_args *args) 82static void set_arg_defaults(struct unit_fw_args *args)
80{ 83{
81 args->unit_load_path = DEFAULT_ARG_UNIT_LOAD_PATH; 84 args->unit_load_path = DEFAULT_ARG_UNIT_LOAD_PATH;
85 args->thread_count = 1;
82} 86}
83 87
84/* 88/*
@@ -121,6 +125,13 @@ int core_parse_args(struct unit_fw *fw, int argc, char **argv)
121 case 'L': 125 case 'L':
122 args->unit_load_path = optarg; 126 args->unit_load_path = optarg;
123 break; 127 break;
128 case 'j':
129 args->thread_count = strtol(optarg, NULL, 10);
130 if (args->thread_count == 0) {
131 core_err(fw, "Invalid number of threads\n");
132 return -1;
133 }
134 break;
124 case '?': 135 case '?':
125 args->help = true; 136 args->help = true;
126 return -1; 137 return -1;