int main(int argc, char *argv[]) { int retval = 0; int i; su_init(); for (i = 1; argv[i]; i++) { if (strcmp(argv[i], "-v") == 0) tstflags |= tst_verbatim; else if (strcmp(argv[i], "-a") == 0) tstflags |= tst_abort; else usage(1); } retval |= test_sockaddr(); retval |= test_sendrecv(); retval |= test_select(); retval |= test_md5(); fflush(stdout); su_deinit(); return retval; }
END_TEST START_TEST (test_symbol) { const char *commands[] = {"c1, symbol o+c", "c2, symbol O", "c3, symbol C", "c4, symbol O AND symbol C", "c5, symbol O OR symbol C", "c6, symbol O+C+SE", "c7, symbol SE", "c8, symbol O+C+SE and not symbol se"}; test_select(commands,8); ck_assert_str_eq(selection_name[0], "c1"); ck_assert_str_eq(selection_name[1], "c2"); ck_assert_str_eq(selection_name[2], "c3"); ck_assert(value[0] > 5); //just to check that it's non-zero ck_assert(float_eq(value[0], addup(symb_O,result) + addup(symb_C,result), 1e-10)); ck_assert(float_eq(value[1], addup(symb_O,result), 1e-10)); ck_assert(float_eq(value[2], addup(symb_C,result), 1e-10)); ck_assert(float_eq(value[3], 0, 1e-10)); ck_assert(float_eq(value[4], value[0], 1e-10)); ck_assert(float_eq(value[5], addup(symb_O,result) + addup(symb_C,result) + addup(symb_SE,result), 1e-10)); ck_assert(float_eq(value[6], addup(symb_SE,result), 1e-10)); ck_assert(float_eq(value[7], value[0], 1e-10)); }
END_TEST START_TEST (test_resi) { const char *commands[] = {"c1, resi 1+2-4", "c2, resi 2-4", "c3, resi 1", "c4, resi 1 AND resi 2-4", "c5, resi 1 OR resi 2-4", "c6, resi 1-2+2-4", "c7, resi 1+2-4+3", "c8, resi 1-2+7+9+3-5+100", "c9, resi 1-4 AND NOT resi 2-4"}; freesasa_set_verbosity(FREESASA_V_SILENT); test_select(commands,9); freesasa_set_verbosity(FREESASA_V_NORMAL); ck_assert(value[0] > 5); ck_assert(float_eq(value[0], addup(resi_1,result) + addup(resi_2r4,result), 1e-10)); ck_assert(float_eq(value[1], addup(resi_2r4,result), 1e-10)); ck_assert(float_eq(value[2], addup(resi_1,result), 1e-10)); ck_assert(float_eq(value[3], 0, 1e-10)); ck_assert(float_eq(value[4], value[0], 1e-10)); ck_assert(float_eq(value[5], value[0], 1e-10)); ck_assert(float_eq(value[6], value[0], 1e-10)); ck_assert(float_eq(value[7], value[0], 1e-10)); ck_assert(float_eq(value[8], value[2], 1e-10)); }
int main(int argc, char **argv) { init_apr_lib(); test_add(); test_select(); free_apr_lib(); return 0; }
/* ************************************************************************* Name: main ************************************************************************* */ int main (int argc, char * argv[]) { /* test_altivec_feature will exit if the processor */ /* can not do altivec */ test_altivec_feature(); /* test the select feature */ test_select(); return(0); }
int main(int argc, char **argv) { int i; SQLLEN bytes_returned; /* do not allocate so big memory in stack */ buf = (unsigned char *) malloc(TEST_BUF_LEN); odbc_connect(); odbc_command("create table " TEST_TABLE_NAME " (im IMAGE)"); odbc_command("SET TEXTSIZE 1000000"); /* populate test buffer with ramp */ for (i = 0; i < TEST_BUF_LEN; i++) { buf[i] = BYTE_AT(i); } /* insert test pattern into database */ if (test_insert(buf, TEST_BUF_LEN) == -1) { clean_up(); return -1; } memset(buf, 0, TEST_BUF_LEN); /* read test pattern from database */ if (test_select(buf, TEST_BUF_LEN, &bytes_returned) == -1) { clean_up(); return -1; } /* compare inserted and read back test patterns */ if (bytes_returned != TEST_BUF_LEN) { show_error("main(): comparing buffers", "Mismatch in input and output pattern sizes."); clean_up(); return -1; } for (i = 0; i < TEST_BUF_LEN; ++i) { if (buf[i] != BYTE_AT(i)) { printf("mismatch at pos %d %d != %d\n", i, buf[i], BYTE_AT(i)); show_error("main(): comparing buffers", "Mismatch in input and output patterns."); clean_up(); return -1; } } printf("Input and output buffers of length %d match.\nTest passed.\n", TEST_BUF_LEN); clean_up(); return 0; }
int main() { int tx_port = 0; char *source = "test/test_defs.b"; sys_init(0); tx_server(source, "bin/state", &tx_port); vol_init(0, "bin/volume"); char *code = sys_load(source); env = env_new(source, code); mem_free(code); int len = 0; char **files = sys_list("test/data", &len); vars = vars_new(len); rvars = vars_new(len); for (int i = 0; i < len; ++i) { vars_add(rvars, files[i], 0, NULL); vars_add(vars, files[i], 0, NULL); } vars_add(vars, "___param", 0, NULL); test_vars(); test_load(); test_param(); test_clone(); test_eq(); test_store(); test_select(); test_rename(); test_extend(); test_join(); test_project(); test_semidiff(); test_summary(); test_union(); test_compound(); test_call(); tx_free(); env_free(env); mem_free(files); vars_free(vars); vars_free(rvars); return 0; }
END_TEST START_TEST (test_resn) { const char *commands[] = {"c1, resn ala+arg", "c2, resn ala", "c3, resn arg", "c4, resn ala AND resn arg", "c5, resn ala OR resn arg", "c6, resn ala+arg AND NOT resn arg"}; test_select(commands,6); ck_assert(value[0] > 5); ck_assert(float_eq(value[0], addup(resn_A,result) + addup(resn_R,result), 1e-10)); ck_assert(float_eq(value[1], addup(resn_A,result), 1e-10)); ck_assert(float_eq(value[2], addup(resn_R,result), 1e-10)); ck_assert(float_eq(value[3], 0, 1e-10)); ck_assert(float_eq(value[4], value[0], 1e-10)); ck_assert(float_eq(value[5], value[1], 1e-10)); }
END_TEST START_TEST (test_chain) { const char *commands[] = {"c1, chain A+B", "c2, chain A", "c3, chain B", "c4, chain A AND chain B", "c5, chain A OR chain B", "c6, chain A-B", "c7, chain A-B AND NOT chain A"}; test_select(commands,7); ck_assert(value[0] > 5); ck_assert(float_eq(value[0], addup(chain_A,result) + addup(chain_B,result), 1e-10)); ck_assert(float_eq(value[0], value[4], 1e-10)); ck_assert(float_eq(value[0], value[5], 1e-10)); ck_assert(float_eq(value[1], addup(chain_A,result), 1e-10)); ck_assert(float_eq(value[2], addup(chain_B,result), 1e-10)); ck_assert(float_eq(value[3], 0, 1e-10)); ck_assert(float_eq(value[6], addup(chain_B,result), 1e-10)); }
int main(int argc, char *argv[]) { unsigned int a, b, i, j; int c, d; unsigned char e, f; int num_failed = 0, num_all = 0; fprintf(stdout, "Testing constant time operations...\n"); for (i = 0; i < OSSL_NELEM(test_values); ++i) { a = test_values[i]; num_failed += test_is_zero(a); num_failed += test_is_zero_8(a); num_all += 2; for (j = 0; j < OSSL_NELEM(test_values); ++j) { b = test_values[j]; num_failed += test_binary_op(&constant_time_lt, "constant_time_lt", a, b, a < b); num_failed += test_binary_op_8(&constant_time_lt_8, "constant_time_lt_8", a, b, a < b); num_failed += test_binary_op(&constant_time_lt, "constant_time_lt_8", b, a, b < a); num_failed += test_binary_op_8(&constant_time_lt_8, "constant_time_lt_8", b, a, b < a); num_failed += test_binary_op(&constant_time_ge, "constant_time_ge", a, b, a >= b); num_failed += test_binary_op_8(&constant_time_ge_8, "constant_time_ge_8", a, b, a >= b); num_failed += test_binary_op(&constant_time_ge, "constant_time_ge", b, a, b >= a); num_failed += test_binary_op_8(&constant_time_ge_8, "constant_time_ge_8", b, a, b >= a); num_failed += test_binary_op(&constant_time_eq, "constant_time_eq", a, b, a == b); num_failed += test_binary_op_8(&constant_time_eq_8, "constant_time_eq_8", a, b, a == b); num_failed += test_binary_op(&constant_time_eq, "constant_time_eq", b, a, b == a); num_failed += test_binary_op_8(&constant_time_eq_8, "constant_time_eq_8", b, a, b == a); num_failed += test_select(a, b); num_all += 13; } } for (i = 0; i < OSSL_NELEM(signed_test_values); ++i) { c = signed_test_values[i]; for (j = 0; j < OSSL_NELEM(signed_test_values); ++j) { d = signed_test_values[j]; num_failed += test_select_int(c, d); num_failed += test_eq_int(c, d); num_failed += test_eq_int_8(c, d); num_all += 3; } } for (i = 0; i < sizeof(test_values_8); ++i) { e = test_values_8[i]; for (j = 0; j < sizeof(test_values_8); ++j) { f = test_values_8[j]; num_failed += test_select_8(e, f); num_all += 1; } } if (!num_failed) { fprintf(stdout, "ok (ran %d tests)\n", num_all); return EXIT_SUCCESS; } else { fprintf(stdout, "%d of %d tests failed!\n", num_failed, num_all); return EXIT_FAILURE; } }
int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 10; acl::string addr("127.0.0.1:6379"), cmd; bool slice_req = false; while ((ch = getopt(argc, argv, "hs:n:C:I:a:S")) > 0) { switch (ch) { case 'h': usage(argv[0]); return 0; case 's': addr = optarg; break; case 'n': n = atoi(optarg); break; case 'C': conn_timeout = atoi(optarg); break; case 'I': rw_timeout = atoi(optarg); break; case 'a': cmd = optarg; break; case 'S': slice_req = true; break; default: break; } } acl::acl_cpp_init(); acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); client.set_slice_request(slice_req); acl::redis_connection redis(&client); bool ret; if (cmd == "auth") ret = test_auth(redis); else if (cmd == "echo") ret = test_echo(redis, n); else if (cmd == "ping") ret = test_ping(redis, n); else if (cmd == "quit") ret = test_quit(redis); else if (cmd == "select") ret = test_select(redis, n); else if (cmd == "all") { ret = test_auth(redis) && test_echo(redis, n) && test_ping(redis, n) && test_select(redis, n) && test_quit(redis); } else { printf("unknown cmd: %s\r\n", cmd.c_str()); ret = false; } printf("cmd: %s %s\r\n", cmd.c_str(), ret ? "ok" : "failed"); #ifdef WIN32 printf("enter any key to exit\r\n"); getchar(); #endif return 0; }
int main() { INDEX *idx = NULL; //test case for idx_create /* printf ("test case for idx_create() ********************************\n"); idx = idx_create("index_testfile", 2000); if (NULL == idx) { printf ("idx_fd is null.\n"); return -1; } printf("is_change:%d\ncur_kv_count:%d\nhashhead_size:%llu\nnode_pool_size:%llu\n", idx->is_change, idx->cur_kv_count, idx->hashhead_size, idx->node_pool_size); printf("free_node_pool_size:%llu\nfree_node_count:%llu\ntimestamp:%llu\n", idx->free_node_pool_size, idx->free_node_count, idx->timestamp); if (NULL == idx->hash_head || NULL == idx->node_pool || NULL == idx->free_node_pool) { printf ("idx some struct is NULL.\n"); return -1; } idx_exit(idx); idx = NULL; */ printf ("***********************************************************\n\n\n"); //test case for idx_load printf ("test case for idx_load() ********************************\n"); idx = idx_load("index_testfile"); if (NULL == idx) { printf ("idx_fd is null.\n"); return -1; } printf("is_change:%d\ncur_kv_count:%d\nhashhead_size:%llu\nnode_pool_size:%llu\n", idx->is_change, idx->cur_kv_count, idx->hashhead_size, idx->node_pool_size); printf("free_node_pool_size:%llu\nfree_node_count:%llu\ntimestamp:%llu\n", idx->free_node_pool_size, idx->free_node_count, idx->timestamp); if (NULL == idx->hash_head || NULL == idx->node_pool || NULL == idx->free_node_pool) { printf ("idx some struct is NULL.\n"); return -1; } printf ("***********************************************************\n\n\n"); //test case for insert printf ("test case for insert ********************************\n"); test_insert(idx, 1101, 1806); test_insert(idx, 1102, 1807); test_insert(idx, 1102, 1808); test_insert(idx, 1102, 1807); printf ("***********************************************************\n\n\n"); //test case for select printf ("test case for select ********************************\n"); test_select(idx, 1806); test_select(idx, 1807); test_select(idx, 1806); test_select(idx, 1806); test_select(idx, 1805); test_select(idx, 1808); printf ("***********************************************************\n\n\n"); //test case for delete printf ("test case for delete ********************************\n"); test_delete(idx, 1111, 1806); test_delete(idx, 1112, 1806); printf ("***********************************************************\n\n\n"); idx_exit(idx); return 0; }
int main(int argc, char **argv) { int mfd,sfd; int status; struct termios t; char buffer[80]; char *tomaster = "2MASTER\n"; char *toslave = "2SLAVE\n"; char name[16]; char *ttynam; struct stat sb; if (openpty(&mfd,&sfd,name,0,0) < 0) { printf("out of ptys\n"); return -1; } printf("opened: %s\n",name); master = mfd; slave = sfd; printf("testing ttyname\n"); if (ttynam = ttyname(master)) { name[5] = 'p'; printf("opened pty: %s, ttyname returned on master %s\n", name,ttynam); if (!strcmp(name,ttynam)) printf("Ok\n"); else printf("Failed ttyname for master\n"); if (!stat(name,&sb)) { print_statbuf(name,&sb); } else { printf("could not do stat on %s errno: %d\n",name,errno); } } else { printf("could not do ttyname on master fd\n"); } if (ttynam = ttyname(slave)) { name[5] = 't'; printf("opened pty: %s, ttyname returned on slave %s\n", name,ttynam); if (!strcmp(name,ttynam)) printf("Ok\n"); else printf("Failed ttyname for slave\n"); if (!stat(name,&sb)) { print_statbuf(name,&sb); } else { printf("could not do stat on %s errno: %d\n",name,errno); } } else { printf("could not do ttyname on slave fd\n"); } probefd(); if (test_select() == 0) {printf("test_select ok\n");} #if 0 return 0; test_nonblocking(); test_blocking(); test_raw(); #endif if (fork() != 0) { printf("going to read slave\n"); if ((status = read(sfd,buffer,76)) > 0) { buffer[status] = 0; printf("0read slave: \"%s\"\n",buffer); } else { printf("0read slave returned: %d, errno: %d\n",status,errno); } } else { printf("parent should be blocking for 3 seconds\n"); sleep (3); printf("writing data...\n"); write(mfd,"wakeup\n",7); printf("wrote data\n"); exit(0); } #if 1 printf("setting master and slave nonblocking\n"); fcntl(mfd,F_SETFL,O_NONBLOCK); fcntl(sfd,F_SETFL,O_NONBLOCK); #endif #if 0 assert(tcgetattr(sfd,&t) == 0); t.c_lflag &= ~(ICANON); /* make it raw */ t.c_cc[VMIN] = 10; t.c_cc[VTIME] = 2; (void) tcsetattr(sfd, TCSAFLUSH, &t); #endif assert(tcgetattr(mfd,&t) == 0); assert(tcgetattr(sfd,&t) == 0); printf("echo: %d echonl: %d\n", t.c_lflag & ECHO,t.c_lflag & ECHONL); #if 0 return (doshell(mfd,sfd)); #endif probefd(); if ((status = read(mfd,buffer,80)) > 0) { buffer[status] = 0; printf("1read master (echo on): \"%s\"\n",buffer); } else { printf("1read master returned: %d, errno: %d\n",status,errno); } if ((status = read(sfd,buffer,80)) > 0) { buffer[status] = 0; printf("2read slave (echo on): \"%s\"\n",buffer); } else { printf("2read slave returned: %d, errno: %d\n",status,errno); } if (fork() == 0) { /* child */ write(mfd,tomaster,strlen(tomaster)); exit(0); } sleep(2); write(sfd,toslave,strlen(toslave)); if ((status = read(mfd,buffer,80)) > 0) { buffer[status] = 0; printf("3read master (echo on): \"%s\"\n",buffer); } else { printf("3read master returned: %d, errno: %d\n",status,errno); } if ((status = read(sfd,buffer,80)) > 0) { buffer[status] = 0; printf("4read slave (echo on): \"%s\"\n",buffer); } else { printf("4read slave returned: %d, errno: %d\n",status,errno); } assert(tcgetattr(mfd,&t) == 0); assert(tcgetattr(sfd,&t) == 0); t.c_lflag &= ~(ECHO); t.c_lflag |= ECHONL; (void) tcsetattr(sfd, TCSANOW, &t); printf("echo: %d echonl: %d\n", t.c_lflag & ECHO,t.c_lflag & ECHONL); write(mfd,tomaster,strlen(tomaster)); write(sfd,toslave,strlen(toslave)); probefd(); if ((status = read(mfd,buffer,80)) > 0) { buffer[status] = 0; printf("5read master (echo off): \"%s\"\n",buffer); } else { printf("5read master returned: %d\n",status); } probefd(); if ((status = read(sfd,buffer,80)) > 0) { buffer[status] = 0; printf("6read slave: \"%s\"\n",buffer); } else { printf("6read slave returned: %d\n",status); } probefd(); (void) close(sfd); (void) close(mfd); return 0; }