Ejemplo n.º 1
0
void test_lib__core__util_c()
{
    subtest("parse_proxy_line", test_parse_proxy_line);
    subtest("extract_push_path_from_link_header", test_extract_push_path_from_link_header);
    subtest("test_build_destination", test_build_destination);
    subtest("test_build_destination_escaping", test_build_destination_escaping);
}
Ejemplo n.º 2
0
void
piglit_init(int argc, char **argv)
{
        enum piglit_result status = PIGLIT_PASS;
        const struct image_stage_info *stage;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        for (stage = image_stages(); stage->name; ++stage) {
                subtest(&status, true,
                        run_test(stage->bit),
                        "%s shader max image uniforms test",
                        stage->name);
        }

        subtest(&status, true,
                run_test((get_image_stage(GL_VERTEX_SHADER) ?
                          GL_VERTEX_SHADER_BIT : 0) |
                         (get_image_stage(GL_TESS_CONTROL_SHADER) ?
                          GL_TESS_CONTROL_SHADER_BIT : 0) |
                         (get_image_stage(GL_TESS_EVALUATION_SHADER) ?
                          GL_TESS_EVALUATION_SHADER_BIT : 0) |
                         (get_image_stage(GL_GEOMETRY_SHADER) ?
                          GL_GEOMETRY_SHADER_BIT : 0) |
                         GL_FRAGMENT_SHADER_BIT),
                "Combined max image uniforms test");

        piglit_report_result(status);
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    subtest("request", test_request);
    subtest("response", test_response);
    subtest("headers", test_headers);
    subtest("chunked", test_chunked);
    subtest("chunked-consume-trailer", test_chunked_consume_trailer);
    return done_testing();
}
Ejemplo n.º 4
0
void test_lib__common__string_c(void)
{
    subtest("strstr", test_strstr);
    subtest("stripws", test_stripws);
    subtest("get_filext", test_get_filext);
    subtest("next_token", test_next_token);
    subtest("next_token2", test_next_token2);
    subtest("next_token3", test_next_token3);
    subtest("decode_base64", test_decode_base64);
    subtest("htmlescape", test_htmlescape);
    subtest("uri_escape", test_uri_escape);
    subtest("at_position", test_at_position);
}
Ejemplo n.º 5
0
void
piglit_init(int argc, char **argv)
{
        enum piglit_result status = PIGLIT_PASS;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        subtest(&status, true, run_test_binding(),
                "binding state test");

        subtest(&status, true, run_test_uniform(),
                "uniform state test");

        piglit_report_result(status);
}
Ejemplo n.º 6
0
void
piglit_init(int argc, char **argv)
{
        enum piglit_result status = PIGLIT_PASS;
        const struct image_format_info *format;
        unsigned i;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        for (format = image_formats_load_store; format->name; ++format) {
                for (i = 0; i < 8; ++i) {
                        const bool strict_layout_qualifiers = i & 1;
                        const bool strict_access_qualifiers = i & 2;
                        const bool strict_binding = i & 4;

                        subtest(&status, true,
                                run_test(format, strict_layout_qualifiers,
                                         strict_access_qualifiers,
                                         strict_binding),
                                "%s/%s layout qualifiers/%s access qualifiers/"
                                "%s binding test", format->name,
                                (strict_layout_qualifiers ? "strict" : "permissive"),
                                (strict_access_qualifiers ? "strict" : "permissive"),
                                (strict_binding ? "strict" : "permissive"));
                }
        }

        piglit_report_result(status);
}
Ejemplo n.º 7
0
void
piglit_init(int argc, char **argv)
{
        const bool quick = (argc >= 2 && !strcmp(argv[1], "--quick"));
        enum piglit_result status = PIGLIT_PASS;
        const struct image_target_info *target;
        int d;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        for (target = image_targets(); target->name; ++target) {
                for (d = 0; d < 4; ++d) {
                        if (should_test_dimension(target, d)) {
                                const struct image_extent size =
                                        get_test_extent(target, d);

                                subtest(&status,
                                        is_test_reasonable(quick, size),
                                        run_test(target, size),
                                        "image%s max size test/%dx%dx%dx%d",
                                        target->name,
                                        size.x, size.y, size.z, size.w);
                        }
                }
        }

        piglit_report_result(status);
}
Ejemplo n.º 8
0
void
piglit_init(int argc, char **argv)
{
        enum piglit_result status = PIGLIT_PASS;
        const struct image_op_info *op;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        for (op = image_ops; op->name; ++op) {
                /*
                 * Draw a rectangle discarding a subset of the
                 * fragments before inc() is run, then make sure that
                 * it had no effect for those fragments.
                 */
                subtest(&status, true,
                        run_test(op, W, H, check_discard,
                                 "GRID_T op(ivec2 idx, GRID_T x) {\n"
                                 "        if (idx.x % 5 == 0)\n"
                                 "                discard;\n"
                                 "        inc(idx);\n"
                                 "        return x;\n"
                                 "}\n"),
                        "%s/discard test", op->name);

                /*
                 * Draw a 1-pixel wide rectangle and make a derivative
                 * computation in the orthogonal direction to get the
                 * GPU to run fragment shader invocations located
                 * outside the primitive, then make sure that inc()
                 * had no effect for those fragments.
                 */
                subtest(&status, true,
                        run_test(op, W - 3, 1, check_derivative,
                                 "GRID_T op(ivec2 idx, GRID_T x) {\n"
                                 "        x = uvec4(1000 * dFdy(vec4("
                                 "                imageLoad(img, IMAGE_ADDR(idx)))));"
                                 "        inc(idx);\n"
                                 "        return x;\n"
                                 "}\n"),
                        "%s/derivative test", op->name);
        }

        piglit_report_result(status);
}
Ejemplo n.º 9
0
void
piglit_init(int argc, char **argv)
{
        enum piglit_result status = PIGLIT_PASS;
        const struct image_target_info *target;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        for (target = image_targets(); target->name; ++target) {
                subtest(&status, true,
                        run_test(target, false, 5),
                        "image%s/non-layered binding test", target->name);

                subtest(&status, true,
                        run_test(target, true, 5),
                        "image%s/layered binding test", target->name);
        }

        piglit_report_result(status);
}
Ejemplo n.º 10
0
void
piglit_init(int argc, char **argv)
{
        const struct image_qualifier_info *qual;
        enum piglit_result status = PIGLIT_PASS;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        for (qual = image_qualifiers; qual->name; ++qual) {
                subtest(&status, true, run_test(qual),
                        "%s image aliasing test", qual->name);
        }


        piglit_report_result(status);
}
Ejemplo n.º 11
0
void test_lib__handler__fastcgi_c()
{
    h2o_globalconf_t globalconf;
    h2o_hostconf_t *hostconf;
    h2o_pathconf_t *pathconf;

    h2o_config_init(&globalconf);
    globalconf.server_name = h2o_iovec_init(H2O_STRLIT("h2o/1.2.1-alpha1"));
    hostconf = h2o_config_register_host(&globalconf, h2o_iovec_init(H2O_STRLIT("default")), 65535);
    pathconf = h2o_config_register_path(hostconf, "/");

    h2o_context_init(&ctx, test_loop, &globalconf);

    subtest("build-request", test_build_request);

    h2o_context_dispose(&ctx);
    h2o_config_dispose(&globalconf);
}
Ejemplo n.º 12
0
void
piglit_init(int argc, char **argv)
{
        const bool quick = (argc >= 2 && !strcmp(argv[1], "--quick"));
        const struct image_qualifier_info *qual;
        const struct image_stage_info *stage_w;
        const struct image_stage_info *stage_r;
        enum piglit_result status = PIGLIT_PASS;
        unsigned l;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        for (l = 4; l <= L; l *= (quick ? 8 : 2)) {
                for (qual = image_qualifiers; qual->name; ++qual) {
                        if (quick && qual->control_test)
                                continue;

                        /*
                         * Loop for each pair of shader stages
                         * skipping the compute shader: "coherent"
                         * gives no useful guarantees in that case
                         * since its execution ordering is undefined
                         * with respect to the other shader stages.
                         */
                        for (stage_w = image_stages();
                             stage_w->stage; ++stage_w) {
                                for (stage_r = stage_w + 1;
                                     stage_r->stage; ++stage_r) {
                                        if (stage_w->stage == GL_COMPUTE_SHADER ||
                                            stage_r->stage == GL_COMPUTE_SHADER)
                                                continue;

                                      subtest(&status, true,
                                                run_test(qual, stage_w, stage_r, l),
                                                "%s-%s shader/%s coherency test/%dx%d",
                                                stage_w->name, stage_r->name,
                                                qual->name, l, l);
                                }
                        }
                }
        }

        piglit_report_result(status);
}
Ejemplo n.º 13
0
int main(int argc, char **argv)
{
    ERR_load_crypto_strings();
    OpenSSL_add_all_algorithms();
#if !defined(OPENSSL_NO_ENGINE)
    /* Load all compiled-in ENGINEs */
    ENGINE_load_builtin_engines();
    ENGINE_register_all_ciphers();
    ENGINE_register_all_digests();
#endif

    {
        BIO *bio = BIO_new_mem_buf(RSA_CERTIFICATE, strlen(RSA_CERTIFICATE));
        X509 *x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
        assert(x509 != NULL || !!"failed to load certificate");
        BIO_free(bio);
        cert.len = i2d_X509(x509, &cert.base);
        X509_free(x509);
    }

    {
        BIO *bio = BIO_new_mem_buf(RSA_PRIVATE_KEY, strlen(RSA_PRIVATE_KEY));
        EVP_PKEY *pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
        assert(pkey != NULL || !"failed to load private key");
        BIO_free(bio);
        ptls_openssl_init_sign_certificate(&cert_signer, pkey);
        EVP_PKEY_free(pkey);
    }

    subtest("next-packet-number", test_next_packet_number);
    subtest("ranges", test_ranges);
    subtest("frame", test_frame);
    subtest("maxsender", test_maxsender);
    subtest("ack", test_ack);
    subtest("simple", test_simple);
    subtest("stream-concurrency", test_stream_concurrency);
    subtest("loss", test_loss);

    return done_testing();
}
Ejemplo n.º 14
0
int main(int argc, char **argv)
{
    ptls_openssl_sign_certificate_t openssl_sign_certificate;
    ptls_openssl_verify_certificate_t openssl_verify_certificate;

    ERR_load_crypto_strings();
    OpenSSL_add_all_algorithms();
#if !defined(OPENSSL_NO_ENGINE)
    /* Load all compiled-in ENGINEs */
    ENGINE_load_builtin_engines();
    ENGINE_register_all_ciphers();
    ENGINE_register_all_digests();
#endif

    ptls_iovec_t cert;
    setup_certificate(&cert);
    setup_sign_certificate(&openssl_sign_certificate);
    ptls_openssl_init_verify_certificate(&openssl_verify_certificate, NULL);
    ptls_context_t openssl_ctx = {
        ptls_openssl_random_bytes,       ptls_openssl_key_exchanges,       ptls_openssl_cipher_suites, {&cert, 1}, NULL, NULL,
        &openssl_sign_certificate.super, &openssl_verify_certificate.super};
    ctx = ctx_peer = &openssl_ctx;

    subtest("ecdh-key-exchange", test_ecdh_key_exchange);
    subtest("rsa-sign", test_rsa_sign);
    subtest("ecdsa-sign", test_ecdsa_sign);
    subtest("picotls", test_picotls);

    ptls_minicrypto_secp256r1sha256_sign_certificate_t minicrypto_sign_certificate;
    ptls_iovec_t minicrypto_certificate = ptls_iovec_init(SECP256R1_CERTIFICATE, sizeof(SECP256R1_CERTIFICATE) - 1);
    ptls_minicrypto_init_secp256r1sha256_sign_certificate(
        &minicrypto_sign_certificate, ptls_iovec_init(SECP256R1_PRIVATE_KEY, sizeof(SECP256R1_PRIVATE_KEY) - 1));
    ptls_context_t minicrypto_ctx = {ptls_minicrypto_random_bytes,
                                     ptls_minicrypto_key_exchanges,
                                     ptls_minicrypto_cipher_suites,
                                     {&minicrypto_certificate, 1},
                                     NULL,
                                     NULL,
                                     &minicrypto_sign_certificate.super};
    ctx_peer = &minicrypto_ctx;
    subtest("vs. minicrypto", test_picotls);

    ctx = &minicrypto_ctx;
    ctx_peer = &openssl_ctx;
    subtest("minicrypto vs.", test_picotls);

    return done_testing();
}
Ejemplo n.º 15
0
int main(int argc, char** argv)
{
    if ((argc > 2) || ((argc == 2) && (strcmp(argv[1], "master") != 0)))
    {
        cerr << "Usage:  " << argv[0] << " master - start the tests" << endl;
        cerr << "        " << argv[0] << "        - run a subtest" << endl;
        exit(1);
    }

    if (argc == 2)
    {
        master(argv[0]);

        cout << argv[0] << " +++++ passed all tests" << endl;
    }
    else
    {
        subtest();
    }

    return 0;
}
Ejemplo n.º 16
0
void test_lib__http2__cache_digests(void)
{
    subtest("calc_hash", test_calc_hash);
    subtest("test_decode", test_decode);
}
Ejemplo n.º 17
0
void test_PASS(int syscall) {
	int child;

	subtest("intercept");
	do_intercept(syscall, 0);
	do_release(syscall, 0);

	subtest("monitor");
	do_intercept(syscall, 0);
	test_monitor(syscall, FALSE);
	do_start(syscall, -1, 0);
	test_monitor(syscall, TRUE);
	do_stop(syscall, -1, 0);
	test_monitor(syscall, FALSE);
	do_release(syscall, 0);

	subtest("monitor & kill monitored process");
	do_intercept(syscall, 0);
	switch (child = fork()) {
	case -1:
		assert(0);
	case 0:
		// monitor the child process then exit
		do_start(syscall, -1, 0);
		test_monitor(syscall, TRUE);
		exit(0);
	default:
		waitpid(child, NULL, 0);
		// child should have been unmonitored automatically
		// there is no way to start process with specific pid...
		do_start(syscall, child, -EINVAL);
		do_stop(syscall, child, -EINVAL);
	}
	do_release(syscall, 0);

	subtest("monitor all pids");
	do_intercept(syscall, 0);
	test_monitor2(syscall, FALSE, FALSE);
	do_start(syscall, 0, 0);
	test_monitor2(syscall, TRUE, TRUE);

	subtest("stop monitor current pid");
	do_stop(syscall, -1, 0);
	test_monitor2(syscall, FALSE, TRUE);

	subtest("monitor all -> stop one -> monitor all");
	do_start(syscall, 0, 0);
	do_stop(syscall, -1, 0);
	do_start(syscall, 0, 0);
	do_stop(syscall, 0, 0);

	subtest("monitor one -> stop all");
	do_start(syscall, -1, 0);
	do_stop(syscall, 0, 0);

	subtest("monitor all -> stop one -> stop all");
	do_start(syscall, 0, 0);
	do_stop(syscall, -1, 0);
	do_stop(syscall, 0, 0);

	subtest("reset");
	do_start(syscall, -1, 0);
	test_monitor2(syscall, TRUE, FALSE);
	do_stop(syscall, 0, 0);
	test_monitor2(syscall, FALSE, FALSE);
	do_release(syscall, 0);
}
Ejemplo n.º 18
0
void test_CDE(int syscall) {
	//C -EINVAL
	subtest("Cannot de-intercept a system call that has not been intercepted yet.");
	do_release(syscall, -EINVAL);
	subtest("Cannot stop monitoring a pid for a syscall that has not been intercepted.");
	do_stop(syscall, -1, -EINVAL);
	do_stop(syscall, 0, -EINVAL);
	subtest("Cannot start monitoring a pid for that has not been intercepted yet.");
	do_start(syscall, -1, -EINVAL);
	do_start(syscall, 0, -EINVAL);

	do_intercept(syscall, 0);

	subtest("Cannot start monitoring a pid that is invalid.");
	do_start(syscall, 1234567, -EINVAL);
	do_start(syscall, -2, -EINVAL);
	subtest("Cannot stop monitoring for a pid that is not being monitored.");
	do_stop(syscall, 0, -EINVAL);
	do_stop(syscall, -1, -EINVAL);
	subtest("Cannot stop monitoring for a pid that is blacklisted.");
	do_start(syscall, 0, 0);
	do_stop(syscall, -1, 0);
	do_stop(syscall, -1, -EINVAL);
	do_stop(syscall, 0, 0);
	subtest("EINVAL: stop all -> stop all");
	do_start(syscall, 0, 0);
	do_stop(syscall, 0, 0);
	do_stop(syscall, 0, -EINVAL);
	subtest("EINVAL: start one pid -> stop the same pid -> stop all");
	do_start(syscall, -1, 0);
	do_stop(syscall, -1, 0);
	do_stop(syscall, 0, -EINVAL);


	do_release(syscall, 0);

	//D -EBUSY
	do_intercept(syscall, 0);

	subtest("EBUSY: intercepting a system call that is already intercepted");
	do_intercept(syscall, -EBUSY);
	subtest("EBUSY: monitoring a pid that is being whitelisted");
	do_start(syscall, -1, 0);
	do_start(syscall, -1, -EBUSY);
	do_stop(syscall, -1, 0);
	subtest("EBUSY: monitoring a pid that is being monitored globally");
	do_start(syscall, 0, 0);
	do_start(syscall, -1, -EBUSY);
	do_stop(syscall, 0, 0);
	subtest("EBUSY: monitoring all pids when all pids are being monitored");
	do_start(syscall, 0, 0);
	do_start(syscall, 0, -EBUSY);
	do_stop(syscall, 0, 0);
	subtest("OK: monitoring all pids when some pids are being monitored");
	do_start(syscall, -1, 0);
	do_start(syscall, 0, 0);
	do_stop(syscall, -1, 0);
	do_stop(syscall, 0, 0);
	//E -ENOMEM
	//If a pid cannot be added to a monitored list, due to no memory being available, an -ENOMEM error code should be returned.
	// int child;
	// int res = 0;
	// while (!res) {
	// 	switch (child = fork()) {
	// 	case -1://error
	// 		assert(0);
	// 	case 0: //child
	// 		pause();
	// 	default: //parent
	// 		res = vsyscall_arg(MY_CUSTOM_SYSCALL, 3, REQUEST_START_MONITORING, syscall, child);
	// 		// printf("start monitoring %d: %d\n", child, res);
	// 		break;
	// 	}
	// }
	// test("%d no memory", syscall, res == -ENOMEM);
	// signal(SIGQUIT, SIG_IGN);
	// kill(-getpid(), SIGQUIT);

	do_release(syscall, 0);
}
Ejemplo n.º 19
0
void test_lib__common__hostinfo_c(void)
{
    /* TODO add tests for h2o_hostinfo_getaddr and related */
    subtest("aton", test_aton);
}
Ejemplo n.º 20
0
void
piglit_init(int argc, char **argv)
{
        enum piglit_result status = PIGLIT_PASS;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        subtest(&status, true,
                run_test(0, 33,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "        imageAtomicAdd(img, IMAGE_ADDR(idx), BASE_T(33));\n"
                         "        return x;\n"
                         "}\n"),
                "imageAtomicAdd");

        subtest(&status, true,
                run_test(0xffffffff, 33,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "        imageAtomicMin(img, IMAGE_ADDR(idx), BASE_T(33));\n"
                         "        return x;\n"
                         "}\n"),
                "imageAtomicMin");

        subtest(&status, true,
                run_test(0, 33,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "        imageAtomicMax(img, IMAGE_ADDR(idx), BASE_T(33));\n"
                         "        return x;\n"
                         "}\n"),
                "imageAtomicMax");

        subtest(&status, true,
                run_test(0xffffffff, 33,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "        imageAtomicAnd(img, IMAGE_ADDR(idx), BASE_T(33));\n"
                         "        return x;\n"
                         "}\n"),
                "imageAtomicAnd");

        subtest(&status, true,
                run_test(0, 33,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "        imageAtomicOr(img, IMAGE_ADDR(idx), BASE_T(33));\n"
                         "        return x;\n"
                         "}\n"),
                "imageAtomicOr");

        subtest(&status, true,
                run_test(0, 33,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "        imageAtomicXor(img, IMAGE_ADDR(idx), BASE_T(33));\n"
                         "        return x;\n"
                         "}\n"),
                "imageAtomicXor");

        subtest(&status, true,
                run_test(0, 33,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "        imageAtomicExchange(img, IMAGE_ADDR(idx),"
                         "                            BASE_T(33));\n"
                         "        return x;\n"
                         "}\n"),
                "imageAtomicExchange");

        subtest(&status, true,
                run_test(0, 33,
                "GRID_T op(ivec2 idx, GRID_T x) {\n"
                "        imageAtomicCompSwap(img, IMAGE_ADDR(idx),"
                "                            BASE_T(0), BASE_T(33));\n"
                "        return x;\n"
                         "}\n"),
                "imageAtomicCompSwap");

        piglit_report_result(status);
}
Ejemplo n.º 21
0
void test_maxsender(void)
{
    subtest("basic", test_basic);
    subtest("stream-id", test_stream_id);
}
Ejemplo n.º 22
0
void
piglit_init(int argc, char **argv)
{
        enum piglit_result status = PIGLIT_PASS;

        piglit_require_extension("GL_ARB_shader_image_load_store");

        /*
         * If imageAtomicAdd() is atomic the return values obtained
         * from each call are guaranteed to be unique.
         */
        subtest(&status, true,
                run_test(0, 1, N, true,
                         "GRID_T op(ivec2 idx, GRID_T x) {\n"
                         "       return GRID_T("
                         "          imageAtomicAdd(img, IMAGE_ADDR(ivec2(0)), 1u),"
                         "          0, 0, 1);\n"
                         "}\n"),
                "imageAtomicAdd");

        /*
         * Call imageAtomicMin() on a fixed location from within a
         * loop passing the most recent guess of the counter value
         * decremented by one.
         *
         * If no race occurs the counter will be decremented by one
         * and we're done, if another thread updates the counter in
         * parallel imageAtomicMin() has no effect since
         * min(x-n, x-1) = x-n for n >= 1, so we update our guess and
         * repeat.  In the end we obtain a unique counter value for
         * each fragment if the read-modify-write operation is atomic.
         */
        subtest(&status, true,
                run_test(0xffffffff, 1, 0xffffffff - N, true,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       uint old, v = 0xffffffffu;"
                        "\n"
                        "       do {\n"
                        "               old = v;\n"
                        "               v = imageAtomicMin(img, IMAGE_ADDR(ivec2(0)),"
                        "                                  v - 1u);\n"
                        "       } while (v != old);\n"
                        "\n"
                        "       return GRID_T(v, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicMin");

        /*
         * Use imageAtomicMax() on a fixed location to increment a
         * counter as explained above for imageAtomicMin().  The
         * atomicity of the built-in guarantees that the obtained
         * values will be unique for each fragment.
         */
        subtest(&status, true,
                run_test(0, 1, N, true,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       uint old, v = 0u;"
                        "\n"
                        "       do {\n"
                        "               old = v;\n"
                        "               v = imageAtomicMax(img, IMAGE_ADDR(ivec2(0)),"
                        "                                  v + 1u);\n"
                        "       } while (v != old);\n"
                        "\n"
                        "       return GRID_T(v, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicMax");

        /*
         * Use imageAtomicAnd() to flip individual bits of a bitmap
         * atomically.  The atomicity of the built-in guarantees that
         * all bits will be clear on termination.
         */
        subtest(&status, true,
                run_test(0xffffffff, N / 32, 0, false,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       int i = IMAGE_ADDR(idx);\n"
                        "       uint m = ~(1u << (i % 32));\n"
                        "\n"
                        "       imageAtomicAnd(img, i / 32, m);\n"
                        "\n"
                        "       return GRID_T(0, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicAnd");

        /*
         * Use imageAtomicOr() to flip individual bits of a bitmap
         * atomically.  The atomicity of the built-in guarantees that
         * all bits will be set on termination.
         */
        subtest(&status, true,
                run_test(0, N / 32, 0xffffffff, false,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       int i = IMAGE_ADDR(idx);\n"
                        "       uint m = (1u << (i % 32));\n"
                        "\n"
                        "       imageAtomicOr(img, i / 32, m);\n"
                        "\n"
                        "       return GRID_T(0, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicOr");

        /*
         * Use imageAtomicXor() to flip individual bits of a bitmap
         * atomically.  The atomicity of the built-in guarantees that
         * all bits will have been inverted on termination.
         */
        subtest(&status, true,
                run_test(0x55555555, N / 32, 0xaaaaaaaa, false,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       int i = IMAGE_ADDR(idx);\n"
                        "       uint m = (1u << (i % 32));\n"
                        "\n"
                        "       imageAtomicXor(img, i / 32, m);\n"
                        "\n"
                        "       return GRID_T(0, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicXor");

        /*
         * Use imageAtomicExchange() to flip individual bits of a
         * bitmap atomically.  The atomicity of the built-in
         * guarantees that all bits will be set on termination.
         */
        subtest(&status, true,
                run_test(0, N / 32, 0xffffffff, false,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       int i = IMAGE_ADDR(idx);\n"
                        "       uint m = (1u << (i % 32));\n"
                        "       uint old = 0u;\n"
                        "\n"
                        "       do {\n"
                        "               m |= old;\n"
                        "               old = imageAtomicExchange("
                        "                       img, i / 32, m);\n"
                        "       } while ((old & ~m) != 0u);\n"
                        "\n"
                        "       return GRID_T(0, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicExchange");

#if 0
        /*
         * Use imageAtomicExchange() on a fixed location to increment
         * a counter, implementing a sort of spin-lock.
         *
         * The counter has two states: locked (0xffffffff) and
         * unlocked (any other value).  While locked a single thread
         * owns the value of the counter, increments its value and
         * puts it back to the same location, atomically releasing the
         * counter.  The atomicity of the built-in guarantees that the
         * obtained values will be unique for each fragment.
         *
         * Unlike the classic spin-lock implementation, this uses the
         * same atomic call to perform either a lock or an unlock
         * operation depending on the current thread state.  This is
         * critical to avoid a dead-lock situation on machines where
         * neighboring threads have limited parallelism (e.g. share
         * the same instruction pointer).
         *
         * This could lead to a different kind of dead-lock on devices
         * that simulate concurrency by context-switching threads
         * based on some sort of priority queue: If there is a
         * possibility for a low-priority thread to acquire the lock
         * and be preempted before the end of the critical section, it
         * will prevent higher priority threads from making progress
         * while the higher priority threads may prevent the
         * lock-owning thread from being scheduled again and releasing
         * the lock.
         *
         * Disabled for now because the latter dead-lock can easily be
         * reproduced on current Intel hardware where it causes a GPU
         * hang.  It seems to work fine on nVidia though, it would be
         * interesting to see if it works on other platforms.
         */
        subtest(&status, true,
                run_test(0, 1, N, true,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       uint p = 0xffffffffu, v = 0xffffffffu;\n"
                        "\n"
                        "       do {\n"
                        "               if (p != 0xffffffffu)\n"
                        "                       v = p++;\n"
                        "               p = imageAtomicExchange("
                        "                  img, IMAGE_ADDR(ivec2(0)), p);\n"
                        "       } while (v == 0xffffffffu);\n"
                        "\n"
                        "       return GRID_T(v, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicExchange (locking)");
#endif

        /*
         * Use imageAtomicCompSwap() on a fixed location from within a
         * loop passing the most recent guess of the counter value as
         * comparison value and the same value incremented by one as
         * argument.  The atomicity of the built-in guarantees that
         * the obtained values will be unique for each fragment.
         */
        subtest(&status, true,
                run_test(0, 1, N, true,
                        "GRID_T op(ivec2 idx, GRID_T x) {\n"
                        "       uint old, v = 0u;"
                        "\n"
                        "       do {\n"
                        "               old = v;\n"
                        "               v = imageAtomicCompSwap("
                        "                  img, IMAGE_ADDR(ivec2(0)), v, v + 1u);\n"
                        "       } while (v != old);\n"
                        "\n"
                        "       return GRID_T(v, 0, 0, 1);\n"
                        "}\n"),
                "imageAtomicCompSwap");

        piglit_report_result(status);
}
Ejemplo n.º 23
0
void test_lib__core__util_c()
{
    subtest("parse_proxy_line", test_parse_proxy_line);
    subtest("extract_push_path_from_link_header", test_extract_push_path_from_link_header);
}