Esempio n. 1
0
static
void
check_line(int fd, const char *exp)
{
    char *line = atf_utils_readline(fd);
    ATF_CHECK(line != NULL);
    ATF_CHECK_STREQ_MSG(exp, line, "read: '%s', expected: '%s'", line, exp);
    free(line);
}
Esempio n. 2
0
ATF_TC_BODY(t_crypto_md5, tc)
{
	const char *digest;
	int i;

	for (i = 0; i < MD5_TEST_CASES; i++) {
		digest = saslc__crypto_md5_hex(md5_test_cases[i].in,
		    strlen(md5_test_cases[i].in));
		ATF_CHECK_STREQ_MSG(digest, md5_test_cases[i].out,
		    "saslc__crypto_md5_hex() failed on %s got %s should be: %s",
		    md5_test_cases[i].in, digest, md5_test_cases[i].out);
		free((void *)digest);
	}
}
Esempio n. 3
0
ATF_TC_BODY(t_crypto_base64, tc)
{
	char *enc;
	size_t enclen;
	int i;

	for (i = 0; i < BASE64_TEST_CASES; i++) {
		saslc__crypto_encode_base64(base64_test_cases[i].in,
		    base64_test_cases[i].len, &enc, &enclen);
		ATF_CHECK_STREQ_MSG(enc, base64_test_cases[i].out,
		    "saslc__crypto_encode_base64() failed on %s got %s should be: %s",
		    base64_test_cases[i].in, enc, base64_test_cases[i].out);
		free((void *)enc);
	}
}
Esempio n. 4
0
ATF_TC_BODY(getopt, tc)
{
    /* Provide an option that is unknown to the test program driver and
     * one that is, together with an argument that would be swallowed by
     * the test program option if it were recognized. */
    int argc = 4;
    char arg1[] = "progname";
    char arg2[] = "-Z";
    char arg3[] = "-s";
    char arg4[] = "foo";
    char *const argv[] = { arg1, arg2, arg3, arg4, NULL };

    int ch;
    bool zflag;

    /* Given that this obviously is a test program, and that we used the
     * same driver to start, we can test getopt(3) right here without doing
     * any fancy stuff. */
    zflag = false;
    while ((ch = getopt(argc, argv, ":Z")) != -1) {
        switch (ch) {
        case 'Z':
            zflag = true;
            break;

        case '?':
        default:
            if (optopt != 's')
                atf_tc_fail("Unexpected unknown option -%c found", optopt);
        }
    }

    ATF_REQUIRE(zflag);
    ATF_REQUIRE_EQ_MSG(1, argc - optind, "Invalid number of arguments left "
        "after the call to getopt(3)");
    ATF_CHECK_STREQ_MSG("foo", argv[optind], "The non-option argument is "
        "invalid");
}
Esempio n. 5
0
static void
run_test(struct ldexp_test *table)
{
	char outbuf[64];
	size_t i;
	double v;

	for (i = 0; table->result != NULL; table++, i++) {

		v = ldexp(table->x, table->exp1);

		if (table->exp2 == SKIP)
			continue;

		v = ldexp(v, table->exp2);

		(void)snprintf(outbuf, sizeof(outbuf), FORMAT, v);

		ATF_CHECK_STREQ_MSG(table->result, outbuf,
			    "Entry %zu:\n\tExp: \"%s\"\n\tAct: \"%s\"",
			    i, table->result, outbuf);
	}
}