/*
* test-save.c: test various aspects of saving
*
- * 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
run(tc, "chmod -R u+w %s", root);
aug = aug_init(root, lensdir, AUG_NO_STDINC);
+ free(lensdir);
CuAssertPtrNotNull(tc, aug);
}
r = aug_set(aug, "/files/etc/yum.repos.d/fedora.repo/fedora/enabled", "0");
CuAssertIntEquals(tc, 0, r);
+ /* What we have set up is fine: two ways to save the same file with the
+ same lens */
+ r = aug_save(aug);
+ CuAssertIntEquals(tc, 0, r);
+
+ /* Now we make it bad: a different lens for the same file */
+ r = aug_set(aug, "/augeas/load/Yum2/lens", "@Subversion");
+ CuAssertIntEquals(tc, 0, r);
+
+ r = aug_set(aug, "/files/etc/yum.repos.d/fedora.repo/fedora/enabled", "1");
+ CuAssertIntEquals(tc, 0, r);
r = aug_save(aug);
CuAssertIntEquals(tc, -1, r);
+
r = aug_error(aug);
CuAssertIntEquals(tc, AUG_EMXFM, r);
}
CuAssertStrNotEqual(tc, mtime1, mtime2);
CuAssertStrNotEqual(tc, "0", mtime2);
+ free(mtime1);
}
/* Check that loading and saving a file given with a relative path
CuAssertIntEquals(tc, 0, stat(fpath, &buf));
CuAssertIntEquals(tc, expected_mode, buf.st_mode & 0777);
+ free(fpath);
}
static void testUmask077(CuTest *tc) {
testUmask(tc, 0077, 0600);
r = access(fname, R_OK);
CuAssertIntEquals(tc, -1, r);
CuAssertIntEquals(tc, ENOENT, errno);
+
+ free(s);
+ free(fname);
}
/* Test that we handle failure to save a file because we lack permission on
r = aug_get(aug, "/augeas/files/etc/hosts/error", &v);
CuAssertIntEquals(tc, 1, r);
CuAssertStrEquals(tc, "replace_from_missing", v);
+ free(path);
}
int main(void) {
CuSuiteDetails(suite, &output);
printf("%s\n", output);
free(output);
- return suite->failCount;
+ int result = suite->failCount;
+ CuSuiteFree(suite);
+ return result;
}
/*