diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 7c0cfc4..ea73782 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
unsigned int io_id[4];
uint8_t client_num;
int step;
- bool reconnect;
+ uint8_t reconnect;
bool suspending;
struct tx_tstamp_data tx_ts;
int seqnum;
.disconnect = true,
};
+static const struct iso_client_data reconnect_16_2_1_send_recv = {
+ .qos = QOS_16_2_1,
+ .expect_err = 0,
+ .send = &send_16_2_1,
+ .recv = &send_16_2_1,
+ .disconnect = true,
+};
+
static const struct iso_client_data connect_ac_1_4 = {
.qos = AC_1_4,
.expect_err = 0
memcmp(isodata->send->iov_base, buf, len))) {
if (!isodata->recv->iov_base)
tester_test_failed();
- } else if (!data->step) {
+ } else if (!data->step)
tester_test_passed();
- }
}
static void bthost_iso_disconnected(void *user_data)
return true;
}
+static void test_connect(const void *test_data);
+static gboolean iso_connect_cb(GIOChannel *io, GIOCondition cond,
+ gpointer user_data);
+static gboolean iso_accept_cb(GIOChannel *io, GIOCondition cond,
+ gpointer user_data);
+static bool iso_defer_accept_bcast(struct test_data *data, GIOChannel *io,
+ uint8_t num, GIOFunc func);
+
+static gboolean iso_disconnected(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
+{
+ struct test_data *data = user_data;
+ const struct iso_client_data *isodata = data->test_data;
+
+ data->io_id[0] = 0;
+
+ if (cond & G_IO_HUP) {
+ if (!isodata->bcast && data->handle)
+ tester_test_failed();
+
+ tester_print("Successfully disconnected");
+
+ if (data->reconnect) {
+ tester_print("Reconnecting #%u...", data->reconnect);
+
+ data->reconnect--;
+
+ if (!isodata->server)
+ test_connect(data->test_data);
+ else {
+ GIOChannel *parent =
+ queue_peek_head(data->io_queue);
+
+ data->step++;
+
+ iso_defer_accept_bcast(data,
+ parent, 0, iso_accept_cb);
+ }
+
+ return FALSE;
+ }
+
+ tester_test_passed();
+ } else
+ tester_test_failed();
+
+ return FALSE;
+}
+
+static void iso_shutdown(struct test_data *data, GIOChannel *io)
+{
+ int sk;
+
+ sk = g_io_channel_unix_get_fd(io);
+
+ data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_disconnected, data);
+
+ /* Shutdown using SHUT_WR as SHUT_RDWR cause the socket to HUP
+ * immediately instead of waiting for Disconnect Complete event.
+ */
+ shutdown(sk, SHUT_WR);
+
+ tester_print("Disconnecting...");
+}
+
static gboolean iso_recv_data(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
tester_test_failed();
else if (data->step)
return TRUE;
+ else if (isodata->disconnect)
+ iso_shutdown(data, io);
else
tester_test_passed();
data->step++;
}
-static void iso_send(struct test_data *data, GIOChannel *io)
+static gboolean iso_pollout(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
{
+ struct test_data *data = user_data;
const struct iso_client_data *isodata = data->test_data;
unsigned int count;
+ data->io_id[0] = 0;
+
+ tester_print("POLLOUT event received");
+
for (count = 0; count < isodata->repeat_send_pre_ts; ++count)
iso_send_data(data, io);
if (isodata->bcast) {
tester_test_passed();
- return;
+ return FALSE;
}
if (isodata->recv)
iso_recv(data, io);
-}
-
-static void test_connect(const void *test_data);
-static gboolean iso_connect_cb(GIOChannel *io, GIOCondition cond,
- gpointer user_data);
-static gboolean iso_accept_cb(GIOChannel *io, GIOCondition cond,
- gpointer user_data);
-static bool iso_defer_accept_bcast(struct test_data *data, GIOChannel *io,
- uint8_t num, GIOFunc func);
-
-static gboolean iso_disconnected(GIOChannel *io, GIOCondition cond,
- gpointer user_data)
-{
- struct test_data *data = user_data;
- const struct iso_client_data *isodata = data->test_data;
-
- data->io_id[0] = 0;
-
- if (cond & G_IO_HUP) {
- if (!isodata->bcast && data->handle)
- tester_test_failed();
-
- tester_print("Successfully disconnected");
-
- if (data->reconnect) {
- data->reconnect = false;
-
- if (!isodata->server)
- test_connect(data->test_data);
- else {
- GIOChannel *parent =
- queue_peek_head(data->io_queue);
-
- data->step++;
-
- iso_defer_accept_bcast(data,
- parent, 0, iso_accept_cb);
- }
-
- return FALSE;
- }
-
- tester_test_passed();
- } else
- tester_test_failed();
return FALSE;
}
-static void iso_shutdown(struct test_data *data, GIOChannel *io)
+static void iso_send(struct test_data *data, GIOChannel *io)
{
- int sk;
-
- sk = g_io_channel_unix_get_fd(io);
-
- data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_disconnected, data);
-
- /* Shutdown using SHUT_WR as SHUT_RDWR cause the socket to HUP
- * immediately instead of waiting for Disconnect Complete event.
- */
- shutdown(sk, SHUT_WR);
-
- tester_print("Disconnecting...");
+ data->io_id[0] = g_io_add_watch(io, G_IO_OUT, iso_pollout, data);
}
static bool hook_set_event_mask(const void *msg, uint16_t len, void *user_data)
{
struct test_data *data = tester_get_data();
- data->reconnect = true;
+ data->reconnect = 1;
+ test_connect(test_data);
+}
+
+static void test_reconnect_16(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ data->reconnect = 16;
test_connect(test_data);
}
{
struct test_data *data = tester_get_data();
- data->reconnect = true;
+ data->reconnect = 1;
setup_connect(data, 0, iso_connect_cb);
}
data->io_queue = queue_new();
- data->reconnect = true;
+ data->reconnect = 1;
setup_connect_many(data, 2, num, funcs);
}
{
struct test_data *data = tester_get_data();
- data->reconnect = true;
+ data->reconnect = 1;
data->step = 1;
setup_listen(data, 0, iso_accept_cb);
setup_powered,
test_reconnect);
+ test_iso("ISO Reconnect Send and Receive #16 - Success",
+ &reconnect_16_2_1_send_recv,
+ setup_powered,
+ test_reconnect_16);
+
test_iso("ISO AC 1 & 4 - Success", &connect_ac_1_4, setup_powered,
test_connect);