Lines Matching refs:test_ctx
217 struct test_fo_ctx *test_ctx;
225 test_ctx = talloc_zero(global_mock_context,
227 assert_non_null(test_ctx);
229 test_ctx->ctx = create_ev_test_ctx(test_ctx);
230 assert_non_null(test_ctx->ctx);
232 ret = resolv_init(test_ctx, test_ctx->ctx->ev,
233 TEST_RESOLV_TIMEOUT, &test_ctx->resolv);
234 assert_non_null(test_ctx->resolv);
240 test_ctx->fo_ctx = fo_context_init(test_ctx, &fopts);
241 assert_non_null(test_ctx->fo_ctx);
243 ret = fo_new_service(test_ctx->fo_ctx, "ldap",
245 &test_ctx->fo_svc);
248 *state = test_ctx;
254 struct test_fo_ctx *test_ctx =
257 talloc_free(test_ctx);
265 struct test_fo_ctx *test_ctx;
269 test_ctx = *state;
271 test_ctx->srv_ctx = fo_resolve_srv_dns_ctx_init(test_ctx, test_ctx->resolv,
274 assert_non_null(test_ctx->srv_ctx);
276 ok = fo_set_srv_lookup_plugin(test_ctx->fo_ctx,
279 test_ctx->srv_ctx);
282 *state = test_ctx;
319 static void test_fo_srv_step1(struct test_fo_ctx *test_ctx);
351 static void test_fo_srv_mock_dns(struct test_fo_ctx *test_ctx,
358 s1 = mock_ares_reply(test_ctx, "ldap1.sssd.com", 100, 1, 389);
361 s2 = mock_ares_reply(test_ctx, "ldap2.sssd.com", 100, 2, 389);
366 dns_domain = talloc_strdup(test_ctx, "sssd.com");
375 struct test_fo_ctx *test_ctx =
378 test_fo_srv_mock_dns(test_ctx, TEST_SRV_TTL);
380 ret = fo_add_srv_server(test_ctx->fo_svc, "_ldap", "sssd.com",
381 "sssd.local", "tcp", test_ctx);
384 test_fo_srv_step1(test_ctx);
386 ret = test_ev_loop(test_ctx->ctx);
390 static void test_fo_srv_step1(struct test_fo_ctx *test_ctx)
394 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
395 test_ctx->resolv, test_ctx->fo_ctx,
396 test_ctx->fo_svc);
398 tevent_req_set_callback(req, test_fo_srv_done1, test_ctx);
403 struct test_fo_ctx *test_ctx = \
413 check_server(test_ctx, srv, 389, "ldap1.sssd.com");
419 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
420 test_ctx->resolv, test_ctx->fo_ctx,
421 test_ctx->fo_svc);
423 tevent_req_set_callback(req, test_fo_srv_done2, test_ctx);
428 struct test_fo_ctx *test_ctx = \
438 check_server(test_ctx, srv, 389, "ldap1.sssd.com");
443 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
444 test_ctx->resolv, test_ctx->fo_ctx,
445 test_ctx->fo_svc);
447 tevent_req_set_callback(req, test_fo_srv_done3, test_ctx);
452 struct test_fo_ctx *test_ctx = \
462 check_server(test_ctx, srv, 389, "ldap2.sssd.com");
467 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
468 test_ctx->resolv, test_ctx->fo_ctx,
469 test_ctx->fo_svc);
471 tevent_req_set_callback(req, test_fo_srv_done4, test_ctx);
476 struct test_fo_ctx *test_ctx = \
487 fo_reset_servers(test_ctx->fo_svc);
488 if (test_ctx->srv_ctx) {
489 test_fo_srv_mock_dns(test_ctx, TEST_SRV_TTL);
492 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
493 test_ctx->resolv, test_ctx->fo_ctx,
494 test_ctx->fo_svc);
496 tevent_req_set_callback(req, test_fo_srv_done5, test_ctx);
501 struct test_fo_ctx *test_ctx = \
512 check_server(test_ctx, srv, 389, "ldap1.sssd.com");
515 test_ctx->ctx->error = ERR_OK;
516 test_ctx->ctx->done = true;
522 static void test_fo_srv_ttl_change_step(struct test_fo_ctx *test_ctx);
528 struct test_fo_ctx *test_ctx =
531 test_ctx->ttl = TEST_SRV_SHORT_TTL;
532 test_fo_srv_ttl_change_step(test_ctx);
535 static void test_fo_srv_ttl_change_step(struct test_fo_ctx *test_ctx)
540 test_fo_srv_mock_dns(test_ctx, test_ctx->ttl);
542 ret = fo_add_srv_server(test_ctx->fo_svc, "_ldap", "sssd.com",
543 "sssd.local", "tcp", test_ctx);
546 ret = fo_add_server(test_ctx->fo_svc, "ldap1.sssd.com",
551 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
552 test_ctx->resolv, test_ctx->fo_ctx,
553 test_ctx->fo_svc);
555 tevent_req_set_callback(req, test_fo_srv_before, test_ctx);
557 ret = test_ev_loop(test_ctx->ctx);
563 struct test_fo_ctx *test_ctx = \
570 ret = fo_resolve_service_recv(req, test_ctx, &test_ctx->srv);
576 check_server(test_ctx, test_ctx->srv, 389, "ldap1.sssd.com");
577 fo_set_server_status(test_ctx->srv, SERVER_WORKING);
580 s1 = mock_ares_reply(test_ctx, "ldap1.sssd.com", 100, 2, 389);
583 s2 = mock_ares_reply(test_ctx, "ldap2.sssd.com", 100, 1, 389);
588 dns_domain = talloc_strdup(test_ctx, "sssd.com");
591 mock_srv_results(s1, test_ctx->ttl, dns_domain);
592 sleep(test_ctx->ttl + 1);
594 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
595 test_ctx->resolv, test_ctx->fo_ctx,
596 test_ctx->fo_svc);
598 tevent_req_set_callback(req, test_fo_srv_after, test_ctx);
605 struct test_fo_ctx *test_ctx = \
620 fo_set_server_status(test_ctx->srv, SERVER_WORKING);
622 sleep(test_ctx->ttl + 1);
625 check_server(test_ctx, srv, 389, "ldap2.sssd.com");
628 s1 = mock_ares_reply(test_ctx, "ldap1.sssd.com", 100, 1, 389);
631 s2 = mock_ares_reply(test_ctx, "ldap2.sssd.com", 100, 2, 389);
636 dns_domain = talloc_strdup(test_ctx, "sssd.com");
639 mock_srv_results(s1, test_ctx->ttl, dns_domain);
640 sleep(test_ctx->ttl + 1);
642 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
643 test_ctx->resolv, test_ctx->fo_ctx,
644 test_ctx->fo_svc);
646 tevent_req_set_callback(req, test_fo_srv_after2, test_ctx);
651 struct test_fo_ctx *test_ctx = \
661 check_server(test_ctx, srv, 389, "ldap1.sssd.com");
663 test_ctx->ctx->error = ERR_OK;
664 test_ctx->ctx->done = true;
669 struct test_fo_ctx *test_ctx =
672 test_ctx->ttl = 0;
673 test_fo_srv_ttl_change_step(test_ctx);
679 struct test_fo_ctx *test_ctx =
682 ret = fo_add_server(test_ctx->fo_svc,
683 "ldap1.sssd.com", 389, test_ctx, true);
686 ret = fo_add_server(test_ctx->fo_svc,
687 "ldap2.sssd.com", 389, test_ctx, true);
690 test_fo_srv_step1(test_ctx);
692 ret = test_ev_loop(test_ctx->ctx);
705 struct test_fo_ctx *test_ctx =
708 test_fo_srv_mock_dns(test_ctx, test_ctx->ttl);
709 test_fo_srv_mock_dns(test_ctx, test_ctx->ttl);
711 ret = fo_add_srv_server(test_ctx->fo_svc, "_ldap", "sssd.com",
712 "sssd.local", "tcp", test_ctx);
715 ret = fo_add_server(test_ctx->fo_svc, "ldap1.sssd.com",
720 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
721 test_ctx->resolv, test_ctx->fo_ctx,
722 test_ctx->fo_svc);
724 tevent_req_set_callback(req, test_fo_srv_dup_done, test_ctx);
726 req = fo_resolve_service_send(test_ctx, test_ctx->ctx->ev,
727 test_ctx->resolv, test_ctx->fo_ctx,
728 test_ctx->fo_svc);
730 tevent_req_set_callback(req, test_fo_srv_dup_done, test_ctx);
732 ret = test_ev_loop(test_ctx->ctx);
738 struct test_fo_ctx *test_ctx = \
743 ret = fo_resolve_service_recv(req, test_ctx, &test_ctx->srv);
747 name = fo_get_server_name(test_ctx->srv);
750 test_ctx->num_done++;
751 if (test_ctx->num_done == 2) {
752 test_ctx->ctx->error = ERR_OK;
753 test_ctx->ctx->done = true;