Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config file read for lua tests #509

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sb_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ option_t *sb_find_option(const char *name)
return find_option(&options, name);
}

static void read_config_file(const char *filename)
int read_config_file(const char *filename)
{
/* read config options from file */
FILE *fp = fopen(filename, "r");
Expand All @@ -122,6 +122,7 @@ static void read_config_file(const char *filename)
read_config(fp, &options);
fclose(fp);
}
return 1;
}

option_t *set_option(const char *name, const char *value, sb_arg_type_t type)
Expand Down Expand Up @@ -175,6 +176,7 @@ option_t *set_option(const char *name, const char *value, sb_arg_type_t type)

break;
case SB_ARG_TYPE_FILE:
add_value(&opt->values, value);
read_config_file(value);
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions src/sb_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ int remove_option(sb_list_t *, char *);

sb_list_t *read_config(FILE *, sb_list_t *);

+int read_config_file(const char *filename);
+
int write_config(FILE *, sb_list_t *);

#endif /* OPTIONS_H */
Expand Down
7 changes: 7 additions & 0 deletions src/sysbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@ int main(int argc, char *argv[])
{
sb_test_t *test = NULL;
int rc;
char * filename;

sb_globals.argc = argc;
sb_globals.argv = malloc(argc * sizeof(char *));
Expand Down Expand Up @@ -1523,6 +1524,12 @@ int main(int argc, char *argv[])
if (parse_test_arguments(test, argc, argv))
return EXIT_FAILURE;

/* If a config file was used, re-read it to pickup the test-specific options */
if ((filename = sb_get_value_string("config-file")) != NULL) {
read_config_file(filename);
}


if (sb_lua_loaded() && sb_lua_custom_command_defined(sb_globals.cmdname))
{
rc = sb_lua_call_custom_command(sb_globals.cmdname);
Expand Down