mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 01:16:18 +00:00
lib: remove handled option arguments from argv
Remove options from argv that have been handled by getopt to allow additional non-option parameters to be processed in the test application. This fixes issues when using options such as --debug with tests that accept additional non-option parameters. Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
55cc132b32
commit
8fb19782f8
@ -487,7 +487,7 @@ static void oom_adjust_for_doom(void)
|
|||||||
low_mem_killer_disable(true);
|
low_mem_killer_disable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int common_init(int argc, char **argv,
|
static int common_init(int *argc, char **argv,
|
||||||
const char *extra_short_opts,
|
const char *extra_short_opts,
|
||||||
struct option *extra_long_opts,
|
struct option *extra_long_opts,
|
||||||
const char *help_str,
|
const char *help_str,
|
||||||
@ -582,7 +582,7 @@ static int common_init(int argc, char **argv,
|
|||||||
std_short_opts);
|
std_short_opts);
|
||||||
assert(ret >= 0);
|
assert(ret >= 0);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, short_opts, combined_opts,
|
while ((c = getopt_long(*argc, argv, short_opts, combined_opts,
|
||||||
&option_index)) != -1) {
|
&option_index)) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case OPT_INTERACTIVE_DEBUG:
|
case OPT_INTERACTIVE_DEBUG:
|
||||||
@ -655,6 +655,11 @@ out:
|
|||||||
if (!test_with_subtests)
|
if (!test_with_subtests)
|
||||||
gettime(&subtest_time);
|
gettime(&subtest_time);
|
||||||
|
|
||||||
|
for (i = 0; (optind + i) < *argc; i++)
|
||||||
|
argv[i + 1] = argv[optind + i];
|
||||||
|
|
||||||
|
*argc = *argc - optind + 1;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,7 +683,7 @@ out:
|
|||||||
*
|
*
|
||||||
* Returns: Forwards any option parsing errors from getopt_long.
|
* Returns: Forwards any option parsing errors from getopt_long.
|
||||||
*/
|
*/
|
||||||
int igt_subtest_init_parse_opts(int argc, char **argv,
|
int igt_subtest_init_parse_opts(int *argc, char **argv,
|
||||||
const char *extra_short_opts,
|
const char *extra_short_opts,
|
||||||
struct option *extra_long_opts,
|
struct option *extra_long_opts,
|
||||||
const char *help_str,
|
const char *help_str,
|
||||||
@ -707,7 +712,7 @@ enum igt_log_level igt_log_level = IGT_LOG_INFO;
|
|||||||
* This initializes a simple test without any support for subtests and allows
|
* This initializes a simple test without any support for subtests and allows
|
||||||
* an arbitrary set of additional options.
|
* an arbitrary set of additional options.
|
||||||
*/
|
*/
|
||||||
void igt_simple_init_parse_opts(int argc, char **argv,
|
void igt_simple_init_parse_opts(int *argc, char **argv,
|
||||||
const char *extra_short_opts,
|
const char *extra_short_opts,
|
||||||
struct option *extra_long_opts,
|
struct option *extra_long_opts,
|
||||||
const char *help_str,
|
const char *help_str,
|
||||||
|
@ -110,7 +110,7 @@ typedef int (*igt_opt_handler_t)(int opt, int opt_index);
|
|||||||
#ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
|
#ifndef __GTK_DOC_IGNORE__ /* gtkdoc wants to document this forward decl */
|
||||||
struct option;
|
struct option;
|
||||||
#endif
|
#endif
|
||||||
int igt_subtest_init_parse_opts(int argc, char **argv,
|
int igt_subtest_init_parse_opts(int *argc, char **argv,
|
||||||
const char *extra_short_opts,
|
const char *extra_short_opts,
|
||||||
struct option *extra_long_opts,
|
struct option *extra_long_opts,
|
||||||
const char *help_str,
|
const char *help_str,
|
||||||
@ -130,7 +130,7 @@ int igt_subtest_init_parse_opts(int argc, char **argv,
|
|||||||
* #igt_main block instead of stitching the test's main() function together
|
* #igt_main block instead of stitching the test's main() function together
|
||||||
* manually.
|
* manually.
|
||||||
*/
|
*/
|
||||||
#define igt_subtest_init(argc, argv) igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
|
#define igt_subtest_init(argc, argv) igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
bool __igt_run_subtest(const char *subtest_name);
|
bool __igt_run_subtest(const char *subtest_name);
|
||||||
#define __igt_tokencat2(x, y) x ## y
|
#define __igt_tokencat2(x, y) x ## y
|
||||||
@ -195,14 +195,14 @@ bool igt_only_list_subtests(void);
|
|||||||
#define igt_main \
|
#define igt_main \
|
||||||
static void igt_tokencat(__real_main, __LINE__)(void); \
|
static void igt_tokencat(__real_main, __LINE__)(void); \
|
||||||
int main(int argc, char **argv) { \
|
int main(int argc, char **argv) { \
|
||||||
igt_subtest_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
|
igt_subtest_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL); \
|
||||||
igt_tokencat(__real_main, __LINE__)(); \
|
igt_tokencat(__real_main, __LINE__)(); \
|
||||||
igt_exit(); \
|
igt_exit(); \
|
||||||
} \
|
} \
|
||||||
static void igt_tokencat(__real_main, __LINE__)(void) \
|
static void igt_tokencat(__real_main, __LINE__)(void) \
|
||||||
|
|
||||||
|
|
||||||
void igt_simple_init_parse_opts(int argc, char **argv,
|
void igt_simple_init_parse_opts(int *argc, char **argv,
|
||||||
const char *extra_short_opts,
|
const char *extra_short_opts,
|
||||||
struct option *extra_long_opts,
|
struct option *extra_long_opts,
|
||||||
const char *help_str,
|
const char *help_str,
|
||||||
@ -219,7 +219,7 @@ void igt_simple_init_parse_opts(int argc, char **argv,
|
|||||||
* #igt_simple_main block instead of stitching the test's main() function together
|
* #igt_simple_main block instead of stitching the test's main() function together
|
||||||
* manually.
|
* manually.
|
||||||
*/
|
*/
|
||||||
#define igt_simple_init(argc, argv) igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL);
|
#define igt_simple_init(argc, argv) igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* igt_simple_main:
|
* igt_simple_main:
|
||||||
@ -231,7 +231,7 @@ void igt_simple_init_parse_opts(int argc, char **argv,
|
|||||||
#define igt_simple_main \
|
#define igt_simple_main \
|
||||||
static void igt_tokencat(__real_main, __LINE__)(void); \
|
static void igt_tokencat(__real_main, __LINE__)(void); \
|
||||||
int main(int argc, char **argv) { \
|
int main(int argc, char **argv) { \
|
||||||
igt_simple_init_parse_opts(argc, argv, NULL, NULL, NULL, NULL); \
|
igt_simple_init_parse_opts(&argc, argv, NULL, NULL, NULL, NULL); \
|
||||||
igt_tokencat(__real_main, __LINE__)(); \
|
igt_tokencat(__real_main, __LINE__)(); \
|
||||||
igt_exit(); \
|
igt_exit(); \
|
||||||
} \
|
} \
|
||||||
|
@ -32,8 +32,9 @@ int main(int argc, char **argv)
|
|||||||
char prog[] = "igt_list_only";
|
char prog[] = "igt_list_only";
|
||||||
char arg[] = "--list-subtests";
|
char arg[] = "--list-subtests";
|
||||||
char *fake_argv[] = {prog, arg};
|
char *fake_argv[] = {prog, arg};
|
||||||
|
int fake_argc = 2;
|
||||||
|
|
||||||
igt_subtest_init(2, fake_argv);
|
igt_subtest_init(fake_argc, fake_argv);
|
||||||
|
|
||||||
igt_subtest("A")
|
igt_subtest("A")
|
||||||
;
|
;
|
||||||
|
@ -31,8 +31,9 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char prog[] = "igt_no_exit";
|
char prog[] = "igt_no_exit";
|
||||||
char *fake_argv[] = {prog};
|
char *fake_argv[] = {prog};
|
||||||
|
int fake_argc = 1;
|
||||||
|
|
||||||
igt_subtest_init(1, fake_argv);
|
igt_subtest_init(fake_argc, fake_argv);
|
||||||
|
|
||||||
igt_subtest("A")
|
igt_subtest("A")
|
||||||
;
|
;
|
||||||
|
@ -32,8 +32,9 @@ int main(int argc, char **argv)
|
|||||||
char prog[] = "igt_list_only";
|
char prog[] = "igt_list_only";
|
||||||
char arg[] = "--list-subtests";
|
char arg[] = "--list-subtests";
|
||||||
char *fake_argv[] = {prog, arg};
|
char *fake_argv[] = {prog, arg};
|
||||||
|
int fake_argc = 2;
|
||||||
|
|
||||||
igt_subtest_init(2, fake_argv);
|
igt_subtest_init(fake_argc, fake_argv);
|
||||||
|
|
||||||
igt_subtest("A")
|
igt_subtest("A")
|
||||||
;
|
;
|
||||||
|
@ -31,8 +31,9 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char prog[] = "igt_no_exit";
|
char prog[] = "igt_no_exit";
|
||||||
char *fake_argv[] = {prog};
|
char *fake_argv[] = {prog};
|
||||||
|
int fake_argc = 1;
|
||||||
|
|
||||||
igt_subtest_init(1, fake_argv);
|
igt_subtest_init(fake_argc, fake_argv);
|
||||||
|
|
||||||
igt_exit();
|
igt_exit();
|
||||||
}
|
}
|
||||||
|
@ -55,22 +55,27 @@ char *argv_run[] = { test };
|
|||||||
static int do_fork(void)
|
static int do_fork(void)
|
||||||
{
|
{
|
||||||
int pid, status;
|
int pid, status;
|
||||||
|
int argc;
|
||||||
|
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
internal_assert(0);
|
internal_assert(0);
|
||||||
case 0:
|
case 0:
|
||||||
if (simple) {
|
if (simple) {
|
||||||
igt_simple_init(1, argv_run);
|
argc = 1;
|
||||||
|
igt_simple_init(argc, argv_run);
|
||||||
|
|
||||||
igt_skip_on_simulation();
|
igt_skip_on_simulation();
|
||||||
|
|
||||||
igt_exit();
|
igt_exit();
|
||||||
} else {
|
} else {
|
||||||
if (list_subtests)
|
if (list_subtests) {
|
||||||
igt_subtest_init(2, argv_list);
|
argc = 2;
|
||||||
else
|
igt_subtest_init(argc, argv_list);
|
||||||
igt_subtest_init(1, argv_run);
|
} else {
|
||||||
|
argc = 1;
|
||||||
|
igt_subtest_init(argc, argv_run);
|
||||||
|
}
|
||||||
|
|
||||||
if (in_fixture) {
|
if (in_fixture) {
|
||||||
igt_fixture
|
igt_fixture
|
||||||
|
@ -144,7 +144,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
igt_simple_init_parse_opts(argc, argv, "i:c:n:mu", NULL, NULL,
|
igt_simple_init_parse_opts(&argc, argv, "i:c:n:mu", NULL, NULL,
|
||||||
opt_handler);
|
opt_handler);
|
||||||
|
|
||||||
fd = drm_open_any_render();
|
fd = drm_open_any_render();
|
||||||
|
@ -141,7 +141,7 @@ int main(int argc, char **argv)
|
|||||||
igt_render_copyfunc_t render_copy = NULL;
|
igt_render_copyfunc_t render_copy = NULL;
|
||||||
int opt_dump_aub = igt_aub_dump_enabled();
|
int opt_dump_aub = igt_aub_dump_enabled();
|
||||||
|
|
||||||
igt_simple_init_parse_opts(argc, argv, "da", NULL, NULL, opt_handler);
|
igt_simple_init_parse_opts(&argc, argv, "da", NULL, NULL, opt_handler);
|
||||||
|
|
||||||
igt_fixture {
|
igt_fixture {
|
||||||
data.drm_fd = drm_open_any_render();
|
data.drm_fd = drm_open_any_render();
|
||||||
|
@ -503,7 +503,7 @@ int main(int argc, char **argv)
|
|||||||
options.prewrap_space = 21;
|
options.prewrap_space = 21;
|
||||||
options.buffers = 10;
|
options.buffers = 10;
|
||||||
|
|
||||||
igt_simple_init_parse_opts(argc, argv, "n:bvt:dp:ri:", long_options,
|
igt_simple_init_parse_opts(&argc, argv, "n:bvt:dp:ri:", long_options,
|
||||||
help, parse_options);
|
help, parse_options);
|
||||||
|
|
||||||
card_index = drm_get_card();
|
card_index = drm_get_card();
|
||||||
|
@ -854,7 +854,7 @@ int main(int argc, char **argv)
|
|||||||
options.tiles_per_buf = options.scratch_buf_size / TILE_BYTES(options.tile_size);
|
options.tiles_per_buf = options.scratch_buf_size / TILE_BYTES(options.tile_size);
|
||||||
options.check_render_cpyfn = 0;
|
options.check_render_cpyfn = 0;
|
||||||
|
|
||||||
igt_simple_init_parse_opts(argc, argv,"ds:g:c:t:rbuxmo:fp:",
|
igt_simple_init_parse_opts(&argc, argv,"ds:g:c:t:rbuxmo:fp:",
|
||||||
long_options, NULL, parse_options);
|
long_options, NULL, parse_options);
|
||||||
|
|
||||||
drm_fd = drm_open_any();
|
drm_fd = drm_open_any();
|
||||||
|
@ -489,7 +489,7 @@ int main(int argc, char *argv[])
|
|||||||
data_t data = {};
|
data_t data = {};
|
||||||
enum operations op;
|
enum operations op;
|
||||||
|
|
||||||
igt_subtest_init_parse_opts(argc, argv, "", long_options,
|
igt_subtest_init_parse_opts(&argc, argv, "", long_options,
|
||||||
help_str, opt_handler);
|
help_str, opt_handler);
|
||||||
igt_skip_on_simulation();
|
igt_skip_on_simulation();
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ int main(int argc, char **argv)
|
|||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = igt_subtest_init_parse_opts(argc, argv, "dt:", NULL, help_str,
|
ret = igt_subtest_init_parse_opts(&argc, argv, "dt:", NULL, help_str,
|
||||||
opt_handler);
|
opt_handler);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret == -1 ? 0 : ret;
|
return ret == -1 ? 0 : ret;
|
||||||
|
@ -1811,7 +1811,7 @@ int main(int argc, char *argv[])
|
|||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
igt_subtest_init_parse_opts(argc, argv, "", long_options,
|
igt_subtest_init_parse_opts(&argc, argv, "", long_options,
|
||||||
help_str, opt_handler);
|
help_str, opt_handler);
|
||||||
|
|
||||||
/* Skip instead of failing in case the machine is not prepared to reach
|
/* Skip instead of failing in case the machine is not prepared to reach
|
||||||
|
Loading…
x
Reference in New Issue
Block a user