7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek/*
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek Authors:
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek Copyright (C) 2014 Red Hat
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek SSSD tests: Common responder code tests
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek This program is free software; you can redistribute it and/or modify
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek it under the terms of the GNU General Public License as published by
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek (at your option) any later version.
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek This program is distributed in the hope that it will be useful,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek GNU General Public License for more details.
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek You should have received a copy of the GNU General Public License
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek*/
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#include <talloc.h>
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#include <tevent.h>
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#include <errno.h>
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#include <popt.h>
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#include "tests/cmocka/common_mock.h"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#include "tests/cmocka/common_mock_resp.h"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
50c9d542e8bf641412debaa82a4dcf67ddb72258Lukas Slebodnik#define TESTS_PATH "tp_" BASE_FILE_STEM
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#define TEST_CONF_DB "test_responder_conf.ldb"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#define TEST_DOM_NAME "responder_test"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#define TEST_ID_PROVIDER "ldap"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek#define NAME "username"
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech/* register_cli_protocol_version is required in test since it links with
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech * responder_common.c module
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech */
56c9f8731173eae841a05f31bb03d311076a8485Petr Cechstruct cli_protocol_version *register_cli_protocol_version(void)
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech{
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech static struct cli_protocol_version responder_test_cli_protocol_version[] = {
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech { 0, NULL, NULL }
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech };
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech return responder_test_cli_protocol_version;
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech}
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekstatic void
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekmock_sss_dp_done(struct tevent_context *ev,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_immediate *imm,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek void *pvt);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekerrno_t
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech__wrap_sss_dp_issue_request(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech const char *strkey, struct sss_domain_info *dom,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech dbus_msg_constructor msg_create, void *pvt,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech struct tevent_req *nreq)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_immediate *imm;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek imm = tevent_create_immediate(rctx->ev);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek if (imm == NULL) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return ENOMEM;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek }
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_schedule_immediate(imm, rctx->ev, mock_sss_dp_done, nreq);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return EOK;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekstatic void
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekmock_sss_dp_done(struct tevent_context *ev,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_immediate *imm,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek void *pvt)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_req *req;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek talloc_free(imm);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek req = talloc_get_type(pvt, struct tevent_req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_req_done(req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekerrno_t
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech__wrap_sss_dp_req_recv(TALLOC_CTX *mem_ctx,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech struct tevent_req *sidereq,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech dbus_uint16_t *dp_err,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech dbus_uint32_t *dp_ret,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech char **err_msg)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return EOK;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekstruct parse_inp_test_ctx {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct sss_test_ctx *tctx;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct resp_ctx *rctx;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek};
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int parse_inp_test_setup(void **state)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx;
9f734d4c122e37cc3080974342ed9586d05d5f83Sumit Bose int ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
bf65fbdd8c3fecd38a66363c3517e7a2679b8186Lukas Slebodnik assert_true(leak_check_setup());
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek parse_inp_ctx = talloc_zero(global_talloc_context, struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_non_null(parse_inp_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek parse_inp_ctx->tctx = create_dom_test_ctx(parse_inp_ctx, TESTS_PATH,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek TEST_CONF_DB, TEST_DOM_NAME,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek TEST_ID_PROVIDER, NULL);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_non_null(parse_inp_ctx->tctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek parse_inp_ctx->rctx = mock_rctx(parse_inp_ctx,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek parse_inp_ctx->tctx->ev,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek parse_inp_ctx->tctx->dom,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek parse_inp_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_non_null(parse_inp_ctx->rctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* Testing the request race condition should be a special case */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek gettimeofday(&parse_inp_ctx->rctx->get_domains_last_call, NULL);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
9f734d4c122e37cc3080974342ed9586d05d5f83Sumit Bose /* sysdb_master_domain_update sets the view name, if we do not call it
9f734d4c122e37cc3080974342ed9586d05d5f83Sumit Bose * here we get a leak check warning when sysdb_master_domain_update is
9f734d4c122e37cc3080974342ed9586d05d5f83Sumit Bose * called later while processing the tests. */
9f734d4c122e37cc3080974342ed9586d05d5f83Sumit Bose ret = sysdb_master_domain_update(parse_inp_ctx->tctx->dom);
9f734d4c122e37cc3080974342ed9586d05d5f83Sumit Bose assert_int_equal(ret, EOK);
9f734d4c122e37cc3080974342ed9586d05d5f83Sumit Bose
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek check_leaks_push(parse_inp_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek *state = parse_inp_ctx;
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek return 0;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozekstatic int parse_inp_test_teardown(void **state)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_true(check_leaks_pop(parse_inp_ctx) == true);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek talloc_free(parse_inp_ctx);
bf65fbdd8c3fecd38a66363c3517e7a2679b8186Lukas Slebodnik assert_true(leak_check_teardown());
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek return 0;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekint __real_sss_parse_name_for_domains(TALLOC_CTX *memctx,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct sss_domain_info *domains,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek const char *default_domain,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek const char *orig, char **domain, char **name);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekint __wrap_sss_parse_name_for_domains(TALLOC_CTX *memctx,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct sss_domain_info *domains,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek const char *default_domain,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek const char *orig, char **domain, char **name)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek enum sss_test_wrapper_call wtype = sss_mock_type(enum sss_test_wrapper_call);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek errno_t ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek if (wtype == WRAP_CALL_REAL) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return __real_sss_parse_name_for_domains(memctx, domains,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek default_domain, orig,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek domain, name);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek }
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ret = sss_mock_type(errno_t);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekvoid parse_inp_simple_done(struct tevent_req *req)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek errno_t ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx =
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_req_callback_data(req, struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek char *name = NULL;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek char *domname = NULL;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ret = sss_parse_inp_recv(req, parse_inp_ctx, &name, &domname);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_int_equal(ret, EOK);
eca74a9559ce1b0f123c14906ad8394fc303f468Jakub Hrozek
eca74a9559ce1b0f123c14906ad8394fc303f468Jakub Hrozek test_ev_done(parse_inp_ctx->tctx, EOK);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek talloc_free(req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_string_equal(name, NAME);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_null(domname);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek talloc_free(name);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekvoid parse_inp_simple(void **state)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_req *req;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek errno_t ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek will_return(__wrap_sss_parse_name_for_domains, WRAP_CALL_REAL);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina req = sss_parse_inp_send(parse_inp_ctx, parse_inp_ctx->rctx,
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina parse_inp_ctx->rctx->default_domain, NAME);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_non_null(req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_req_set_callback(req, parse_inp_simple_done, parse_inp_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ret = test_ev_loop(parse_inp_ctx->tctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_int_equal(ret, EOK);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekvoid parse_inp_call_dp(void **state)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_req *req;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek errno_t ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* First call will indicate we need to go to DP */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek will_return(__wrap_sss_parse_name_for_domains, WRAP_CALL_WRAPPER);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek will_return(__wrap_sss_parse_name_for_domains, EAGAIN);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* The second one will succeed as the domains are up-to-date */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek will_return(__wrap_sss_parse_name_for_domains, WRAP_CALL_REAL);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina req = sss_parse_inp_send(parse_inp_ctx, parse_inp_ctx->rctx,
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina parse_inp_ctx->rctx->default_domain, NAME);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_non_null(req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_req_set_callback(req, parse_inp_simple_done, parse_inp_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ret = test_ev_loop(parse_inp_ctx->tctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_int_equal(ret, EOK);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekvoid parse_inp_call_attach(void **state)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_req *req;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek errno_t ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* simulate responder startup */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek parse_inp_ctx->rctx->get_domains_last_call.tv_sec = 0;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* The first parse wouldn't be called, the second one will succeed
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek * as the domains are up-to-date */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek will_return(__wrap_sss_parse_name_for_domains, WRAP_CALL_REAL);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina req = sss_parse_inp_send(parse_inp_ctx, parse_inp_ctx->rctx,
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina parse_inp_ctx->rctx->default_domain, NAME);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_non_null(req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_req_set_callback(req, parse_inp_simple_done, parse_inp_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ret = test_ev_loop(parse_inp_ctx->tctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_int_equal(ret, EOK);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekvoid parse_inp_neg_done(struct tevent_req *req)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek errno_t ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx =
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_req_callback_data(req, struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek char *name = NULL;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek char *domname = NULL;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ret = sss_parse_inp_recv(req, parse_inp_ctx, &name, &domname);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_int_equal(ret, ERR_INPUT_PARSE);
eca74a9559ce1b0f123c14906ad8394fc303f468Jakub Hrozek test_ev_done(parse_inp_ctx->tctx, EOK);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek talloc_free(req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_null(name);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_null(domname);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekvoid parse_inp_call_neg(void **state)
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct parse_inp_test_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct tevent_req *req;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek errno_t ret;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* Simulate an error */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek will_return(__wrap_sss_parse_name_for_domains, WRAP_CALL_WRAPPER);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek will_return(__wrap_sss_parse_name_for_domains, EINVAL);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina req = sss_parse_inp_send(parse_inp_ctx, parse_inp_ctx->rctx,
2b5704cd96a085b99d3b0d4f80f4414adc134750Pavel Březina parse_inp_ctx->rctx->default_domain, NAME);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_non_null(req);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tevent_req_set_callback(req, parse_inp_neg_done, parse_inp_ctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek ret = test_ev_loop(parse_inp_ctx->tctx);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek assert_int_equal(ret, EOK);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozekstruct sss_nc_ctx {
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek struct parse_inp_test_ctx *pctx;
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek};
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek
56c9f8731173eae841a05f31bb03d311076a8485Petr Cecherrno_t __wrap_sss_ncache_reset_repopulate_permanent(struct resp_ctx *rctx,
56c9f8731173eae841a05f31bb03d311076a8485Petr Cech struct sss_nc_ctx *dummy_ncache_ptr)
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek{
eca74a9559ce1b0f123c14906ad8394fc303f468Jakub Hrozek test_ev_done(dummy_ncache_ptr->pctx->tctx, EOK);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek return EOK;
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek}
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozekvoid test_schedule_get_domains_task(void **state)
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek{
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek struct parse_inp_test_ctx);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek errno_t ret;
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek struct sss_nc_ctx *dummy_ncache_ptr;
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek dummy_ncache_ptr = talloc(parse_inp_ctx, struct sss_nc_ctx);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek assert_non_null(dummy_ncache_ptr);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek dummy_ncache_ptr->pctx = parse_inp_ctx;
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek ret = schedule_get_domains_task(dummy_ncache_ptr,
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek parse_inp_ctx->rctx->ev,
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek parse_inp_ctx->rctx,
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek dummy_ncache_ptr);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek assert_int_equal(ret, EOK);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek ret = test_ev_loop(parse_inp_ctx->tctx);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek assert_int_equal(ret, EOK);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek talloc_free(dummy_ncache_ptr);
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek}
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnikvoid test_sss_output_fqname(void **state)
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik{
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik struct parse_inp_test_ctx *parse_inp_ctx = talloc_get_type(*state,
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik struct parse_inp_test_ctx);
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik errno_t ret;
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik struct sized_string *res = NULL;
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik ret = sized_output_name(parse_inp_ctx, parse_inp_ctx->rctx, "dummy",
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik parse_inp_ctx->tctx->dom, &res);
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik assert_int_equal(ret, EOK);
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik assert_non_null(res);
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik assert_string_equal("dummy", res->str);
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik assert_int_equal(6, res->len);
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik talloc_zfree(res);
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik}
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozekint main(int argc, const char *argv[])
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek{
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek int rv;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek int no_cleanup = 0;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek poptContext pc;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek int opt;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek struct poptOption long_options[] = {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek POPT_AUTOHELP
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek SSSD_DEBUG_OPTS
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek {"no-cleanup", 'n', POPT_ARG_NONE, &no_cleanup, 0,
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek _("Do not delete the test database after a test run"), NULL },
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek POPT_TABLEEND
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek };
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek const struct CMUnitTest tests[] = {
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(parse_inp_simple,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_setup,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_teardown),
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(parse_inp_call_dp,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_setup,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_teardown),
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(parse_inp_call_attach,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_setup,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_teardown),
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek cmocka_unit_test_setup_teardown(parse_inp_call_neg,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_setup,
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek parse_inp_test_teardown),
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek cmocka_unit_test_setup_teardown(test_schedule_get_domains_task,
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek parse_inp_test_setup,
0528fdec17d0031996e919fcd852459e86592c35Jakub Hrozek parse_inp_test_teardown),
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik cmocka_unit_test_setup_teardown(test_sss_output_fqname,
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik parse_inp_test_setup,
051e0fc7cc86fb4e4b3a9323a61684ad3a6fa589Lukas Slebodnik parse_inp_test_teardown),
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek };
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz /* Set debug level to invalid value so we can decide if -d 0 was used. */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek debug_level = SSSDBG_INVALID;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek pc = poptGetContext(argv[0], argc, argv, long_options, 0);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek while((opt = poptGetNextOpt(pc)) != -1) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek switch(opt) {
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek default:
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek fprintf(stderr, "\nInvalid option %s: %s\n\n",
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek poptBadOption(pc, 0), poptStrerror(opt));
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek poptPrintUsage(pc, stderr, 0);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return 1;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek }
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek }
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek poptFreeContext(pc);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
6b57784f0f175275fd900eca21c77415e3a5ea52Jakub Hrozek DEBUG_CLI_INIT(debug_level);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek /* Even though normally the tests should clean up after themselves
57c5ea8825c7179fd93382dbcbb07e828e5aec19René Genz * they might not after a failed run. Remove the old DB to be sure */
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek tests_set_cwd();
cb4742876508a08ba90c82466c9dba708e4bf999Pavel Březina test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek test_dom_suite_setup(TESTS_PATH);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek rv = cmocka_run_group_tests(tests, NULL, NULL);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek if (rv == 0 && !no_cleanup) {
cb4742876508a08ba90c82466c9dba708e4bf999Pavel Březina test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME);
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek }
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek return rv;
7caf7ed4f2eae1ec1c0717b4ee6ce78bdacd5926Jakub Hrozek}