Skip to content

Commit

Permalink
fixup tests: avoid loading sconfdir conf
Browse files Browse the repository at this point in the history
  • Loading branch information
dacav committed Jan 3, 2025
1 parent dae6bfb commit 1e9bb39
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,25 @@ static int str_opt_cmp(const char *s1, const char *s2) {
static void test_regular(void) {
// Ensure that all configuration options are loaded into the configuration:

const char *argv[] = {"prompt=hi",
const char *argv[] = {NULL,
"debug", // So we have a log file for the test
NULL};
"prompt=hi"};

struct conf_file cf;
int r;
cfg_t cfg, cfg_defaults;

conf_file_init(&cf, NULL);
argv[0] = cf.arg;

// 1. Load the default
r = cfg_init(&cfg_defaults, 0, 0, NULL);
r = cfg_init(&cfg_defaults, 0, 1, argv);
assert(r == PAM_SUCCESS);

// 2. Write the configuration file, changing every field.
conf_file_init(&cf, NULL);
config_flip_all(&cf, &cfg_defaults);

// 3. Load from the file
argv[2] = cf.arg;
r = cfg_init(&cfg, 0, sizeof(argv) / sizeof(*argv), argv);
assert(r == PAM_SUCCESS);
conf_file_clear(&cf);
Expand Down Expand Up @@ -333,12 +334,12 @@ static void test_file_parser(void) {
struct conf_file cf;
int r;

r = cfg_init(&cfg_defaults, 0, 0, NULL);
assert(r == PAM_SUCCESS);

conf_file_init(&cf, NULL);
argv[0] = cf.arg;

r = cfg_init(&cfg_defaults, 0, 1, argv);
assert(r == PAM_SUCCESS);

// Defaults are unlikely to change, but if they do
// the test might be invalidated.
assert(!cfg_defaults.alwaysok);
Expand Down

0 comments on commit 1e9bb39

Please sign in to comment.