コード例 #1
0
ファイル: test_hncp_nio.c プロジェクト: dtaht/hnetd
bool hncp_io_set_ifname_enabled(hncp o, const char *ifname, bool enabled)
{
  sput_fail_unless(o, "hncp");
  sput_fail_unless(o && o->udp_socket == 1, "hncp_io ready");
  smock_pull_string_is("set_enable_ifname", ifname);
  smock_pull_bool_is("set_enable_enabled", enabled);
  return smock_pull_bool("set_enable_result");
}
コード例 #2
0
ファイル: test_hncp_nio.c プロジェクト: dtaht/hnetd
static void dummy_node_cb(hncp_subscriber s, hncp_node n, bool add)
{
  L_NOTICE("node callback %s %s",
           HNCP_NODE_REPR(n), add ? "add" : "remove");
  sput_fail_unless(s, "subscriber provided");
  sput_fail_unless(s->node_change_callback == dummy_node_cb, "node cb set");
  sput_fail_unless(n, "node set");
  smock_pull_bool_is("node_callback", add);
}
コード例 #3
0
ファイル: test_hncp_io.c プロジェクト: dot-Sean/hnetd
void dncp_ext_ep_ready(dncp_ep ep, bool ready)
{
  smock_pull_string_is("dncp_ready", ep->ifname);
  smock_pull_bool_is("dncp_ready_value", ready);
}
コード例 #4
0
ファイル: test_iface.c プロジェクト: sbyx/hnetd
void iface_test_new_managed(void)
{
	struct in_addr v4source = {INADDR_LOOPBACK};
	iface_register_user(&user_mock);
	struct prefix p = {IN6ADDR_LOOPBACK_INIT, 0};
	char test[] = "test";

	struct iface *iface00 = iface_create("test00", "test00", 0);
	iface_update_ipv4_uplink(iface00);
	iface_set_ipv4_uplink(iface00, &v4source, 24);
	iface_commit_ipv4_uplink(iface00);
	/* smock_pull_bool_is("test00", false); */
        /* this was removed in the commit
           a5293745c235a057b6a477ffbd817937eaa9bc12 at 5/2015(!);
        */

	struct iface *iface = iface_create("test0", "test0", 0);
	iface->carrier = true;
	iface_discover_border(iface);

	sput_fail_unless(!!iface, "alloc managed");

	struct iface *iface2 = iface_get("test0");
	sput_fail_unless(iface == iface2, "get after create");

	struct iface *iface3 = iface_create("test0", "test0", 0);
	sput_fail_unless(iface == iface3, "create after create");

	/* smock_pull_bool_is("test0", false); */
        /* this was removed in the commit
           a5293745c235a057b6a477ffbd817937eaa9bc12 at 5/2015(!);
        */

	uloop_cancelled = false;
	uloop_run();
	smock_pull_bool_is("test0", true);

	iface_update_ipv4_uplink(iface);
	iface_set_ipv4_uplink(iface, &v4source, 24);
	iface_commit_ipv4_uplink(iface);
	smock_pull_bool_is("test0", false);

	iface_update_ipv4_uplink(iface);
	iface_commit_ipv4_uplink(iface);
	uloop_cancelled = false;
	uloop_run();
	smock_pull_bool_is("test0", true);

	iface_update_ipv6_uplink(iface);
	iface_add_delegated(iface, &p, NULL, HNETD_TIME_MAX, 0, test, sizeof(test));
	iface_commit_ipv6_uplink(iface);

	smock_pull_bool_is("test0", false);
	sput_fail_unless(!prefix_cmp(&p, (struct prefix *)smock_pull("prefix_prefix")), "prefix address");
	smock_pull_int64_is("prefix_valid", HNETD_TIME_MAX);
	smock_pull_int64_is("prefix_preferred", 0);
	sput_fail_unless(!strcmp(smock_pull("dhcpv6_data"), "test"), "dhcpv6_data");
	smock_pull_int_is("dhcpv6_len", sizeof(test));

	iface_update_ipv4_uplink(iface);
	iface_set_ipv4_uplink(iface, &v4source, 24);
	iface_commit_ipv4_uplink(iface);

	iface_update_ipv6_uplink(iface);
	iface_commit_ipv6_uplink(iface);
	smock_pull_bool_is("prefix_remove", true);

	iface_update_ipv4_uplink(iface);
	iface_commit_ipv4_uplink(iface);

	uloop_cancelled = false;
	uloop_run();
	smock_pull_bool_is("test0", true);

	iface_remove(iface);
	sput_fail_unless(!iface_get("test0"), "delete");
	smock_pull_bool_is("test0", false);
	smock_is_empty();
	iface_unregister_user(&user_mock);
}