Beispiel #1
0
int
main(int argc, char **argv)
{
    char *ptr;
    int count;


    if (argc != 2)
	usage(1);

    verbose_fp = fdopen(4, "w");
    if (verbose_fp == NULL) {
	verbose_fp = fopen("/dev/null", "w");
	if (verbose_fp == NULL)
	    err(1, "fopen");
    }

    count = strtol(argv[1], &ptr, 0);
    if (count == 0 && ptr == argv[1])
	errx(1, "'%s' not a number", argv[1]);

    return creat_symlinks(count) || verify_contents(count);
}
Beispiel #2
0
int main(int argc, char *argv[]) {
        JournalFile *one, *two, *three;
        char t[] = "/tmp/journal-stream-XXXXXX";
        unsigned i;
        _cleanup_journal_close_ sd_journal *j = NULL;
        char *z;
        const void *data;
        size_t l;

        log_set_max_level(LOG_DEBUG);

        assert_se(mkdtemp(t));
        assert_se(chdir(t) >= 0);

        assert_se(journal_file_open("one.journal", O_RDWR|O_CREAT, 0666, true, NULL, NULL, NULL, &one) == 0);
        assert_se(journal_file_open("two.journal", O_RDWR|O_CREAT, 0666, true, NULL, NULL, NULL, &two) == 0);
        assert_se(journal_file_open("three.journal", O_RDWR|O_CREAT, 0666, true, NULL, NULL, NULL, &three) == 0);

        for (i = 0; i < N_ENTRIES; i++) {
                char *p, *q;
                dual_timestamp ts;
                struct iovec iovec[2];

                dual_timestamp_get(&ts);

                assert_se(asprintf(&p, "NUMBER=%u", i) >= 0);
                iovec[0].iov_base = p;
                iovec[0].iov_len = strlen(p);

                assert_se(asprintf(&q, "MAGIC=%s", i % 5 == 0 ? "quux" : "waldo") >= 0);

                iovec[1].iov_base = q;
                iovec[1].iov_len = strlen(q);

                if (i % 10 == 0)
                        assert_se(journal_file_append_entry(three, &ts, iovec, 2, NULL, NULL, NULL) == 0);
                else {
                        if (i % 3 == 0)
                                assert_se(journal_file_append_entry(two, &ts, iovec, 2, NULL, NULL, NULL) == 0);

                        assert_se(journal_file_append_entry(one, &ts, iovec, 2, NULL, NULL, NULL) == 0);
                }

                free(p);
                free(q);
        }

        journal_file_close(one);
        journal_file_close(two);
        journal_file_close(three);

        assert_se(sd_journal_open_directory(&j, t, 0) >= 0);

        assert_se(sd_journal_add_match(j, "MAGIC=quux", 0) >= 0);
        SD_JOURNAL_FOREACH_BACKWARDS(j) {
                _cleanup_free_ char *c = NULL;

                assert_se(sd_journal_get_data(j, "NUMBER", &data, &l) >= 0);
                printf("\t%.*s\n", (int) l, (const char*) data);

                assert_se(sd_journal_get_cursor(j, &c) >= 0);
                assert_se(sd_journal_test_cursor(j, c) > 0);
        }

        SD_JOURNAL_FOREACH(j) {
                _cleanup_free_ char *c = NULL;

                assert_se(sd_journal_get_data(j, "NUMBER", &data, &l) >= 0);
                printf("\t%.*s\n", (int) l, (const char*) data);

                assert_se(sd_journal_get_cursor(j, &c) >= 0);
                assert_se(sd_journal_test_cursor(j, c) > 0);
        }

        sd_journal_flush_matches(j);

        verify_contents(j, 1);

        printf("NEXT TEST\n");
        assert_se(sd_journal_add_match(j, "MAGIC=quux", 0) >= 0);

        assert_se(z = journal_make_match_string(j));
        printf("resulting match expression is: %s\n", z);
        free(z);

        verify_contents(j, 5);

        printf("NEXT TEST\n");
        sd_journal_flush_matches(j);
        assert_se(sd_journal_add_match(j, "MAGIC=waldo", 0) >= 0);
        assert_se(sd_journal_add_match(j, "NUMBER=10", 0) >= 0);
        assert_se(sd_journal_add_match(j, "NUMBER=11", 0) >= 0);
        assert_se(sd_journal_add_match(j, "NUMBER=12", 0) >= 0);

        assert_se(z = journal_make_match_string(j));
        printf("resulting match expression is: %s\n", z);
        free(z);

        verify_contents(j, 0);

        assert_se(sd_journal_query_unique(j, "NUMBER") >= 0);
        SD_JOURNAL_FOREACH_UNIQUE(j, data, l)
                printf("%.*s\n", (int) l, (const char*) data);

        assert_se(rm_rf_dangerous(t, false, true, false) >= 0);

        return 0;
}
Beispiel #3
0
static bool
test_format(const struct fmt_test *test)
{
	bool pass = true;

	glUseProgram(prog);
	glUniform1i(0 /* explicit loc */, 0);

	/* Test glRenderbufferStorage. */
	GLuint rbo = create_and_bind_rbo(test);
	if (!rbo || !piglit_check_gl_error(GL_NO_ERROR)) {
		piglit_report_subtest_result(PIGLIT_FAIL,
					     "format 0x%x RBO test",
					     test->iformat);
		pass &= false;
	} else {
		piglit_report_subtest_result(PIGLIT_PASS,
					     "format 0x%x RBO test",
					     test->iformat);
	}
	glDeleteRenderbuffers(1, &rbo);

	/* Create framebuffer object. */
	GLuint fbo_tex;
	const GLuint fbo = create_and_bind_fbo(test, &fbo_tex);

	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) !=
		GL_FRAMEBUFFER_COMPLETE) {
		piglit_report_subtest_result(PIGLIT_FAIL,
					     "format 0x%x fbo fail",
					     test->iformat);
		pass &= false;
	}

	/* Create a texture, upload data */
	const GLuint texture = create_and_bind_texture(test);

	render_texture(texture, GL_TEXTURE_2D, fbo);

	glDeleteTextures(1, &texture);

	/* Test glCopyTexImage2D by copying current fbo content to
	 * a texture, rendering copy back to fbo and verifying fbo contents.
	 */
	GLuint tmp_tex = create_and_bind_empty_texture();
	glCopyTexImage2D(GL_TEXTURE_2D, 0, test->iformat, 0, 0, piglit_width,
			 piglit_height, 0);

	render_texture(tmp_tex, GL_TEXTURE_2D, fbo);

	glDeleteTextures(1, &tmp_tex);

	/* Verify contents. */
	pass &= verify_contents(test);

	glDeleteFramebuffers(1, &fbo);

	/* Render fbo contents to window. */
	render_texture(fbo_tex, GL_TEXTURE_2D, 0);

	piglit_present_results();

	glDeleteTextures(1, &fbo_tex);

	return pass;
}
Beispiel #4
0
static bool
test_format(const struct fmt_test *test)
{
	bool pass = true;

	if (piglit_is_extension_supported("GL_OES_texture_buffer") &&
	    test->can_texbuf) {
		bool buf_test = buffer_test(test);
		piglit_report_subtest_result(PIGLIT_RESULT(buf_test),
					     "format 0x%x TBO test",
					     test->iformat);
		pass &= buf_test;
	}

	glUseProgram(prog);
	glUniform1i(0 /* explicit loc */, 0);

	/* Create a texture, upload data */
	const GLuint texture = create_texture(test);

	glBindTexture(GL_TEXTURE_2D, texture);

	/* Can only texture from. */
	if (!test->req_render) {
		/* Render texture to window and verify contents. */
		render_texture(texture, GL_TEXTURE_2D, 0);
		bool render_test = verify_contents_float(test);
		piglit_present_results();
		piglit_report_subtest_result(PIGLIT_RESULT(render_test),
					     "format 0x%x",
					     test->iformat);
		glDeleteTextures(1, &texture);
		pass &= render_test;
		return pass;
	}

	/* Test glRenderbufferStorage. */
	GLuint rbo = create_rbo(test);
	if (!rbo || !piglit_check_gl_error(GL_NO_ERROR)) {
		piglit_report_subtest_result(PIGLIT_FAIL,
					     "format 0x%x RBO test",
					     test->iformat);
		pass &= false;
	} else {
		piglit_report_subtest_result(PIGLIT_PASS,
					     "format 0x%x RBO test",
					     test->iformat);
	}
	glDeleteRenderbuffers(1, &rbo);

	/* Create framebuffer object. */
	GLuint fbo_tex;
	const GLuint fbo = create_fbo(test, &fbo_tex);

	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) !=
		GL_FRAMEBUFFER_COMPLETE) {
		piglit_report_subtest_result(PIGLIT_FAIL,
					     "format 0x%x fbo fail",
					     test->iformat);
		pass &= false;
	}

	render_texture(texture, GL_TEXTURE_2D, fbo);

	/* Test glCopyTexImage2D by copying current fbo content to
	 * a texture, rendering copy back to fbo and verifying fbo contents.
	 */
	GLuint tmp_tex = create_empty_texture();
	glCopyTexImage2D(GL_TEXTURE_2D, 0, test->iformat, 0, 0, piglit_width,
			 piglit_height, 0);

	render_texture(tmp_tex, GL_TEXTURE_2D, fbo);

	/* If format can be read, verify contents. */
	if (test->can_read)
		pass &= verify_contents(test);

	glDeleteTextures(1, &tmp_tex);

	/* If GL_EXT_copy_image is supported then create another
	 * texture, copy contents and render result to fbo.
	 */
	GLuint texture_copy = 0;
	if (piglit_is_extension_supported("GL_EXT_copy_image")) {
		bool copy_pass =
			test_copy_image(test, texture, &texture_copy);
		pass &= copy_pass;
		piglit_report_subtest_result(PIGLIT_RESULT(copy_pass),
					     "copy image format 0x%x",
					     test->iformat);
		render_texture(texture_copy, GL_TEXTURE_2D, fbo);
	}

	/* If format can be read, verify contents. */
	if (test->can_read)
		pass &= verify_contents(test);

	/* Render fbo contents to window. */
	render_texture(fbo_tex, GL_TEXTURE_2D, 0);

	piglit_present_results();

	glDeleteFramebuffers(1, &fbo);
	glDeleteTextures(1, &texture);
	glDeleteTextures(1, &texture_copy);

	return pass;
}