[augeas-devel] augeas: master - * src/augeas.h: expose flag to suppress module autoload
David Lutterkort
lutter at fedoraproject.org
Sat Apr 4 00:48:25 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=56d908f49129df50660c680b0532dced153a239a
Commit: 56d908f49129df50660c680b0532dced153a239a
Parent: ab50e343cda5d3f2fd44df9acc10a17e29de6192
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Fri Apr 3 16:45:33 2009 -0700
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Apr 3 16:45:33 2009 -0700
* src/augeas.h: expose flag to suppress module autoload
With AUG_NO_MODL_AUTOLOAD, modules are only loaded when they are needed.
---
src/augeas.h | 3 ++-
src/internal.h | 4 ----
tests/test-load.c | 26 ++++++++++++++++++++++++++
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/augeas.h b/src/augeas.h
index 5a146f1..9792bad 100644
--- a/src/augeas.h
+++ b/src/augeas.h
@@ -46,7 +46,8 @@ enum aug_flags {
modules */
AUG_SAVE_NOOP = (1 << 4), /* Make save a no-op process, just record
what would have changed */
- AUG_NO_LOAD = (1 << 5) /* Do not load the tree from AUG_INIT */
+ AUG_NO_LOAD = (1 << 5), /* Do not load the tree from AUG_INIT */
+ AUG_NO_MODL_AUTOLOAD = (1 << 6)
};
/* Function: aug_init
diff --git a/src/internal.h b/src/internal.h
index a2698b4..cc636ef 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -263,10 +263,6 @@ char* read_file(const char *path);
*/
const char *xstrerror(int errnum, char *buf, size_t len);
-/* A hidden flag used by augparse to suppress loading of all the modules
- * on the path */
-#define AUG_NO_MODL_AUTOLOAD (1 << 15)
-
/* Struct: augeas
* The data structure representing a connection to Augeas. */
struct augeas {
diff --git a/tests/test-load.c b/tests/test-load.c
index 4ca1fce..d3eb790 100644
--- a/tests/test-load.c
+++ b/tests/test-load.c
@@ -99,6 +99,31 @@ static void testNoLoad(CuTest *tc) {
aug_close(aug);
}
+static void testNoAutoload(CuTest *tc) {
+ augeas *aug = NULL;
+ int nmatches, r;
+
+ aug = aug_init(root, loadpath, AUG_NO_MODL_AUTOLOAD);
+ CuAssertPtrNotNull(tc, aug);
+
+ nmatches = aug_match(aug, "/augeas/load/*", NULL);
+ CuAssertZero(tc, nmatches);
+
+ r = aug_set(aug, "/augeas/load/Hosts/lens", "Hosts.lns");
+ CuAssertRetSuccess(tc, r);
+
+ r = aug_set(aug, "/augeas/load/Hosts/incl", "/etc/hosts");
+ CuAssertRetSuccess(tc, r);
+
+ r = aug_load(aug);
+ CuAssertRetSuccess(tc, r);
+
+ nmatches = aug_match(aug, "/files/etc/hosts/*[ipaddr]", NULL);
+ CuAssertIntEquals(tc, 2, nmatches);
+
+ aug_close(aug);
+}
+
static void invalidLens(CuTest *tc, augeas *aug, const char *lens) {
int r, nmatches;
@@ -140,6 +165,7 @@ int main(void) {
SUITE_ADD_TEST(suite, testDefault);
SUITE_ADD_TEST(suite, testNoLoad);
+ SUITE_ADD_TEST(suite, testNoAutoload);
SUITE_ADD_TEST(suite, testInvalidLens);
abs_top_srcdir = getenv("abs_top_srcdir");
More information about the augeas-devel
mailing list