/*
* test-run.c: test the aug_srun API function
*
- * Copyright (C) 2009-2015 David Lutterkort
+ * Copyright (C) 2009-2016 David Lutterkort
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
bool out_present;
};
+static void free_tests(struct test *test) {
+ if (test == NULL)
+ return;
+ free_tests(test->next);
+ free(test->name);
+ free(test->module);
+ free(test->cmd);
+ free(test->out);
+ free(test);
+}
+
#define die(msg) \
do { \
fprintf(stderr, "%d: Fatal error: %s\n", __LINE__, msg); \
}
static struct test *read_tests(void) {
- char *fname;
+ char *fname = NULL;
FILE *fp;
char line[BUFSIZ];
struct test *result = NULL, *t = NULL;
if (t->out != NULL)
t->out_present = true;
}
+ free(fname);
return result;
}
static int load_module(struct augeas *aug, struct test *test) {
char *fname, *fpath;
- int r;
+ int r, result = -1;
if (test->module == NULL)
return 0;
r = __aug_load_module_file(aug, fpath);
fail(r < 0, "Could not load %s", fpath);
-
- return 0;
+ result = 0;
error:
- return -1;
+ free(fname);
+ free(fpath);
+ return result;
}
static int run_one_test(struct test *test) {
MEMZERO(&ms, 1);
- aug = aug_init("/dev/null", lensdir, AUG_NO_STDINC|AUG_NO_MODL_AUTOLOAD);
+ aug = aug_init("/dev/null", lensdir,
+ AUG_NO_STDINC|AUG_NO_MODL_AUTOLOAD|AUG_ENABLE_SPAN);
fail(aug == NULL, "aug_init");
fail(aug_error(aug) != AUG_NOERROR, "aug_init: errcode was %d",
aug_error(aug));
die("out of memory setting lensdir");
tests = read_tests();
- return run_tests(tests, argc - 1, argv + 1);
+ int result = run_tests(tests, argc - 1, argv + 1);
+ free_tests(tests);
+ return result;
}
/*