void test_buildingowner_goes_to_empty_unit_after_leave(CuTest * tc) { struct region *r; struct building *bld; struct unit *u1, *u2, *u3; struct faction *f1; test_setup(); f1 = test_create_faction(NULL); r = test_create_plain(0, 0); bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u1 = test_create_unit(f1, r); u2 = test_create_unit(f1, r); u3 = test_create_unit(f1, r); u_set_building(u1, bld); u_set_building(u2, bld); u_set_building(u3, bld); CuAssertPtrEquals(tc, u1, building_owner(bld)); u2->number = 0; leave_building(u1); CuAssertPtrEquals(tc, u3, building_owner(bld)); leave_building(u3); CuAssertPtrEquals(tc, NULL, building_owner(bld)); u2->number = 1; CuAssertPtrEquals(tc, u2, building_owner(bld)); test_teardown(); }
static void test_buildingowner_goes_to_same_faction_after_leave(CuTest * tc) { struct region *r; struct building *bld; struct unit *u, *u2, *u3; struct faction *f1, *f2; test_setup(); f1 = test_create_faction(NULL); f2 = test_create_faction(NULL); r = test_create_plain(0, 0); bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u2 = test_create_unit(f2, r); u3 = test_create_unit(f1, r); u = test_create_unit(f1, r); CuAssertPtrNotNull(tc, u); u_set_building(u, bld); u_set_building(u2, bld); u_set_building(u3, bld); CuAssertPtrEquals(tc, u, building_owner(bld)); leave_building(u); CuAssertPtrEquals(tc, u3, building_owner(bld)); leave_building(u3); CuAssertPtrEquals(tc, u2, building_owner(bld)); leave_building(u2); CuAssertPtrEquals(tc, NULL, building_owner(bld)); test_teardown(); }
static void test_active_building(CuTest *tc) { building *b; region *r; unit *u; building_type *btype; test_setup(); btype = test_create_buildingtype("castle"); assert(btype && btype->maxsize == -1); b = test_create_building(r = test_create_region(0, 0, NULL), btype); u = test_create_unit(test_create_faction(NULL), r); CuAssertIntEquals(tc, false, building_is_active(b)); CuAssertPtrEquals(tc, NULL, active_building(u, btype)); b->flags |= BLD_MAINTAINED; CuAssertIntEquals(tc, true, building_is_active(b)); CuAssertPtrEquals(tc, NULL, active_building(u, btype)); u_set_building(u, b); CuAssertIntEquals(tc, true, building_is_active(b)); CuAssertPtrNotNull(tc, active_building(u, btype) ); btype->maxsize = 10; b->size = btype->maxsize; CuAssertIntEquals(tc, true, building_is_active(b)); CuAssertPtrNotNull(tc, active_building(u, btype) ); b->size = 9; CuAssertIntEquals(tc, false, building_is_active(b)); CuAssertPtrEquals(tc, NULL, active_building(u, btype)); btype->maxsize = -1; b->flags &= ~BLD_MAINTAINED; CuAssertIntEquals(tc, false, building_is_active(b)); CuAssertPtrEquals(tc, NULL, active_building(u, btype)); test_teardown(); }
static void setup_resources(void) { struct locale *lang; item_type *itype; test_setup(); itype = it_get_or_create(rt_get_or_create("stone")); itype->rtype->flags = RTF_LIMITED | RTF_POOLED; itype->construction = calloc(1, sizeof(construction)); itype->construction->skill = SK_QUARRYING; itype->construction->minskill = 1; rmt_create(itype->rtype); init_resources(); lang = get_or_create_locale("de"); /* CR tags are translated from this */ locale_setstring(lang, "money", "Silber"); locale_setstring(lang, "money_p", "Silber"); locale_setstring(lang, "horse", "Pferd"); locale_setstring(lang, "horse_p", "Pferde"); locale_setstring(lang, "peasant", "Bauer"); locale_setstring(lang, "peasant_p", "Bauern"); locale_setstring(lang, "stone", "Stein"); locale_setstring(lang, "stone_p", "Steine"); locale_setstring(lang, "tree", "Blume"); locale_setstring(lang, "tree_p", "Blumen"); locale_setstring(lang, "sapling", "Schoessling"); locale_setstring(lang, "sapling_p", "Schoesslinge"); locale_setstring(lang, "mallornsapling", "Mallornschoessling"); locale_setstring(lang, "mallornsapling_p", "Mallornschoesslinge"); locale_setstring(lang, "mallorntree", "Mallorn"); locale_setstring(lang, "mallorntree_p", "Mallorn"); }
int main(int argc, char **argv, char **env) { if (apr_app_initialize(&argc, (const char * const **) argv, (const char * const **) env) != APR_SUCCESS) { printf("apr_app_initialize failed\n"); return -1; } apr_pool_t *pool = NULL; apr_pool_create(&pool, NULL); request_rec *r = test_setup(pool); OpenSSL_add_all_digests(); char *result = all_tests(pool, r); if (result != 0) { printf("Failed: %s\n", result); } else { printf("All %d tests passed!\n", test_nr_run); } EVP_cleanup(); apr_pool_destroy(pool); apr_terminate(); return result != 0; }
/** * Verify that eglClientWaitSyncKHR() emits correct error when given an invalid * sync object. * * From the EGL_KHR_fence_sync: * * * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is * returned and an EGL_BAD_PARAMETER error is generated. */ static enum piglit_result test_eglClientWaitSyncKHR_invalid_sync(void *test_data) { enum piglit_result result = PIGLIT_PASS; EGLint wait_status = 0; EGLSyncKHR invalid_sync = (EGLSyncKHR) &canary; result = test_setup(); if (result != PIGLIT_PASS) { return result; } wait_status = peglClientWaitSyncKHR(g_dpy, invalid_sync, 0, 0); if (wait_status != EGL_FALSE) { piglit_loge("Given an invalid sync object, eglClientWaitSyncKHR() " "should return EGL_FALSE, but returned 0x%x", wait_status); result = PIGLIT_FAIL; } if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) { piglit_loge("Given an invalid sync object, eglClientWaitSyncKHR() " "did not emit EGL_BAD_PARAMETER"); result = PIGLIT_FAIL; } test_cleanup(EGL_NO_SYNC_KHR, &result); return result; }
static void test_shipspeed_max_range(CuTest *tc) { ship *sh; ship_type *stype; region *r; struct faction *f; unit *cap, *crew; test_setup(); sh = setup_ship(); setup_crew(sh, 0, &cap, &crew); config_set("movement.shipspeed.skillbonus", "5"); r = sh->region; f = test_create_faction(NULL); assert(r && f); stype = st_get_or_create(sh->type->_name); set_level(cap, SK_SAILING, stype->cptskill + 4); set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 4); CuAssertIntEquals_Msg(tc, "skill bonus requires at least movement.shipspeed.skillbonus points", 2, shipspeed(sh, cap)); set_level(cap, SK_SAILING, stype->cptskill + 5); set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 5); CuAssertIntEquals_Msg(tc, "skill bonus from movement.shipspeed.skillbonus", 3, shipspeed(sh, cap)); set_level(cap, SK_SAILING, stype->cptskill + 15); scale_number(crew, 15); set_level(crew, SK_SAILING, stype->sumskill - stype->cptskill); CuAssertIntEquals_Msg(tc, "skill-bonus cannot exceed max_range", 4, shipspeed(sh, cap)); test_teardown(); }
static void test_shipspeed_speedy(CuTest *tc) { ship_type *stype; ship *sh; unit *cap, *crw; test_setup(); stype = test_create_shiptype("dragonship"); stype->range = 5; stype->range_max = -1; stype->flags |= SFL_SPEEDY; cap = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); crw = test_create_unit(cap->faction, cap->region); sh = test_create_ship(cap->region, stype); cap->ship = sh; crw->ship = sh; set_level(cap, SK_SAILING, stype->cptskill); set_level(crw, SK_SAILING, stype->sumskill - stype->cptskill); CuAssertPtrEquals(tc, cap, ship_owner(sh)); CuAssertIntEquals(tc, 5, shipspeed(sh, cap)); set_level(cap, SK_SAILING, stype->cptskill * 3 - 1); CuAssertIntEquals(tc, 5, shipspeed(sh, cap)); set_level(cap, SK_SAILING, stype->cptskill * 3); CuAssertIntEquals(tc, 6, shipspeed(sh, cap)); set_level(cap, SK_SAILING, stype->cptskill * 3 * 3 - 1); CuAssertIntEquals(tc, 6, shipspeed(sh, cap)); set_level(cap, SK_SAILING, stype->cptskill * 3 * 3); CuAssertIntEquals(tc, 7, shipspeed(sh, cap)); test_teardown(); }
static void test_shipspeed(CuTest *tc) { ship *sh; const ship_type *stype; unit *cap, *crew; test_setup(); sh = setup_ship(); stype = sh->type; CuAssertIntEquals_Msg(tc, "ship without a captain cannot move", 0, shipspeed(sh, NULL)); setup_crew(sh, 0, &cap, &crew); CuAssertPtrEquals(tc, cap, ship_owner(sh)); CuAssertIntEquals_Msg(tc, "ship with fully skilled crew can sail at max speed", 2, shipspeed(sh, cap)); CuAssertIntEquals_Msg(tc, "shipspeed without a hint defaults to captain", 2, shipspeed(sh, NULL)); set_level(cap, SK_SAILING, stype->cptskill + 5); set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 10); CuAssertIntEquals_Msg(tc, "higher skills should not affect top speed", 2, shipspeed(sh, cap)); set_level(cap, SK_SAILING, stype->cptskill); set_level(crew, SK_SAILING, stype->sumskill - stype->cptskill); CuAssertIntEquals(tc, 2, shipspeed(sh, cap)); set_level(crew, SK_SAILING, (stype->sumskill - stype->cptskill) * 11); set_level(cap, SK_SAILING, stype->cptskill + 10); CuAssertIntEquals_Msg(tc, "regular skills should not exceed sh.range", 2, shipspeed(sh, cap)); test_teardown(); }
/** * Verify that eglClientWaitSyncKHR() accepts the * EGL_SYNC_FLUSH_COMMANDS_BIT_KHR flag. * * From the EGL_KHR_fence_sync: * * Accepted in the <flags> parameter of eglClientWaitSyncKHR: * EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 */ static enum piglit_result test_eglClientWaitSyncKHR_flag_sync_flush(void *test_data) { enum piglit_result result = PIGLIT_PASS; EGLSyncKHR sync = 0; EGLint wait_status = 0; result = test_setup(); if (result != PIGLIT_PASS) { return result; } glClear(GL_COLOR_BUFFER_BIT); sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_FENCE_KHR, NULL); if (!sync) { piglit_loge("eglCreateSyncKHR(EGL_SYNC_FENCE_KHR) failed"); result = PIGLIT_FAIL; goto cleanup; } wait_status = peglClientWaitSyncKHR(g_dpy, sync, EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 0); if (wait_status != EGL_TIMEOUT_EXPIRED_KHR && wait_status != EGL_CONDITION_SATISFIED_KHR) { piglit_loge("eglClientWaitSyncKHR() before glFinish:\n" " Expected status: EGL_TIMEOUT_EXPIRED_KHR or " " EGL_CONDITION_SATISFIED_KHR\n" " Actual status: 0x%x\n", wait_status); result = PIGLIT_FAIL; } cleanup: test_cleanup(sync, &result); return result; }
static void test_cmp_current_owner(CuTest *tc) { region *r; building *b1, *b2; building_type *btype; unit *u1, *u2; test_setup(); config_set("rules.region_owners", "1"); r = test_create_region(0, 0, NULL); btype = test_create_buildingtype("watch"); btype->stages->construction->maxsize = 1; btype->taxes = 200; b1 = test_create_building(r, btype); btype = test_create_buildingtype("castle"); btype->stages->construction->maxsize = 1; btype->taxes = 100; b2 = test_create_building(r, btype); b1->size = 1; CuAssertIntEquals(tc, 1, buildingeffsize(b1, false)); b2->size = 1; CuAssertIntEquals(tc, 1, buildingeffsize(b2, false)); u1 = test_create_unit(test_create_faction(NULL), r); u_set_building(u1, b1); u2 = test_create_unit(test_create_faction(NULL), r); u_set_building(u2, b2); region_set_owner(r, u1->faction, turn); CuAssertPtrEquals(tc, b1, largestbuilding(r, cmp_current_owner, false)); CuAssertTrue(tc, cmp_current_owner(b2, b1) < 0); CuAssertTrue(tc, cmp_current_owner(b1, b2) > 0); CuAssertTrue(tc, cmp_current_owner(b1, b1) == 0); test_teardown(); }
/** * Verify that eglCreateSyncKHR emits correct error when given an invalid * attribute list. * * From the EGL_KHR_fence_sync spec: * * If <attrib_list> is neither NULL nor empty (containing only * EGL_NONE), EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE * error is generated. */ static enum piglit_result test_eglCreateSyncKHR_invalid_attrib_list(void *test_data) { enum piglit_result result = PIGLIT_PASS; EGLSyncKHR sync = 0; const EGLint attrib_list[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, }; result = test_setup(); if (result != PIGLIT_PASS) { return result; } sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_FENCE_KHR, attrib_list); if (sync) { piglit_loge("eglCreateSyncKHR() succeeded with invalid " "attrib list"); result = PIGLIT_FAIL; } if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE)) { piglit_loge("eglCreateSyncKHR emitted wrong error"); result = PIGLIT_FAIL; } test_cleanup(sync, &result); return result; }
/** * Verify that eglCreateSyncKHR emits correct error when no context is current. * * From the EGL_KHR_fence_sync spec: * * If <type> is EGL_SYNC_FENCE_KHR and no context is current for * the bound API (i.e., eglGetCurrentContext returns * EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an * EGL_BAD_MATCH error is generated. */ static enum piglit_result test_eglCreateSyncKHR_no_current_context(void *test_data) { enum piglit_result result = PIGLIT_PASS; EGLSyncKHR sync = 0; result = test_setup(); if (result != PIGLIT_PASS) { return result; } eglMakeCurrent(g_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_TYPE_KHR, NULL); if (sync) { piglit_loge("eglCreateSyncKHR() succeeded when no context was " "current"); peglDestroySyncKHR(g_dpy, sync); result = PIGLIT_FAIL; } if (!piglit_check_egl_error(EGL_BAD_MATCH)) { piglit_loge("eglCreateSyncKHR emitted wrong error"); result = PIGLIT_FAIL; } test_cleanup(sync, &result); return result; }
static void test_piracy_cmd_land_to_land(CuTest * tc) { unit *u; region *r; faction *f; int target; const terrain_type *t_plain; const ship_type *stype; test_setup(); setup_piracy(); t_plain = get_or_create_terrain("plain"); stype = test_create_shiptype("boat"); /* create a target: */ r = test_create_region(0, 0, t_plain); f = test_create_faction(NULL); u = test_create_unit(f, r); u->ship = test_create_ship(r, stype); target = f->no; /* create a pirate: */ r = test_create_region(1, 0, t_plain); f = test_create_faction(NULL); u = test_create_unit(f, r); u->ship = test_create_ship(r, stype); set_level(u, SK_SAILING, u->ship->type->sumskill); u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(target)); piracy_cmd(u); CuAssertPtrEquals(tc, NULL, u->thisorder); CuAssertPtrEquals(tc, r, u->region); test_teardown(); }
static void test_piracy_cmd(CuTest * tc) { faction *f; region *r; unit *u, *u2; terrain_type *t_ocean; ship_type *st_boat; test_setup(); setup_piracy(); t_ocean = get_or_create_terrain("ocean"); st_boat = st_get_or_create("boat"); u2 = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, t_ocean)); assert(u2); u_set_ship(u2, test_create_ship(u2->region, st_boat)); u = test_create_unit(f = test_create_faction(NULL), r = test_create_region(0, 0, t_ocean)); assert(f && u); set_level(u, SK_SAILING, st_boat->sumskill); u_set_ship(u, test_create_ship(u->region, st_boat)); f->locale = get_or_create_locale("de"); u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no)); piracy_cmd(u); CuAssertPtrEquals(tc, NULL, u->thisorder); CuAssertTrue(tc, u->region != r); CuAssertPtrEquals(tc, u2->region, u->region); CuAssertPtrEquals(tc, u2->region, u->ship->region); CuAssertPtrNotNullMsg(tc, "successful PIRACY sets attribute", r->attribs); /* FIXME: this is testing implementation, not interface */ CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(f->msgs, "piratesawvictim")); CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(f->msgs, "shipsail")); test_teardown(); }
END_TEST /* * test suite */ static Suite * cuckoo_suite(void) { Suite *s = suite_create(SUITE_NAME); /* basic requests */ TCase *tc_basic_req = tcase_create("basic item api"); suite_add_tcase(s, tc_basic_req); test_setup(CUCKOO_POLICY_RANDOM, true); tcase_add_test(tc_basic_req, test_insert_basic_random_true); tcase_add_test(tc_basic_req, test_insert_basic_random_false); tcase_add_test(tc_basic_req, test_insert_collision_random_true); tcase_add_test(tc_basic_req, test_insert_collision_random_false); tcase_add_test(tc_basic_req, test_insert_collision_expire_true); tcase_add_test(tc_basic_req, test_insert_collision_expire_false); tcase_add_test(tc_basic_req, test_cas_random); tcase_add_test(tc_basic_req, test_cas_expire); tcase_add_test(tc_basic_req, test_delete_basic_random_true); tcase_add_test(tc_basic_req, test_delete_basic_random_false); tcase_add_test(tc_basic_req, test_expire_basic_random_true); tcase_add_test(tc_basic_req, test_expire_basic_random_false); tcase_add_test(tc_basic_req, test_insert_replace_expired); tcase_add_test(tc_basic_req, test_insert_insert_expire_swap); return s; }
int main() { test_setup(); perf_start(); for (int i = 0; i < NUM_ITER; ++i) { test_clear(); reset_timer(); start_timer(); test_run(i); stop_timer(); samples[i] = get_time(); } perf_stop(); int check = test_check(); printf("Correct: %d\n", check); for (int i = 0; i < NUM_ITER; ++i) printf("TS[%d]: %d\n", i, samples[i]); perf_print_all(); return 0; }
int main(int ac, char **av) { int lc, i; tst_parse_opts(ac, av, NULL, NULL); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; for (i = 0; i < TST_TOTAL; ++i) { test_setup(i); TEST(ltp_syscall(__NR_capget, test_cases[i].headerp, test_cases[i].datap)); if (TEST_RETURN == -1 && TEST_ERRNO == test_cases[i].exp_errno) { tst_resm(TPASS | TTERRNO, "capget failed as expected"); } else { tst_resm(TFAIL | TTERRNO, "capget failed unexpectedly (%ld)", TEST_RETURN); } } } cleanup(); tst_exit(); }
static void test_buildingowner_goes_to_other_when_empty(CuTest * tc) { struct region *r; struct building *bld; struct unit *u, *u2; struct faction *f; test_setup(); f = test_create_faction(NULL); r = test_create_plain(0, 0); bld = test_create_building(r, NULL); CuAssertPtrNotNull(tc, bld); u2 = test_create_unit(f, r); u = test_create_unit(f, r); CuAssertPtrNotNull(tc, u); u_set_building(u, bld); CuAssertPtrEquals(tc, u, building_owner(bld)); u_set_building(u2, bld); CuAssertPtrEquals(tc, u, building_owner(bld)); u->number = 0; CuAssertPtrEquals(tc, u2, building_owner(bld)); test_teardown(); }
static void test_building_effsize(CuTest *tc) { building *b; building_type *btype; building_stage *stage; construction *cons; test_setup(); btype = test_create_buildingtype("castle"); stage = btype->stages; assert(stage && stage->construction); cons = stage->construction; cons->maxsize = 5; stage->next = calloc(1, sizeof(building_stage)); stage = stage->next; cons = stage->construction = calloc(1, sizeof(construction)); cons->maxsize = 5; stage->next = calloc(1, sizeof(building_stage)); stage = stage->next; cons = stage->construction = calloc(1, sizeof(construction)); cons->maxsize = -1; b = test_create_building(test_create_region(0,0,0), btype); b->size = 1; CuAssertIntEquals(tc, 0, buildingeffsize(b, false)); b->size = 5; CuAssertIntEquals(tc, 1, buildingeffsize(b, false)); b->size = 10; CuAssertIntEquals(tc, 2, buildingeffsize(b, false)); b->size = 20; CuAssertIntEquals(tc, 2, buildingeffsize(b, false)); test_teardown(); }
static void test_shipowner_goes_to_other_when_empty(CuTest * tc) { struct region *r; struct ship *sh; struct unit *u, *u2; struct faction *f; const struct ship_type *stype; const struct race *human; test_setup(); test_create_world(); human = rc_find("human"); CuAssertPtrNotNull(tc, human); stype = st_find("boat"); CuAssertPtrNotNull(tc, stype); f = test_create_faction(human); r = findregion(0, 0); sh = test_create_ship(r, stype); CuAssertPtrNotNull(tc, sh); u2 = test_create_unit(f, r); u = test_create_unit(f, r); CuAssertPtrNotNull(tc, u); u_set_ship(u, sh); u_set_ship(u2, sh); CuAssertPtrEquals(tc, u, ship_owner(sh)); u->number = 0; CuAssertPtrEquals(tc, u2, ship_owner(sh)); test_teardown(); }
static void test_merge_split(CuTest *tc) { message_list *mlist = 0, *append = 0; struct mlist **split; /* TODO: why is this a double asterisk? */ message_type *mtype; message *msg; test_setup(); mtype = mt_create(mt_new("custom", NULL), NULL, 0); add_message(&mlist, msg = msg_message(mtype->name, "")); msg_release(msg); add_message(&append, msg = msg_message(mtype->name, "")); msg_release(msg); CuAssertPtrEquals(tc, NULL, mlist->begin->next); CuAssertPtrEquals(tc, &mlist->begin->next, mlist->end); split = merge_messages(mlist, append); CuAssertPtrNotNull(tc, split); CuAssertPtrEquals(tc, &mlist->begin->next, split); CuAssertPtrEquals(tc, append->end, mlist->end); CuAssertPtrNotNull(tc, mlist->begin->next); CuAssertPtrEquals(tc, append->begin, mlist->begin->next); split_messages(mlist, split); CuAssertPtrEquals(tc, NULL, mlist->begin->next); free_messagelist(*split); free_messagelist(mlist->begin); free(mlist); free_messagelist(append->begin); free(append); test_teardown(); }
/** * Verify that eglDestroySyncKHR() emits the correct error when given an * invalid sync object. * * From the EGL_KHR_fence_sync spec: * * * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is * returned and an EGL_BAD_PARAMETER error is generated. */ static enum piglit_result test_eglDestroySyncKHR_invalid_sync(void *test_data) { enum piglit_result result = PIGLIT_PASS; bool ok = false; EGLSyncKHR invalid_sync = (EGLSyncKHR) &canary; result = test_setup(); if (result != PIGLIT_PASS) { return result; } ok = peglDestroySyncKHR(g_dpy, invalid_sync); if (ok) { piglit_loge("eglDestroySyncKHR() succeeded when given invalid " "sync object"); result = PIGLIT_FAIL; } if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) { piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) emitted " "an incorrect error"); result = PIGLIT_FAIL; } test_cleanup(EGL_NO_SYNC_KHR, &result); return result; }
static void test_plane(CuTest *tc) { struct region *r; plane *pl; test_setup(); r = test_create_region(0, 0, NULL); CuAssertPtrEquals(tc, NULL, findplane(0, 0)); CuAssertPtrEquals(tc, NULL, getplane(r)); CuAssertIntEquals(tc, 0, getplaneid(r)); CuAssertPtrEquals(tc, NULL, getplanebyid(0)); CuAssertIntEquals(tc, 0, plane_center_x(0)); CuAssertIntEquals(tc, 0, plane_center_y(0)); CuAssertIntEquals(tc, 0, plane_width(0)); CuAssertIntEquals(tc, 0, plane_height(0)); CuAssertPtrEquals(tc, NULL, get_homeplane()); pl = create_new_plane(1, "Hell", 4, 8, 40, 80, 15); r = test_create_region(4, 40, 0); CuAssertIntEquals(tc, 15, pl->flags); CuAssertIntEquals(tc, 4, pl->minx); CuAssertIntEquals(tc, 8, pl->maxx); CuAssertIntEquals(tc, 40, pl->miny); CuAssertIntEquals(tc, 80, pl->maxy); CuAssertPtrEquals(tc, NULL, pl->attribs); CuAssertStrEquals(tc, "Hell", pl->name); CuAssertPtrEquals(tc, pl, findplane(4, 40)); CuAssertPtrEquals(tc, pl, getplane(r)); CuAssertPtrEquals(tc, pl, getplanebyid(1)); CuAssertIntEquals(tc, 1, getplaneid(r)); CuAssertIntEquals(tc, 6, plane_center_x(pl)); CuAssertIntEquals(tc, 60, plane_center_y(pl)); CuAssertIntEquals(tc, 5, plane_width(pl)); CuAssertIntEquals(tc, 41, plane_height(pl)); test_teardown(); }
/** * Verify that eglCreateSyncKHR emits correct error when given an invalid * sync type. * * From the EGL_KHR_fence_sync spec: * * If <type> is not a supported type of sync object, * EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is * generated. * * TODO(chadv,joshtriplett): eglCreateSyncKHR should generate EGL_BAD_PARAMETER * TODO: on bad sync types, not EGL_BAD_ATTRIBUTE. Bug filed in Khronos private * TODO: Bugzilla; update the test when resolved. */ static enum piglit_result test_eglCreateSyncKHR_invalid_sync_type(void *test_data) { enum piglit_result result = PIGLIT_PASS; EGLSyncKHR sync = 0; EGLenum bad_sync_type = EGL_SYNC_TYPE_KHR; result = test_setup(); if (result != PIGLIT_PASS) { return result; } sync = peglCreateSyncKHR(g_dpy, bad_sync_type, NULL); if (sync) { piglit_loge("eglCreateSyncKHR() succeeded with invalid " "sync type"); result = PIGLIT_FAIL; } if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE)) { piglit_loge("eglCreateSyncKHR emitted wrong error"); result = PIGLIT_FAIL; } test_cleanup(sync, &result); return result; }
/* Test that reading a custom CA certificate file works. */ static void test_ssl_cert_subject(CuTest *tc) { apr_hash_t *subject; serf_ssl_certificate_t *cert = NULL; apr_status_t status; apr_pool_t *test_pool = test_setup(); status = serf_ssl_load_cert_file( &cert, get_ca_file(test_pool, "test/serftestca.pem"), test_pool); CuAssertIntEquals(tc, APR_SUCCESS, status); CuAssertPtrNotNull(tc, cert); subject = serf_ssl_cert_subject(cert, test_pool); CuAssertStrEquals(tc, "Test Suite", apr_hash_get(subject, "OU", APR_HASH_KEY_STRING)); CuAssertStrEquals(tc, "In Serf we trust, Inc.", apr_hash_get(subject, "O", APR_HASH_KEY_STRING)); CuAssertStrEquals(tc, "Mechelen", apr_hash_get(subject, "L", APR_HASH_KEY_STRING)); CuAssertStrEquals(tc, "Antwerp", apr_hash_get(subject, "ST", APR_HASH_KEY_STRING)); CuAssertStrEquals(tc, "BE", apr_hash_get(subject, "C", APR_HASH_KEY_STRING)); CuAssertStrEquals(tc, "*****@*****.**", apr_hash_get(subject, "E", APR_HASH_KEY_STRING)); test_teardown(test_pool); }
/** * Verify that eglGetSyncAttribKHR emits the correct error when given an object * that is not a sync object. * * From the EGL_KHR_fence_sync: * * * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is * returned and an EGL_BAD_PARAMETER error is generated. * * [...] * * If any error occurs, <*value> is not modified. */ static enum piglit_result test_eglGetSyncAttribKHR_invalid_sync(void *test_data) { enum piglit_result result = PIGLIT_PASS; bool ok = false; EGLint sync_type = canary; EGLSyncKHR invalid_sync = (EGLSyncKHR) &canary; result = test_setup(); if (result != PIGLIT_PASS) { return result; } ok = peglGetSyncAttribKHR(g_dpy, invalid_sync, EGL_SYNC_TYPE_KHR, &sync_type); if (ok) { piglit_loge("eglGetSyncAttribKHR incorrectly succeeded when " "given an invalid sync object"); result = PIGLIT_FAIL; } if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) { piglit_loge("eglGetSyncAttribKHR emitted wrong error"); result = PIGLIT_FAIL; } if (sync_type != canary) { piglit_loge("eglGetSynAttribKHR modified out parameter <value>"); result = PIGLIT_FAIL; } test_cleanup(EGL_NO_SYNC_KHR, &result); return result; }
static void test_ship_set_owner(CuTest * tc) { struct region *r; struct ship *sh; struct unit *u1, *u2; struct faction *f; const struct ship_type *stype; const struct race *human; test_setup(); test_create_world(); human = rc_find("human"); stype = st_find("boat"); f = test_create_faction(human); r = findregion(0, 0); sh = test_create_ship(r, stype); u1 = test_create_unit(f, r); u_set_ship(u1, sh); CuAssertPtrEquals(tc, u1, ship_owner(sh)); u2 = test_create_unit(f, r); u_set_ship(u2, sh); CuAssertPtrEquals(tc, u1, ship_owner(sh)); ship_set_owner(u2); CuAssertPtrEquals(tc, u2, ship_owner(sh)); test_teardown(); }
int suite_init(void) { int i; for (i = 0; i < mp_num_sds; i++) { if (!mp_sds[i]->iscsi_url) { continue; } if (mp_sds[i]->iscsi_ctx) { iscsi_logout_sync(mp_sds[i]->iscsi_ctx); iscsi_destroy_context(mp_sds[i]->iscsi_ctx); } mp_sds[i]->iscsi_ctx = iscsi_context_login(initiatorname1, mp_sds[i]->iscsi_url, &mp_sds[i]->iscsi_lun); if (mp_sds[i]->iscsi_ctx == NULL) { fprintf(stderr, "error: Failed to login to target for test set-up\n"); return 1; } } #ifndef HAVE_CU_SUITEINFO_PSETUPFUNC /* libcunit version 1 */ test_setup(); #endif return 0; }
static void test_building_type(CuTest *tc) { building_type *btype; test_setup(); btype = test_create_buildingtype("house"); CuAssertIntEquals(tc, true, is_building_type(btype, "house")); CuAssertIntEquals(tc, false, is_building_type(btype, "castle")); test_teardown(); }