int run_basic_tests(void) { int passed_count = 0; TEST_FUNC(test_detect_not_power_of_two()); TEST_FUNC(test_alloc_and_free()); TEST_FUNC(test_SPSC_add_and_remove_elem()); TEST_FUNC(test_SPSC_add_and_remove_elems_BULK()); TEST_FUNC(test_late_void_ptr_cast_BULK()); return passed_count; }
/* * Main routine for the basic test */ int main(int argc, const char *const argv[]) { int ret; ret = 0; /* Run tests */ TEST_FUNC("init6", test_init, ret); TEST_FUNC("lookup6", test_lookup, ret); TEST_FUNC("lookup6_fullroute", test_lookup_linx, ret); return ret; }
/// run this category of tests virtual void run_test(void) const throw() { printf( "\n" FLTL_F_UNDER "%s" FLTL_F_DEF ": %s\n", func_name, message ); TEST_FUNC(); }
unsigned n_cl_infos); void test_basic_hashtable_1bucket(); void test_basic_hashtable2_1bucket(); void test_basic_hashtable_nbuckets(); void test_basic_hashtable2_nbuckets(); void test_basic_height_balanced_tree(); void test_basic_path_reduction_tree(); void test_basic_red_black_tree(); void test_basic_skiplist(); void test_basic_splay_tree(); void test_basic_treap(); void test_basic_weight_balanced_tree(); void test_version_string(); CU_TestInfo basic_tests[] = { TEST_FUNC(test_basic_hashtable_1bucket), TEST_FUNC(test_basic_hashtable2_1bucket), TEST_FUNC(test_basic_hashtable_nbuckets), TEST_FUNC(test_basic_hashtable2_nbuckets), TEST_FUNC(test_basic_height_balanced_tree), TEST_FUNC(test_basic_path_reduction_tree), TEST_FUNC(test_basic_red_black_tree), TEST_FUNC(test_basic_skiplist), TEST_FUNC(test_basic_splay_tree), TEST_FUNC(test_basic_treap), TEST_FUNC(test_basic_weight_balanced_tree), TEST_FUNC(test_version_string), CU_TEST_INFO_NULL }; #define TEST_SUITE(suite) { #suite, NULL, NULL, suite }
int main(){ tnn_state s[N]; tnn_state t, u, v; tnn_param p; tnn_state *sp; int i,j; //Initialize all the states for(i = 0; i < N; i = i + 1){ printf("Initializing state %d: %s\n", i, TEST_FUNC(tnn_state_init(&s[i], i + M))); printf("Initialized state %d to be size %d, valid %d.\n", i, s[i].size, s[i].valid); } //Initialize the parameter printf("Initializing parameter: %s\n", TEST_FUNC(tnn_param_init(&p))); tnn_param_debug(&p); //Allocate states in the paramter for(i = 0; i < N; i = i + 1){ printf("Allocating state %d: %s\n", i, TEST_FUNC(tnn_param_state_alloc(&p, &s[i]))); printf("Allocated state %d to be valid %d, vector owner %d.\n", i, s[i].valid, s[i].x.owner); tnn_param_debug(&p); } //Initialize the values in the vector for(i = 0; i < p.x->size; i = i + 1){ gsl_vector_set(p.x, i, i + A); gsl_vector_set(p.dx, i, i + B); } tnn_param_debug(&p); //Initialize values for t using calloc printf("Initializing state t: %s\n", TEST_FUNC(tnn_state_init(&t, I))); printf("Initialized state t to be size %d, valid %d.\n", t.size, t.valid); printf("Allocating state t: %s\n", TEST_FUNC(tnn_param_state_calloc(&p, &t))); printf("Allocated state t to be valid %d, vector owner %d.\n", t.valid, t.x.owner); tnn_param_debug(&p); printf("Initializing state u: %s\n", TEST_FUNC(tnn_state_init(&u, J))); printf("Getting subvector u: %s\n", TEST_FUNC(tnn_param_state_sub(&p, &s[N-1], &u, 1))); tnn_param_debug(&p); printf("Initializing state v: %s\n", TEST_FUNC(tnn_state_init(&v, s[N-1].size))); tnn_state_debug(&v); printf("Allocating state v: %s\n", TEST_FUNC(tnn_param_state_calloc(&p, &v))); printf("Copying s to v: %s\n", TEST_FUNC(tnn_state_copy(&s[N-1],&v))); tnn_state_debug(&v); tnn_param_debug(&p); //Destroy the parameter printf("Destroying the paramter: %s.\n", TEST_FUNC(tnn_param_destroy(&p))); printf("Destroyed paramter x = %d, dx = %d, states = %d, size = %d.\n", p.x, p.dx, p.states, p.size); for(i = 0; i < N; i = i + 1){ printf("Destroyed state %d, valid: %d\n", i, s[i].valid); } printf("Destroyed state t, valid: %d\n", t.valid); printf("Destroyed state u, valid: %d\n", u.valid); tnn_param_debug(&p); //Delete paramter experiment printf("Initializing paramter: %s\n", TEST_FUNC(tnn_param_init(&p))); for(i = 0; i < N; i = i + 1){ sp = (tnn_state *) malloc(sizeof(tnn_state)); printf("Initializing sp %p: %s\n", sp, TEST_FUNC(tnn_state_init(sp,A+i))); printf("Allocating sp %p: %s\n", sp, TEST_FUNC(tnn_param_state_calloc(&p, sp))); } printf("Debugging paramter: %s\n", TEST_FUNC(tnn_param_debug(&p))); printf("Free paramter: %s\n", TEST_FUNC(tnn_param_free(&p))); printf("Debugging paramter: %s\n", TEST_FUNC(tnn_param_debug(&p))); }
int main(){ tnn_param p, q, io, oi; tnn_state in, out; tnn_module m, l; int i; tnn_pstable t; srand(time(NULL)); printf("Initializing state in: %s\n", TEST_FUNC(tnn_state_init(&in, A))); printf("Initializing state out: %s\n", TEST_FUNC(tnn_state_init(&out, B))); printf("Initializing paramter p: %s\n", TEST_FUNC(tnn_param_init(&p))); printf("Initializing paramter io: %s\n", TEST_FUNC(tnn_param_init(&io))); printf("Allocating state in: %s\n", TEST_FUNC(tnn_param_state_alloc(&io, &in))); printf("Allocating state out: %s\n", TEST_FUNC(tnn_param_state_alloc(&io, &out))); printf("Allocating state out again: %s\n", TEST_FUNC(tnn_param_state_alloc(&io, &out))); printf("Initializing module m: %s\n", TEST_FUNC(tnn_module_init_linear(&m, &in, &out, &p))); printf("Initialized module t = %ld, c = %ld, w.size = %d, input = %ld, output = %ld, bprop = %ld, fprop = %ld, randomize = %ld, destroy = %ld\n", (long)m.t, (long)m.c, (int)m.w.size, (long)m.input, (long)m.output, (long)m.bprop, (long)m.fprop, (long)m.randomize, (long)m.destroy); printf("Setting input\n"); for(i = 0; i < in.size; i = i + 1){ gsl_vector_set(&in.x, i, (double)(C+i)); } printf("Debugging using polymorphic call: %s\n", TEST_FUNC(tnn_module_debug(&m))); printf("Setting output\n"); for(i = 0; i < out.size; i = i + 1){ gsl_vector_set(&out.dx, i, E + (double)i/10.0); } printf("Debugging using polymorphic call: %s\n", TEST_FUNC(tnn_module_debug(&m))); printf("Radomizing weights using polymorphic call: %s\n", TEST_FUNC(tnn_module_randomize(&m, 1.0))); printState(&m.w); printf("Executing fprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_fprop(&m))); printState(&out); printf("Executing bprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_bprop(&m))); printf("Debugging using polymorphic call: %s\n", TEST_FUNC(tnn_module_debug(&m))); //Cloning test printf("Initializing parameter q: %s\n", TEST_FUNC(tnn_param_init(&q))); printf("Initializing parameter oi: %s\n", TEST_FUNC(tnn_param_init(&oi))); printf("Initializing pstable t: %s\n", TEST_FUNC(tnn_pstable_init(&t))); printf("Constructing t with oi from io: %s\n", TEST_FUNC(tnn_pstable_param_alloc(&t, &io, &oi))); printf("Debugging pstable t: %s\n", TEST_FUNC(tnn_pstable_debug(&t))); printf("Debugging paramter oi: %s\n", TEST_FUNC(tnn_param_debug(&oi))); printf("Cloning m to l: %s\n", TEST_FUNC(tnn_module_clone(&m,&l,&q, &t))); printf("Debugging l: %s\n", TEST_FUNC(tnn_module_debug(&l))); printf("Radomizing weights using polymorphic call: %s\n", TEST_FUNC(tnn_module_randomize(&l, 1.0))); printf("Executing fprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_fprop(&l))); printf("Executing bprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_bprop(&l))); printf("Debugging l: %s\n", TEST_FUNC(tnn_module_debug(&l))); printf("Freeing paramter oi: %s\n", TEST_FUNC(tnn_param_free(&oi))); printf("Destroying paramter q: %s\n", TEST_FUNC(tnn_param_destroy(&q))); printf("Destroying pstable t: %s\n", TEST_FUNC(tnn_pstable_destroy(&t))); printf("Destroying paramter p: %s\n", TEST_FUNC(tnn_param_destroy(&p))); printf("Destroying paramter io: %s\n", TEST_FUNC(tnn_param_destroy(&io))); printf("Radomizing weights using polymorphic call: %s\n", TEST_FUNC(tnn_module_randomize(&m, 1.0))); printf("Executing fprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_fprop(&m))); printf("Executing bprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_bprop(&m))); printf("Destroy module m using polymorphic call: %s\n", TEST_FUNC(tnn_module_destroy(&m))); return 0; }
int main(int argc, char *argv[]) { char buffer[256]; /* * get_user_config_file() */ #define TEST_RESULT "/home/test/.config/test-linux.conf" #define TEST_FUNC get_user_config_file test_env_xdg_valid = 1; test_env_home_valid = 1; TEST_FUNC(buffer, 5, "test-linux"); CHECK_RESULT("", "returns empty string when buffer is too small."); test_env_xdg_valid = 1; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $HOME and not $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 0; RUN_TEST("", "returns empty string when $XDG_CONFIG_HOME and $HOME are absent."); #undef TEST_FUNC #undef TEST_RESULT /* * get_user_config_folder() */ #define TEST_RESULT "/home/test/.config/test-linux/" #define TEST_FUNC get_user_config_folder test_env_xdg_valid = 1; test_env_home_valid = 1; TEST_FUNC(buffer, 5, "test-linux"); CHECK_RESULT("", "returns empty string when buffer is too small."); test_env_xdg_valid = 1; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $HOME and not $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 0; RUN_TEST("", "returns empty string when $XDG_CONFIG_HOME and $HOME are absent."); #undef TEST_FUNC #undef TEST_RESULT /* * get_user_data_folder() */ #define TEST_RESULT "/home/test/.local/share/test-linux/" #define TEST_FUNC get_user_data_folder test_env_xdg_valid = 1; test_env_home_valid = 1; TEST_FUNC(buffer, 5, "test-linux"); CHECK_RESULT("", "returns empty string when buffer is too small."); test_env_xdg_valid = 1; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $HOME and not $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 0; RUN_TEST("", "returns empty string when $XDG_CONFIG_HOME and $HOME are absent."); #undef TEST_FUNC #undef TEST_RESULT /* * get_user_cache_folder() */ #define TEST_RESULT "/home/test/.cache/test-linux/" #define TEST_FUNC get_user_cache_folder test_env_xdg_valid = 1; test_env_home_valid = 1; TEST_FUNC(buffer, 5, "test-linux"); CHECK_RESULT("", "returns empty string when buffer is too small."); test_env_xdg_valid = 1; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 1; RUN_TEST(TEST_RESULT, "works with $HOME and not $XDG_CONFIG_HOME."); test_env_xdg_valid = 0; test_env_home_valid = 0; RUN_TEST("", "returns empty string when $XDG_CONFIG_HOME and $HOME are absent."); #undef TEST_FUNC #undef TEST_RESULT printf("All tests passed for platform: Linux.\n"); return 0; }
int main(){ double l; tnn_reg l1; tnn_reg l2; gsl_vector *w; gsl_vector *d; int i; //Initializing regularizers printf("Initializing l1 regularizer: %s\n", TEST_FUNC(tnn_reg_init_l1(&l1))); printf("Initializing l2 regularizer: %s\n", TEST_FUNC(tnn_reg_init_l2(&l2))); printf("Debugging l1 regularizer: %s\n", TEST_FUNC(tnn_reg_debug(&l1))); printf("Debugging l2 regularizer: %s\n", TEST_FUNC(tnn_reg_debug(&l2))); //Allocating vectors printf("Allocating vectors\n"); w = gsl_vector_alloc(A); d = gsl_vector_alloc(A); for(i = 0; i < w->size; i = i + 1){ gsl_vector_set(w, i, (double)(B - i)); } printf("w:"); printVector(w); printf("d:"); printVector(d); printf("Test l1 loss: %s\n", TEST_FUNC(tnn_reg_l(&l1, w, &l))); printf("%g\n", l); printf("Test l2 loss: %s\n", TEST_FUNC(tnn_reg_l(&l2, w, &l))); printf("%g\n", l); printf("TEST l1 derivatives: %s\n", TEST_FUNC(tnn_reg_d(&l1, w, d))); printVector(d); printf("TEST l2 derivatives: %s\n", TEST_FUNC(tnn_reg_d(&l2, w, d))); printVector(d); printf("Test l1 add loss: %s\n", TEST_FUNC(tnn_reg_addl(&l1, w, &l))); printf("%g\n", l); printf("Test l2 add loss: %s\n", TEST_FUNC(tnn_reg_addl(&l2, w, &l))); printf("%g\n", l); printf("Test l1 add derivatives: %s\n", TEST_FUNC(tnn_reg_addd(&l1, w, d, 0.5))); printVector(d); printf("Test l2 add derivatives: %s\n", TEST_FUNC(tnn_reg_addd(&l2, w, d, 0.5))); printVector(d); printf("Destroying l1 regularizer: %s\n", TEST_FUNC(tnn_reg_destroy(&l1))); printf("Destroying l2 regularizer: %s\n", TEST_FUNC(tnn_reg_destroy(&l2))); return 0; }
int main(int argc, char *argv[]) { uint32_t opcode; uint64_t test_srvid[] = { CTDB_SRVID_BANNING, CTDB_SRVID_ELECTION, CTDB_SRVID_RECONFIGURE, CTDB_SRVID_RELEASE_IP, CTDB_SRVID_TAKE_IP, CTDB_SRVID_SET_NODE_FLAGS, CTDB_SRVID_RECD_UPDATE_IP, CTDB_SRVID_VACUUM_FETCH, CTDB_SRVID_DETACH_DATABASE, CTDB_SRVID_MEM_DUMP, CTDB_SRVID_GETLOG, CTDB_SRVID_CLEARLOG, CTDB_SRVID_PUSH_NODE_FLAGS, CTDB_SRVID_RELOAD_NODES, CTDB_SRVID_TAKEOVER_RUN, CTDB_SRVID_REBALANCE_NODE, CTDB_SRVID_DISABLE_TAKEOVER_RUNS, CTDB_SRVID_DISABLE_RECOVERIES, CTDB_SRVID_DISABLE_IP_CHECK, }; int i; if (argc == 2) { int seed = atoi(argv[1]); srandom(seed); } TEST_FUNC(ctdb_req_header)(); TEST_FUNC(ctdb_req_call)(); TEST_FUNC(ctdb_reply_call)(); TEST_FUNC(ctdb_reply_error)(); TEST_FUNC(ctdb_req_dmaster)(); TEST_FUNC(ctdb_reply_dmaster)(); for (opcode=0; opcode<NUM_CONTROLS; opcode++) { TEST_FUNC(ctdb_req_control_data)(opcode); } for (opcode=0; opcode<NUM_CONTROLS; opcode++) { TEST_FUNC(ctdb_reply_control_data)(opcode); } for (opcode=0; opcode<NUM_CONTROLS; opcode++) { TEST_FUNC(ctdb_req_control)(opcode); } for (opcode=0; opcode<NUM_CONTROLS; opcode++) { TEST_FUNC(ctdb_reply_control)(opcode); } for (i=0; i<ARRAY_SIZE(test_srvid); i++) { TEST_FUNC(ctdb_message_data)(test_srvid[i]); } for (i=0; i<ARRAY_SIZE(test_srvid); i++) { TEST_FUNC(ctdb_req_message)(test_srvid[i]); } TEST_FUNC(ctdb_req_message_data)(); TEST_FUNC(ctdb_req_keepalive)(); TEST_FUNC(ctdb_req_tunnel)(); return 0; }
int main(){ tnn_param p, io; tnn_state in, out, *s; tnn_module m; int i; printf("Initializing state in: %s\n", TEST_FUNC(tnn_state_init(&in, A))); printf("Initializing state out: %s\n", TEST_FUNC(tnn_state_init(&out, B))); printf("Initializing paramter p: %s\n", TEST_FUNC(tnn_param_init(&p))); printf("Initializing paramter io: %s\n", TEST_FUNC(tnn_param_init(&io))); printf("Allocating state in: %s\n", TEST_FUNC(tnn_param_state_alloc(&io, &in))); printf("Allocating state out: %s\n", TEST_FUNC(tnn_param_state_alloc(&io, &out))); printf("Initializing module m: %s\n", TEST_FUNC(tnn_module_init_sum(&m, &in, &out, &io))); printf("Debugging module m: %s\n", TEST_FUNC(tnn_module_debug(&m))); printf("Setting input\n"); for(i = 0; i < in.size; i = i + 1){ gsl_vector_set(&in.x, i, (double)(C+i)); } printf("Setting output\n"); for(i = 0; i < out.size; i = i + 1){ gsl_vector_set(&out.dx, i, 2.0*(double)(D+i)); } printf("Radomizing weights using polymorphic call: %s\n", TEST_FUNC(tnn_module_randomize(&m, 1.0))); printf("Debugging module m: %s\n", TEST_FUNC(tnn_module_debug(&m))); printf("Executing fprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_fprop(&m))); printf("Debugging module m: %s\n", TEST_FUNC(tnn_module_debug(&m))); printf("Executing bprop using polymorphic call: %s\n", TEST_FUNC(tnn_module_bprop(&m))); printf("Debugging module m: %s\n", TEST_FUNC(tnn_module_debug(&m))); for(i = 0; i < A/B; i = i + 1){ printf("Executing get: %s\n", TEST_FUNC(tnn_module_sum_get(&m, &s, i))); printf("Debugging s: %s\n", TEST_FUNC(tnn_state_debug(s))); } printf("Debugging parameter p: %s\n", TEST_FUNC(tnn_param_debug(&p))); printf("Debugging parameter io: %s\n", TEST_FUNC(tnn_param_debug(&io))); printf("Destroying paramter p: %s\n", TEST_FUNC(tnn_param_destroy(&p))); printf("Destroying paramter io: %s\n", TEST_FUNC(tnn_param_destroy(&io))); printf("Destroy module m using polymorphic call: %s\n", TEST_FUNC(tnn_module_destroy(&m))); printf("Debugging module m: %s\n", TEST_FUNC(tnn_module_debug(&m))); return 0; }
int main(){ tnn_trainer_class t; tnn_machine *m; tnn_loss *l; tnn_reg *r; tnn_state *label; tnn_module *mout; tnn_module *min; tnn_param *p; tnn_state *sin; tnn_state *sout; tnn_state *in; tnn_state *out; gsl_matrix *inputs; gsl_vector_view input; size_t *labels; size_t lb; double ls; double er; bool cr; //Initialize the trainer and get every components printf("Initializing the trainer: %s\n", TEST_FUNC(tnn_trainer_class_init_nsgd(&t, A, B, label_set(B, P), L, E, S, T, N))); printf("Getting the machine of the trainer: %s\n", TEST_FUNC(tnn_trainer_class_get_machine(&t, &m))); printf("Getting the loss of the trainer: %s\n", TEST_FUNC(tnn_trainer_class_get_loss(&t, &l))); printf("Getting the regularizer of the trainer: %s\n", TEST_FUNC(tnn_trainer_class_get_reg(&t, &r))); printf("Getting the label of the trainer: %s\n", TEST_FUNC(tnn_trainer_class_get_label(&t, &label))); //Get various things from the initialized machine printf("Get machine paramters: %s\n", TEST_FUNC(tnn_machine_get_param(m, &p))); printf("Get machine input module: %s\n", TEST_FUNC(tnn_machine_get_min(m, &min))); printf("Get machine output module: %s\n", TEST_FUNC(tnn_machine_get_mout(m, &mout))); printf("Get machine input state: %s\n", TEST_FUNC(tnn_machine_get_sin(m, &sin))); printf("Get machine output state: %s\n", TEST_FUNC(tnn_machine_get_sout(m, &sout))); //Allocate modules for the machine and the loss out = malloc(sizeof(tnn_state)); printf("Initializing first hidden state: %s\n", TEST_FUNC(tnn_state_init(out, B))); printf("Allocating first hidden state: %s\n", TEST_FUNC(tnn_machine_state_alloc(m, out))); printf("Initializing min: %s\n", TEST_FUNC(tnn_module_init_linear(min, sin, out, p))); in = out; printf("Initializing mout: %s\n", TEST_FUNC(tnn_module_init_bias(mout, in, sout, p))); out = malloc(sizeof(tnn_state)); printf("Initializing loss output: %s\n", TEST_FUNC(tnn_state_init(out, 1))); printf("Allocating loss output: %s\n", TEST_FUNC(tnn_machine_state_alloc(m, out))); printf("Initializing the loss: %s\n", TEST_FUNC(tnn_loss_init_euclidean(l, sout, label, out))); //Initialize the regularization parameter printf("Initializing the regularization: %s\n", TEST_FUNC(tnn_reg_init_l1(r))); //Randomize the machine printf("Randomizing the machine: %s\n", TEST_FUNC(tnn_machine_randomize(m, 1.0))); //First debug printf("Debugging the trainer: %s\n", TEST_FUNC(tnn_trainer_class_debug(&t))); //Generate training data inputs = rdata(Q, A, D); labels = rlabel(Q, B); printf("Data generated.\n"); //Learn a sample input = gsl_matrix_row(inputs, 0); printf("Learn a sample: %s\n", TEST_FUNC(tnn_trainer_class_learn(&t, &input.vector, labels[0]))); //Second debug printf("Debugging the trainer: %s\n", TEST_FUNC(tnn_trainer_class_debug(&t))); //Train on samples printf("Train on samples: %s\n", TEST_FUNC(tnn_trainer_class_train(&t, inputs, labels))); //Third debug printf("Debugging the trainer: %s\n", TEST_FUNC(tnn_trainer_class_debug(&t))); //Test one example printf("Run on one example: %s\n", TEST_FUNC(tnn_trainer_class_run(&t, &input.vector, &lb, &ls))); printf("Label: %ld, loss: %g\n", lb, ls); printf("Try on one example: %s\n", TEST_FUNC(tnn_trainer_class_try(&t, &input.vector, labels[0], &cr))); printf("Correct: %s\n", cr?"YES":"NO"); printf("Test on the data: %s\n", TEST_FUNC(tnn_trainer_class_test(&t, inputs, labels, &ls, &er))); printf("Loss: %g, error: %g\n", ls, er); //Fourth debug printf("Debugging the trainer: %s\n", TEST_FUNC(tnn_trainer_class_debug(&t))); //Destroy the trainer printf("Destroying the trainer: %s\n", TEST_FUNC(tnn_trainer_class_destroy(&t))); free(labels); gsl_matrix_free(inputs); return 0; }
int main(){ int i; size_t l; tnn_state *key; tnn_state *s; tnn_param p,q; tnn_pstable t,tp; printf("Initializing t: %s\n", TEST_FUNC(tnn_pstable_init(&t))); //Adding dummy variables key = (tnn_state *)A; s = (tnn_state *)B; for(i = 0; i < 4; i = i + 1){ printf("Inserting key=%p, s=%p: %s\n", key, s, TEST_FUNC(tnn_pstable_add(&t, key, s))); key = key + 1; s = s - 1; } key = key - 1; s = s + 1; printf("Inserting key=%p, s=%p: %s\n", key, s, TEST_FUNC(tnn_pstable_add(&t, key, s))); //Debug printf("Debugging t: %s\n", TEST_FUNC(tnn_pstable_debug(&t))); //Delete a key key = (tnn_state *)A; key = key + C; printf("Deleting key=%p: %s\n", key, TEST_FUNC(tnn_pstable_delete(&t, key))); printf("Debugging t: %s\n", TEST_FUNC(tnn_pstable_debug(&t))); key = (tnn_state *)A; key = key - D; printf("Deleting key=%p: %s\n", key, TEST_FUNC(tnn_pstable_delete(&t, key))); printf("Debugging t: %s\n", TEST_FUNC(tnn_pstable_debug(&t))); //Find a key key = (tnn_state *)A; key = key + E; printf("Finding key=%p, s=%p: %s\n", key, s, TEST_FUNC(tnn_pstable_find(&t, key, &s))); key = (tnn_state *)A; key = key + C; printf("Finding key=%p, s=%p: %s\n", key, s, TEST_FUNC(tnn_pstable_find(&t, key, &s))); //Get the length printf("Getting the length=%ld: %s\n", l, TEST_FUNC(tnn_pstable_get_length(&t, &l))); //Destroy the table printf("Destroying t: %s\n", TEST_FUNC(tnn_pstable_destroy(&t))); printf("Debugging t: %s\n", TEST_FUNC(tnn_pstable_debug(&t))); //Initialize the two paramters printf("Initializing p: %s\n", TEST_FUNC(tnn_param_init(&p))); printf("Initializing q: %s\n", TEST_FUNC(tnn_param_init(&q))); //Allocating states in q for(i = 0; i < N; i = i + 1){ s = (tnn_state *) malloc(sizeof(tnn_state)); printf("Initializing s %d: %s\n", i, TEST_FUNC(tnn_state_init(s,i+F))); printf("Allocating s in p: %s\n", TEST_FUNC(tnn_param_state_calloc(&p,s))); } printf("Debugging p: %s\n", TEST_FUNC(tnn_param_debug(&p))); printf("Initialize q: %s\n", TEST_FUNC(tnn_param_init(&q))); printf("Initialize tp: %s\n", TEST_FUNC(tnn_pstable_init(&tp))); printf("Copying p to q: %s\n", TEST_FUNC(tnn_pstable_param_alloc(&tp,&p,&q))); printf("Debugging tp: %s\n", TEST_FUNC(tnn_pstable_debug(&tp))); printf("Debugging q: %s\n", TEST_FUNC(tnn_param_debug(&q))); return 0; }
//convert RENDER operation type into a function pointer extern "C" ptr2PdFunc EnumToFunc(const PorterDuffOp op, PixelFormat source_pf, PixelFormat dest_pf, PixelFormat mask_pf) { if (op == kPictOpOver) { if (mask_pf == kNoData) { TEST_FUNC(PDOver, kA8R8G8B8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOver, kA8R8G8B8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOver, kA8R8G8B8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOver, kA8R8G8B8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOver, kX8R8G8B8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOver, kX8R8G8B8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOver, kX8R8G8B8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOver, kX8R8G8B8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOver, kA8B8G8R8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOver, kA8B8G8R8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOver, kA8B8G8R8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOver, kA8B8G8R8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOver, kX8B8G8R8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOver, kX8B8G8R8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOver, kX8B8G8R8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOver, kX8B8G8R8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOver, kA8, kA8, kA8, false); } else if (mask_pf == kA8) { TEST_FUNC(PDOver, kA8R8G8B8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOver, kA8R8G8B8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOver, kA8R8G8B8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOver, kA8R8G8B8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOver, kX8R8G8B8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOver, kX8R8G8B8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOver, kX8R8G8B8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOver, kX8R8G8B8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOver, kA8B8G8R8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOver, kA8B8G8R8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOver, kA8B8G8R8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOver, kA8B8G8R8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOver, kX8B8G8R8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOver, kX8B8G8R8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOver, kX8B8G8R8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOver, kX8B8G8R8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOver, kA8, kA8, kA8, true); } else if (mask_pf == kA8R8G8B8) { TEST_FUNC(PDOver, kA8R8G8B8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8R8G8B8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8R8G8B8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8R8G8B8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8R8G8B8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8R8G8B8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8R8G8B8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8R8G8B8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8B8G8R8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8B8G8R8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8B8G8R8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8B8G8R8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8B8G8R8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8B8G8R8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8B8G8R8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kX8B8G8R8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8, kA8, kA8R8G8B8, true); } } #if 0 else if (op == kPictOpOutReverse) { if (mask_pf == kNoData) { TEST_FUNC(PDOutReverse, kA8R8G8B8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kA8R8G8B8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kA8R8G8B8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOutReverse, kA8R8G8B8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOutReverse, kX8R8G8B8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kX8R8G8B8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kX8R8G8B8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOutReverse, kX8R8G8B8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOutReverse, kA8B8G8R8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kA8B8G8R8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kA8B8G8R8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOutReverse, kA8B8G8R8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOutReverse, kX8B8G8R8, kA8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kX8B8G8R8, kX8R8G8B8, kA8, false) TEST_FUNC(PDOutReverse, kX8B8G8R8, kA8B8G8R8, kA8, false) TEST_FUNC(PDOutReverse, kX8B8G8R8, kX8B8G8R8, kA8, false) TEST_FUNC(PDOver, kA8, kA8, kA8, false); } else if (mask_pf == kA8) { TEST_FUNC(PDOutReverse, kA8R8G8B8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kA8R8G8B8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kA8R8G8B8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOutReverse, kA8R8G8B8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kA8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kX8R8G8B8, kA8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kA8B8G8R8, kA8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kX8B8G8R8, kA8, true) TEST_FUNC(PDOver, kA8, kA8, kA8, true); } else if (mask_pf == kA8R8G8B8) { TEST_FUNC(PDOutReverse, kA8R8G8B8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kA8R8G8B8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kA8R8G8B8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kA8R8G8B8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8R8G8B8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kA8B8G8R8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOutReverse, kX8B8G8R8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDOver, kA8, kA8, kA8R8G8B8, true); } } #endif else if (op == kPictOpAdd) { if (mask_pf == kNoData) { TEST_FUNC(PDAdd, kA8R8G8B8, kA8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kA8R8G8B8, kX8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kA8R8G8B8, kA8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kA8R8G8B8, kX8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kX8R8G8B8, kA8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kX8R8G8B8, kX8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kX8R8G8B8, kA8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kX8R8G8B8, kX8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kA8B8G8R8, kA8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kA8B8G8R8, kX8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kA8B8G8R8, kA8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kA8B8G8R8, kX8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kX8B8G8R8, kA8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kX8B8G8R8, kX8R8G8B8, kA8, false) TEST_FUNC(PDAdd, kX8B8G8R8, kA8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kX8B8G8R8, kX8B8G8R8, kA8, false) TEST_FUNC(PDAdd, kA8, kA8, kA8, false) TEST_FUNC(PDAdd, kA8R8G8B8, kA8, kA8, false) } else if (mask_pf == kA8) { TEST_FUNC(PDAdd, kA8R8G8B8, kA8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kA8R8G8B8, kX8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kA8R8G8B8, kA8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kA8R8G8B8, kX8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kA8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kX8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kA8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kX8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kA8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kX8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kA8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kX8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kA8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kX8R8G8B8, kA8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kA8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kX8B8G8R8, kA8, true) TEST_FUNC(PDAdd, kA8, kA8, kA8, true) } else if (mask_pf == kA8R8G8B8) { TEST_FUNC(PDAdd, kA8R8G8B8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8R8G8B8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8R8G8B8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8R8G8B8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8R8G8B8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8B8G8R8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kA8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kX8R8G8B8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kA8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kX8B8G8R8, kX8B8G8R8, kA8R8G8B8, true) TEST_FUNC(PDAdd, kA8, kA8, kA8R8G8B8, true) } } else if (op == kPictOpSrc)