test_dyndns.c revision a7401bf72db3a6eb62b1628f9dd141f7118e3510
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes Jakub Hrozek <jhrozek@redhat.com>
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes Copyright (C) 2013 Red Hat
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes SSSD tests: Dynamic DNS tests
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes This program is free software; you can redistribute it and/or modify
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes it under the terms of the GNU General Public License as published by
0662ed52e814f8f08ef0e09956413a792584eddffuankg the Free Software Foundation; either version 3 of the License, or
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes (at your option) any later version.
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes This program is distributed in the hope that it will be useful,
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes but WITHOUT ANY WARRANTY; without even the implied warranty of
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes GNU General Public License for more details.
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes You should have received a copy of the GNU General Public License
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes along with this program. If not, see <http://www.gnu.org/licenses/>.
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes/* In order to access opaque types */
405f61494d3ed3ca9c054dacc05a53513e172145bnicholesvoid __wrap_execv(const char *path, char *const argv[])
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes DEBUG(SSSDBG_FUNC_DATA, ("nsupdate success test case\n"));
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes DEBUG(SSSDBG_FUNC_DATA, ("nsupdate error test case\n"));
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes DEBUG(SSSDBG_FUNC_DATA, ("nsupdate timeout test case\n"));
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes DEBUG(SSSDBG_CRIT_FAILURE, ("unknown test case\n"));
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes DEBUG(SSSDBG_TRACE_LIBS, ("Child exiting with status %d\n", err));
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes while ((name = sss_mock_ptr_type(char *)) != NULL) {
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes ifap = talloc_zero(global_talloc_context, struct ifaddrs);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes ifap->ifa_addr = (struct sockaddr *) talloc(ifap, struct sockaddr_in);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes ((struct sockaddr_in *) ifap->ifa_addr)->sin_family = AF_INET;
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes /* convert straddr into ifa_addr */
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes &(((struct sockaddr_in *) ifap->ifa_addr)->sin_addr)) != 1) {
405f61494d3ed3ca9c054dacc05a53513e172145bnicholesstatic void dyndns_test_done(struct tevent_req *req)
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes tevent_req_callback_data(req, struct dyndns_test_ctx);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes ctx->tctx->error = be_nsupdate_recv(req, &ctx->child_status);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholesvoid will_return_getifaddrs(const char *ifname, const char *straddr)
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes will_return_getifaddrs(NULL, NULL); /* sentinel */
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes ret = sss_iface_addr_list_get(dyndns_test_ctx, "eth0", &addrlist);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes /* There must be only one address with the correct value */
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes &((struct sockaddr_in *) addrlist->addr)->sin_addr,
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes assert_true(check_leaks_pop(dyndns_test_ctx) == true);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes req = be_nsupdate_send(tmp_ctx, dyndns_test_ctx->tctx->ev,
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg tevent_req_set_callback(req, dyndns_test_done, dyndns_test_ctx);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes /* Wait until the test finishes with EOK */
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg ("Child request returned [%d]: %s\n", ret, strerror(ret)));
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes assert_true(WIFEXITED(dyndns_test_ctx->child_status));
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes assert_int_equal(WEXITSTATUS(dyndns_test_ctx->child_status), 0);
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes req = be_nsupdate_send(tmp_ctx, dyndns_test_ctx->tctx->ev,
405f61494d3ed3ca9c054dacc05a53513e172145bnicholes tevent_req_set_callback(req, dyndns_test_done, dyndns_test_ctx);
static int ncalls = 0;
ncalls++;
params);
int rv;
int no_cleanup = 0;
int opt;
switch(opt) {
return rv;