Beispiel #1
0
/* Demonstrates misfeature of original design */
static void test_aliasing_toupper(void **state)
{
    char *abc = ToUpperStr("abc");
    char *def = ToUpperStr("def");

    assert_string_equal(abc, "DEF");
    assert_string_equal(def, "DEF");
}
Beispiel #2
0
static void test_hi_alphabet_toupper(void **state)
{
    assert_string_equal(ToUpperStr(hi_alphabet), hi_alphabet);
}
Beispiel #3
0
static void test_weird_chars_toupper(void **state)
{
    static const char *weirdstuff = "1345\0xff%$#@!";

    assert_string_equal(ToUpperStr(weirdstuff), weirdstuff);
}
Beispiel #4
0
static void test_empty_toupper(void **state)
{
    assert_string_equal(ToUpperStr(""), "");
}
Beispiel #5
0
static void test_mix_case_toupper(void **state)
{
    assert_string_equal(ToUpperStr("aBcD"), "ABCD");
}
Beispiel #6
0
int VerifyInFstab(char *name, Attributes a, Promise *pp)
/* Ensure filesystem IS in fstab, and return no of changes */
{
    char fstab[CF_BUFSIZE];
    char *host, *rmountpt, *mountpt, *fstype, *opts;

    if (!FSTABLIST)
    {
        if (!LoadFileAsItemList(&FSTABLIST, VFSTAB[VSYSTEMHARDCLASS], a, pp))
        {
            CfOut(cf_error, "", "Couldn't open %s!\n", VFSTAB[VSYSTEMHARDCLASS]);
            return false;
        }
        else
        {
            FSTAB_EDITS = 0;
        }
    }

    if (a.mount.mount_options)
    {
        opts = Rlist2String(a.mount.mount_options, ",");
    }
    else
    {
        opts = xstrdup(VMOUNTOPTS[VSYSTEMHARDCLASS]);
    }

    host = a.mount.mount_server;
    rmountpt = a.mount.mount_source;
    mountpt = name;
    fstype = a.mount.mount_type;

    switch (VSYSTEMHARDCLASS)
    {
    case osf:
    case bsd4_3:
    case irix:
    case irix4:
    case irix64:
    case sun3:
    case aos:
    case nextstep:
    case newsos:
    case qnx:
    case sun4:
        snprintf(fstab, CF_BUFSIZE, "%s:%s \t %s %s\t%s 0 0", host, rmountpt, mountpt, fstype, opts);
        break;

    case crayos:
        snprintf(fstab, CF_BUFSIZE, "%s:%s \t %s %s\t%s", host, rmountpt, mountpt, ToUpperStr(fstype), opts);
        break;
    case ultrx:                //snprintf(fstab,CF_BUFSIZE,"%s@%s:%s:%s:0:0:%s:%s",rmountpt,host,mountpt,mode,fstype,opts);
        break;
    case hp:
        snprintf(fstab, CF_BUFSIZE, "%s:%s %s \t %s \t %s 0 0", host, rmountpt, mountpt, fstype, opts);
        break;
    case aix:
        snprintf(fstab, CF_BUFSIZE,
                 "%s:\n\tdev\t= %s\n\ttype\t= %s\n\tvfs\t= %s\n\tnodename\t= %s\n\tmount\t= true\n\toptions\t= %s\n\taccount\t= false\n",
                 mountpt, rmountpt, fstype, fstype, host, opts);
        break;
    case GnU:
    case linuxx:
        snprintf(fstab, CF_BUFSIZE, "%s:%s \t %s \t %s \t %s", host, rmountpt, mountpt, fstype, opts);
        break;

    case netbsd:
    case openbsd:
    case bsd_i:
    case dragonfly:
    case freebsd:
        snprintf(fstab, CF_BUFSIZE, "%s:%s \t %s \t %s \t %s 0 0", host, rmountpt, mountpt, fstype, opts);
        break;

    case unix_sv:
    case solaris:
        snprintf(fstab, CF_BUFSIZE, "%s:%s - %s %s - yes %s", host, rmountpt, mountpt, fstype, opts);
        break;

    case cfnt:
        snprintf(fstab, CF_BUFSIZE, "/bin/mount %s:%s %s", host, rmountpt, mountpt);
        break;
    case cfsco:
        CfOut(cf_error, "", "Don't understand filesystem format on SCO, no data - please fix me");
        break;

    case unused1:
    case unused2:
    case unused3:
    default:
        free(opts);
        return false;
    }

    CfOut(cf_verbose, "", "Verifying %s in %s\n", mountpt, VFSTAB[VSYSTEMHARDCLASS]);

    if (!MatchFSInFstab(mountpt))
    {
        AppendItem(&FSTABLIST, fstab, NULL);
        FSTAB_EDITS++;
        cfPS(cf_inform, CF_CHG, "", pp, a, "Adding file system %s:%s seems to %s.\n", host, rmountpt,
             VFSTAB[VSYSTEMHARDCLASS]);
    }

    free(opts);
    return 0;
}