int main(int argc, char **argv) { if (argc == 2) scale = atoi(argv[1]); (void)test_context(1 * scale); ArrayPool<T> pool; pool.setSize(10 * scale); plan(0); testSLList(pool); testDLList(pool); testSLCList(pool); testDLCList(pool); testSLFifoList(pool); testDLFifoList(pool); testSLCFifoList(pool); testDLCFifoList(pool); testConcat(pool); return exit_status(); }
int main (void) { // test_planfile (); test_context (); return(0); }
int main(void) { test_context(); test_load(); test_flowgraph1(); test_flowgraph2(); fprintf(stderr, "\nAll tests passed!\n"); return 0; }
static int test_app_context(void) { OPENSSL_CTX *ctx = NULL; int result = TEST_true(foo_init()) && TEST_ptr(ctx = OPENSSL_CTX_new()) && test_context(ctx); OPENSSL_CTX_free(ctx); return result; }
int main(int argc, char **argv) { cl_context ctx; cl_command_queue q; // root device, all devices #define NUMDEVS 6 cl_device_id rootdev, alldevs[NUMDEVS]; // pointers to the sub devices of the partitions EQUALLY and BY_COUNTS // respectively cl_device_id *eqdev = alldevs + 1, *countdev = alldevs + 4; cl_uint max_cus, max_subs, split; cl_uint i, j; cl_int err = poclu_get_any_device(&ctx, &rootdev, &q); CHECK_OPENCL_ERROR_IN("poclu_get_any_device"); TEST_ASSERT( ctx ); TEST_ASSERT( rootdev ); TEST_ASSERT( q ); alldevs[0] = rootdev; err = clGetDeviceInfo(rootdev, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(max_cus), &max_cus, NULL); CHECK_OPENCL_ERROR_IN("CL_DEVICE_MAX_COMPUTE_UNITS"); if (max_cus < 2) { printf("This test requires a cl device with at least 2 compute units" " (a dual-core or better CPU)\n"); return 1; } err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, sizeof(max_subs), &max_subs, NULL); CHECK_OPENCL_ERROR_IN("CL_DEVICE_PARTITION_MAX_SUB_DEVICES"); // test fails without possible sub-devices, e.g. with basic pocl device TEST_ASSERT(max_subs > 1); cl_device_partition_property *dev_pt; size_t dev_pt_size; err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_PROPERTIES, 0, NULL, &dev_pt_size); CHECK_OPENCL_ERROR_IN("CL_DEVICE_PARTITION_PROPERTIES size"); dev_pt = malloc(dev_pt_size); TEST_ASSERT(dev_pt); err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_PROPERTIES, dev_pt_size, dev_pt, NULL); CHECK_OPENCL_ERROR_IN("CL_DEVICE_PARTITION_PROPERTIES"); j = dev_pt_size / sizeof (*dev_pt); // number of partition types // check that partition types EQUALLY and BY_COUNTS are supported int found = 0; for (i = 0; i < j; ++i) { if (dev_pt[i] == CL_DEVICE_PARTITION_EQUALLY || dev_pt[i] == CL_DEVICE_PARTITION_BY_COUNTS) ++found; } TEST_ASSERT(found == 2); // here we will store the partition types returned by the subdevices cl_device_partition_property *ptype = NULL; size_t ptype_size; cl_uint numdevs = 0; cl_device_id parent; cl_uint sub_cus; /* CL_DEVICE_PARTITION_EQUALLY */ printf("Max CUs: %u\n", max_cus); /* if the device has 3 CUs, 3 subdevices will be created, otherwise 2. */ if (max_cus == 3) split = 3; else split = 2; const cl_device_partition_property equal_splitter[] = { CL_DEVICE_PARTITION_EQUALLY, max_cus/split, 0 }; err = clCreateSubDevices(rootdev, equal_splitter, 0, NULL, &numdevs); CHECK_OPENCL_ERROR_IN("count sub devices"); TEST_ASSERT(numdevs == split); err = clCreateSubDevices(rootdev, equal_splitter, split, eqdev, NULL); CHECK_OPENCL_ERROR_IN("partition equally"); if (split == 2) eqdev[2] = NULL; cl_uint refc; err = clGetDeviceInfo (eqdev[0], CL_DEVICE_REFERENCE_COUNT, sizeof (refc), &refc, NULL); CHECK_OPENCL_ERROR_IN ("get refcount"); TEST_ASSERT (refc == 1); /* First, check that the root device is untouched */ err = clGetDeviceInfo(rootdev, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(sub_cus), &sub_cus, NULL); CHECK_OPENCL_ERROR_IN("parenty CU"); TEST_ASSERT(sub_cus == max_cus); err = clGetDeviceInfo(rootdev, CL_DEVICE_PARENT_DEVICE, sizeof(parent), &parent, NULL); CHECK_OPENCL_ERROR_IN("root parent device"); TEST_ASSERT(parent == NULL); /* partition type may either be NULL or contain a 0 entry */ err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE, 0, NULL, &ptype_size); CHECK_OPENCL_ERROR_IN("root partition type"); if (ptype_size != 0) { /* abuse dev_pt which should be large enough */ TEST_ASSERT(ptype_size == sizeof(cl_device_partition_property)); TEST_ASSERT(ptype_size <= dev_pt_size); err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE, ptype_size, dev_pt, NULL); CHECK_OPENCL_ERROR_IN("root partition type #2"); TEST_ASSERT(dev_pt[0] == 0); } /* now test the subdevices */ for (i = 0; i < split; ++i) { err = clGetDeviceInfo(eqdev[i], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(sub_cus), &sub_cus, NULL); CHECK_OPENCL_ERROR_IN("sub CU"); TEST_ASSERT(sub_cus == max_cus/split); err = clGetDeviceInfo(eqdev[i], CL_DEVICE_PARENT_DEVICE, sizeof(parent), &parent, NULL); CHECK_OPENCL_ERROR_IN("sub parent device"); TEST_ASSERT(parent == rootdev); err = clGetDeviceInfo(eqdev[i], CL_DEVICE_PARTITION_TYPE, 0, NULL, &ptype_size); CHECK_OPENCL_ERROR_IN("sub partition type"); TEST_ASSERT(ptype_size == sizeof(equal_splitter)); ptype = malloc(ptype_size); TEST_ASSERT(ptype); err = clGetDeviceInfo(eqdev[i], CL_DEVICE_PARTITION_TYPE, ptype_size, ptype, NULL); CHECK_OPENCL_ERROR_IN("sub partition type #2"); TEST_ASSERT(memcmp(ptype, equal_splitter, ptype_size) == 0); /* free the partition type */ free(ptype) ; ptype = NULL; } /* CL_DEVICE_PARTITION_BY_COUNTS */ /* Note that the platform will only read this to the first 0, * which is actually CL_DEVICE_PARTITION_BY_COUNTS_LIST_END; * the test is structured with an additional final 0 intentionally, * to follow the Khoronos doc example */ const cl_device_partition_property count_splitter[] = { CL_DEVICE_PARTITION_BY_COUNTS, 1, max_cus - 1, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 }; err = clCreateSubDevices(rootdev, count_splitter, 0, NULL, &numdevs); CHECK_OPENCL_ERROR_IN("count sub devices"); TEST_ASSERT(numdevs == 2); err = clCreateSubDevices(rootdev, count_splitter, 2, countdev, NULL); CHECK_OPENCL_ERROR_IN("partition by counts"); /* First, check that the root device is untouched */ err = clGetDeviceInfo(rootdev, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(sub_cus), &sub_cus, NULL); CHECK_OPENCL_ERROR_IN("parenty CU"); TEST_ASSERT(sub_cus == max_cus); err = clGetDeviceInfo(rootdev, CL_DEVICE_PARENT_DEVICE, sizeof(parent), &parent, NULL); CHECK_OPENCL_ERROR_IN("root parent device"); TEST_ASSERT(parent == NULL); /* partition type may either be NULL or contain a 0 entry */ err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE, 0, NULL, &ptype_size); CHECK_OPENCL_ERROR_IN("root partition type"); if (ptype_size != 0) { /* abuse dev_pt which should be large enough */ TEST_ASSERT(ptype_size == sizeof(cl_device_partition_property)); TEST_ASSERT(ptype_size <= dev_pt_size); err = clGetDeviceInfo(rootdev, CL_DEVICE_PARTITION_TYPE, ptype_size, dev_pt, NULL); CHECK_OPENCL_ERROR_IN("root partition type #2"); TEST_ASSERT(dev_pt[0] == 0); } // devices might be returned in different order than the counts // in the count_splitter int found_cus[2] = {0, 0}; /* now test the subdevices */ for (i = 0; i < 2; ++i) { err = clGetDeviceInfo(countdev[i], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(sub_cus), &sub_cus, NULL); CHECK_OPENCL_ERROR_IN("sub CU"); if (sub_cus == count_splitter[1]) found_cus[0] += 1; else if (sub_cus == count_splitter[2]) found_cus[1] += 1; err = clGetDeviceInfo(countdev[i], CL_DEVICE_PARENT_DEVICE, sizeof(parent), &parent, NULL); CHECK_OPENCL_ERROR_IN("sub parent device"); TEST_ASSERT(parent == rootdev); /* The partition type returned is up to the first 0, * which happens to be the CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, * not the final terminating 0 in count_splitter, so it has one less * element. It should be otherwise equal */ err = clGetDeviceInfo(countdev[i], CL_DEVICE_PARTITION_TYPE, 0, NULL, &ptype_size); CHECK_OPENCL_ERROR_IN("sub partition type"); TEST_ASSERT(ptype_size == sizeof(count_splitter) - sizeof(*count_splitter)); ptype = malloc(ptype_size); TEST_ASSERT(ptype); err = clGetDeviceInfo(countdev[i], CL_DEVICE_PARTITION_TYPE, ptype_size, ptype, NULL); CHECK_OPENCL_ERROR_IN("sub partition type #2"); TEST_ASSERT(memcmp(ptype, count_splitter, ptype_size) == 0); /* free the partition type */ free(ptype) ; ptype = NULL; } /* the previous loop finds 1+1 subdevices only on >dual core systems; * on dual cores, the count_splitter is [1, 1] and the above * "(sub_cus == count_splitter[x])" results in 2+0 subdevices found */ if (max_cus > 2) TEST_ASSERT(found_cus[0] == 1 && found_cus[1] == 1); else TEST_ASSERT((found_cus[0] + found_cus[1]) == 2); /* So far, so good. Let's now try and use these devices, * by building a program for all of them and launching kernels on them. * * Note that there's a discrepancy in behavior between implementations: * some assume you can treat sub-devices as their parent device, and thus * e.g. using them through any context which includes their parent devices, * other fail miserably if you try this. * * For the time being we will test the stricter behavior, where * sub-devices should be added manually to a context. */ err = clReleaseCommandQueue(q); CHECK_OPENCL_ERROR_IN("clReleaseCommandQueue"); err = clReleaseContext(ctx); CHECK_OPENCL_ERROR_IN("clReleaseContext"); /* if we split into 2 equal parts, third pointer is NULL. Let's copy the * previous device to it */ if (split == 2) eqdev[2] = eqdev[1]; ctx = clCreateContext(NULL, NUMDEVS, alldevs, NULL, NULL, &err); CHECK_OPENCL_ERROR_IN("clCreateContext"); TEST_ASSERT( test_context(ctx, prog_src_all, 1, NUMDEVS, alldevs) == CL_SUCCESS ); ctx = clCreateContext(NULL, NUMDEVS - 1, alldevs + 1, NULL, NULL, &err); CHECK_OPENCL_ERROR_IN("clCreateContext"); TEST_ASSERT( test_context(ctx, prog_src_two, -1, NUMDEVS - 1, alldevs + 1) == CL_SUCCESS ); /* Don't release the same device twice. clReleaseDevice(NULL) should return * an error but not crash. */ if (split == 2) eqdev[2] = NULL; for (i = 0; i < NUMDEVS; i++) clReleaseDevice (alldevs[i]); CHECK_CL_ERROR (clUnloadCompiler ()); free (dev_pt); printf ("OK\n"); return 0; }
int main(int argc, char *argv[]) { struct tls_config *conf; struct tls *ctx, *ocsp; struct tls_cert *cert; int res; const char *host; char buf[256]; if (argc < 2) errx(1, "give host as arg\n"); host = argv[1]; #ifdef USUAL_LIBSSL_FOR_TLS printf("libssl: %s\n", SSLeay_version(SSLEAY_VERSION)); #endif res = tls_init(); if (res < 0) errx(1, "tls_init"); conf = tls_config_new(); if (!conf) errx(1, "tls_config_new"); tls_config_set_protocols(conf, TLS_PROTOCOLS_ALL); tls_config_set_ciphers(conf, "fast"); ctx = tls_client(); if (!ctx) errx(1, "tls_client"); res = tls_configure(ctx, conf); if (res < 0) errx(1, "tls_configure: %s", tls_error(ctx)); res = tls_connect(ctx, host, "443"); if (res < 0) errx(1, "tls_connect: %s", tls_error(ctx)); res = tls_handshake(ctx); if (res < 0) errx(1, "tls_handshake: %s", tls_error(ctx)); res = tls_get_peer_cert(ctx, &cert, NULL); if (res < 0) errx(1, "tls_get_peer_cert: %s", tls_error(ctx)); tls_get_connection_info(ctx, buf, sizeof buf); printf("Connection: '%s'\n", buf); printf(" CN='%s'\n", cert->subject.common_name); printf(" C='%s'\n", cert->subject.country_name); printf(" ST='%s'\n", cert->subject.state_or_province_name); printf(" L='%s'\n", cert->subject.locality_name); printf(" S='%s'\n", cert->subject.street_address); printf(" O='%s'\n", cert->subject.organization_name); printf(" OU='%s'\n", cert->subject.organizational_unit_name); show_ocsp_info("OCSP stapling", ctx); ocsp = NULL; res = tls_ocsp_check_peer(&ocsp, NULL, ctx); if (ocsp) { show_ocsp_info("OCSP responder", ocsp); tls_free(ocsp); } else if (res == TLS_NO_OCSP) { printf("OCSP responder: No OCSP support in libtls\n"); } if (0) test_context(ctx); tls_close(ctx); tls_free(ctx); tls_config_free(conf); tls_cert_free(cert); return 0; }
static int test_def_context(void) { return test_context(NULL); }