test/read_conf: validate the setting name early
This commit is contained in:
parent
0ff0aca2e2
commit
1a82981d07
@ -22,6 +22,7 @@
|
|||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "util/PrintException.hxx"
|
#include "util/PrintException.hxx"
|
||||||
|
#include "util/RuntimeError.hxx"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -37,14 +38,15 @@ try {
|
|||||||
const Path config_path = Path::FromFS(argv[1]);
|
const Path config_path = Path::FromFS(argv[1]);
|
||||||
const char *name = argv[2];
|
const char *name = argv[2];
|
||||||
|
|
||||||
|
const auto option = ParseConfigOptionName(name);
|
||||||
|
if (option == ConfigOption::MAX)
|
||||||
|
throw FormatRuntimeError("Unknown setting: %s", name);
|
||||||
|
|
||||||
config_global_init();
|
config_global_init();
|
||||||
|
|
||||||
ReadConfigFile(config_path);
|
ReadConfigFile(config_path);
|
||||||
|
|
||||||
ConfigOption option = ParseConfigOptionName(name);
|
const char *value = config_get_string(option);
|
||||||
const char *value = option != ConfigOption::MAX
|
|
||||||
? config_get_string(option)
|
|
||||||
: nullptr;
|
|
||||||
int ret;
|
int ret;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
printf("%s\n", value);
|
printf("%s\n", value);
|
||||||
|
Loading…
Reference in New Issue
Block a user