static void testUmask(CuTest *tc, int tumask, mode_t expected_mode) {
    int r;
    struct stat buf;
    char* fpath = NULL;

    if (asprintf(&fpath, "%s/etc/test", root) < 0) {
        CuFail(tc, "failed to set root");
    }

    umask(tumask);

    r = aug_rm(aug, "/augeas/load/*");
    CuAssertPositive(tc, r);

    r = aug_set(aug, "/augeas/load/Test/lens", "Simplelines.lns");
    CuAssertRetSuccess(tc, r);
    r = aug_set(aug, "/augeas/load/Test/incl", "/etc/test");
    CuAssertRetSuccess(tc, r);
    r = aug_load(aug);
    CuAssertRetSuccess(tc, r);
    r = aug_set(aug, "/files/etc/test/1", "test");
    CuAssertRetSuccess(tc, r);

    r = aug_save(aug);
    CuAssertRetSuccess(tc, r);
    r = aug_match(aug, "/augeas//error", NULL);
    CuAssertIntEquals(tc, 0, r);

    CuAssertIntEquals(tc, 0, stat(fpath, &buf));
    CuAssertIntEquals(tc, expected_mode, buf.st_mode & 0777);
}
static void testUmask(CuTest *tc, int tumask, mode_t expected_mode) {
    int r;
    struct stat buf;
    char* fpath = NULL;

    if (asprintf(&fpath, "%s/etc/test", root) < 0) {
        CuFail(tc, "failed to set root");
    }

    umask(tumask);

    r = aug_rm(aug, "/augeas/load/*");
    CuAssertPositive(tc, r);

    r = aug_set(aug, "/augeas/load/Test/lens", "Simplelines.lns");
    CuAssertRetSuccess(tc, r);
    r = aug_set(aug, "/augeas/load/Test/incl", "/etc/test");
    CuAssertRetSuccess(tc, r);
    r = aug_load(aug);
    CuAssertRetSuccess(tc, r);
    r = aug_set(aug, "/files/etc/test/1", "test");
    CuAssertRetSuccess(tc, r);

    r = aug_save(aug);
    CuAssertRetSuccess(tc, r);
    r = aug_match(aug, "/augeas//error", NULL);
    CuAssertIntEquals(tc, 0, r);

    CuAssertIntEquals(tc, 0, stat(fpath, &buf));
    CuAssertIntEquals(tc, expected_mode, buf.st_mode & 0777);
}