* [PATCH 0/2] Add new rilmodem SMS test cases
@ 2015-11-24 19:38 Tony Espy
2015-11-24 19:38 ` [PATCH 1/2] unit: add write support to rilmodem-test-server Tony Espy
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tony Espy @ 2015-11-24 19:38 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 503 bytes --]
This patchset adds new rilmodem SMS test cases, including
tests for incoming SMS unsolicited responses.
Tony Espy (2):
unit: add write support to rilmodem-test-server
unit: add new test-rilmodem-sms test cases
unit/rilmodem-test-server.c | 113 ++++++++------
unit/rilmodem-test-server.h | 11 +-
unit/test-rilmodem-cs.c | 6 +-
unit/test-rilmodem-sms.c | 356 ++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 426 insertions(+), 60 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] unit: add write support to rilmodem-test-server
2015-11-24 19:38 [PATCH 0/2] Add new rilmodem SMS test cases Tony Espy
@ 2015-11-24 19:38 ` Tony Espy
2015-11-24 19:38 ` [PATCH 2/2] unit: add new test-rilmodem-sms test cases Tony Espy
2015-11-29 21:49 ` [PATCH 0/2] Add new rilmodem SMS " Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Tony Espy @ 2015-11-24 19:38 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 7688 bytes --]
This change adds write support to the rilmodem-test-server
in order to support testing receipt of unsolicted RIL
responses.
---
unit/rilmodem-test-server.c | 113 ++++++++++++++++++++++++++++----------------
unit/rilmodem-test-server.h | 11 ++++-
2 files changed, 80 insertions(+), 44 deletions(-)
diff --git a/unit/rilmodem-test-server.c b/unit/rilmodem-test-server.c
index 52a3c74..17e5090 100644
--- a/unit/rilmodem-test-server.c
+++ b/unit/rilmodem-test-server.c
@@ -37,10 +37,13 @@
#define MAX_REQUEST_SIZE 4096
-static int server_sk;
-static ConnectFunc connect_func;
-static GIOChannel *server_io;
-static const struct rilmodem_test_data *rtd;
+struct server_data {
+ int server_sk;
+ ConnectFunc connect_func;
+ GIOChannel *server_io;
+ const struct rilmodem_test_data *rtd;
+ void *user_data;
+};
/* Warning: length is stored in network order */
struct rsp_hdr {
@@ -52,6 +55,7 @@ struct rsp_hdr {
static gboolean read_server(gpointer data)
{
+ struct server_data *sd = data;
GIOStatus status;
gsize offset, rbytes, wbytes;
gchar *buf, *bufp;
@@ -60,14 +64,13 @@ static gboolean read_server(gpointer data)
buf = g_malloc0(MAX_REQUEST_SIZE);
- status = g_io_channel_read_chars(server_io, buf, MAX_REQUEST_SIZE,
+ status = g_io_channel_read_chars(sd->server_io, buf, MAX_REQUEST_SIZE,
&rbytes, NULL);
g_assert(status == G_IO_STATUS_NORMAL);
-
- g_assert(rbytes == rtd->req_size);
+ g_assert(rbytes == sd->rtd->req_size);
/* validate len, and request_id */
- g_assert(!memcmp(buf, rtd->req_data, (sizeof(uint32_t) * 2)));
+ g_assert(!memcmp(buf, sd->rtd->req_data, (sizeof(uint32_t) * 2)));
/*
* header: size (uint32), reqid (uin32), serial (uint32)
@@ -84,28 +87,28 @@ static gboolean read_server(gpointer data)
/* validate the rest of the parcel... */
offset = (sizeof(uint32_t) * 3);
- g_assert(!memcmp(bufp, rtd->req_data + offset,
- rtd->req_size - offset));
+ g_assert(!memcmp(bufp, sd->rtd->req_data + offset,
+ sd->rtd->req_size - offset));
/* Length does not include the length field. Network order. */
- rsp.length = htonl(sizeof(rsp) - sizeof(rsp.length) + rtd->rsp_size);
+ rsp.length = htonl(sizeof(rsp) - sizeof(rsp.length) +
+ sd->rtd->rsp_size);
rsp.unsolicited = 0;
rsp.serial = req_serial;
- rsp.error = rtd->rsp_error;
+ rsp.error = sd->rtd->rsp_error;
/* copy header */
memcpy(buf, &rsp, sizeof(rsp));
- if (rtd->rsp_size) {
+ if (sd->rtd->rsp_size) {
bufp = buf + sizeof(rsp);
- memcpy(bufp, rtd->rsp_data, rtd->rsp_size);
+ memcpy(bufp, sd->rtd->rsp_data, sd->rtd->rsp_size);
}
-
- status = g_io_channel_write_chars(server_io,
+ status = g_io_channel_write_chars(sd->server_io,
buf,
- sizeof(rsp) + rtd->rsp_size,
+ sizeof(rsp) + sd->rtd->rsp_size,
&wbytes, NULL);
/* FIXME: assert wbytes is correct */
@@ -113,7 +116,7 @@ static gboolean read_server(gpointer data)
g_assert(status == G_IO_STATUS_NORMAL);
g_free(buf);
- g_io_channel_unref(server_io);
+ g_io_channel_unref(sd->server_io);
return FALSE;
}
@@ -121,6 +124,7 @@ static gboolean read_server(gpointer data)
static gboolean on_socket_connected(GIOChannel *chan, GIOCondition cond,
gpointer data)
{
+ struct server_data *sd = data;
struct sockaddr saddr;
unsigned int len = sizeof(saddr);
int fd;
@@ -128,48 +132,52 @@ static gboolean on_socket_connected(GIOChannel *chan, GIOCondition cond,
g_assert(cond == G_IO_IN);
- fd = accept(server_sk, &saddr, &len);
+ fd = accept(sd->server_sk, &saddr, &len);
g_assert(fd != -1);
- server_io = g_io_channel_unix_new(fd);
- g_assert(server_io != NULL);
+ sd->server_io = g_io_channel_unix_new(fd);
+ g_assert(sd->server_io != NULL);
- if (connect_func)
- connect_func(data);
-
- status = g_io_channel_set_encoding(server_io, NULL, NULL);
+ status = g_io_channel_set_encoding(sd->server_io, NULL, NULL);
g_assert(status == G_IO_STATUS_NORMAL);
- g_io_channel_set_buffered(server_io, FALSE);
- g_io_channel_set_close_on_unref(server_io, TRUE);
+ g_io_channel_set_buffered(sd->server_io, FALSE);
+ g_io_channel_set_close_on_unref(sd->server_io, TRUE);
+
+ if (sd->connect_func)
+ sd->connect_func(sd->user_data);
- g_idle_add(read_server, data);
+ if (sd->rtd->unsol_test == FALSE)
+ g_idle_add(read_server, sd);
return FALSE;
}
-void rilmodem_test_server_close(void)
+void rilmodem_test_server_close(struct server_data *sd)
{
- g_assert(server_sk);
- close(server_sk);
- server_sk = 0;
+ g_assert(sd->server_sk);
+ close(sd->server_sk);
+ g_free(sd);
}
-void rilmodem_test_server_create(ConnectFunc connect,
+struct server_data *rilmodem_test_server_create(ConnectFunc connect,
const struct rilmodem_test_data *test_data,
void *data)
{
GIOChannel *io;
struct sockaddr_un addr;
int retval;
+ struct server_data *sd;
- g_assert(server_sk == 0);
- connect_func = connect;
- rtd = test_data;
+ sd = g_new0(struct server_data, 1);
- server_sk = socket(AF_UNIX, SOCK_STREAM, 0);
- g_assert(server_sk);
+ sd->connect_func = connect;
+ sd->user_data = data;
+ sd->rtd = test_data;
+
+ sd->server_sk = socket(AF_UNIX, SOCK_STREAM, 0);
+ g_assert(sd->server_sk);
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
@@ -178,19 +186,40 @@ void rilmodem_test_server_create(ConnectFunc connect,
/* Unlink any existing socket for this session */
unlink(addr.sun_path);
- retval = bind(server_sk, (struct sockaddr *) &addr, sizeof(addr));
+ retval = bind(sd->server_sk, (struct sockaddr *) &addr, sizeof(addr));
g_assert(retval >= 0);
- retval = listen(server_sk, 0);
+ retval = listen(sd->server_sk, 0);
g_assert(retval >= 0);
- io = g_io_channel_unix_new(server_sk);
+ io = g_io_channel_unix_new(sd->server_sk);
g_assert(io != NULL);
g_io_channel_set_close_on_unref(io, TRUE);
g_io_add_watch_full(io, G_PRIORITY_DEFAULT,
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- on_socket_connected, data, NULL);
+ on_socket_connected, sd, NULL);
g_io_channel_unref(io);
+
+ return sd;
+}
+
+void rilmodem_test_server_write(struct server_data *sd,
+ const unsigned char *buf,
+ const size_t buf_len)
+{
+ GIOStatus status;
+ gsize wbytes;
+
+ status = g_io_channel_write_chars(sd->server_io,
+ (const char *) buf,
+ buf_len,
+ &wbytes, NULL);
+
+ g_assert(status == G_IO_STATUS_NORMAL);
+
+ status = g_io_channel_flush(sd->server_io, NULL);
+
+ g_assert(status == G_IO_STATUS_NORMAL);
}
diff --git a/unit/rilmodem-test-server.h b/unit/rilmodem-test-server.h
index ba8b43c..e6a2afc 100644
--- a/unit/rilmodem-test-server.h
+++ b/unit/rilmodem-test-server.h
@@ -21,6 +21,8 @@
#define RIL_SERVER_SOCK_PATH "/tmp/unittestril"
+struct server_data;
+
struct rilmodem_test_data {
const unsigned char *req_data;
@@ -29,12 +31,17 @@ struct rilmodem_test_data {
uint32_t rsp_error;
const unsigned char *rsp_data;
const size_t rsp_size;
+ gboolean unsol_test;
};
typedef void (*ConnectFunc)(void *data);
-void rilmodem_test_server_close(void);
+void rilmodem_test_server_close(struct server_data *sd);
-void rilmodem_test_server_create(ConnectFunc connect,
+struct server_data *rilmodem_test_server_create(ConnectFunc connect,
const struct rilmodem_test_data *test_data,
void *data);
+
+void rilmodem_test_server_write(struct server_data *sd,
+ const unsigned char *buf,
+ const size_t buf_len);
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] unit: add new test-rilmodem-sms test cases
2015-11-24 19:38 [PATCH 0/2] Add new rilmodem SMS test cases Tony Espy
2015-11-24 19:38 ` [PATCH 1/2] unit: add write support to rilmodem-test-server Tony Espy
@ 2015-11-24 19:38 ` Tony Espy
2015-11-29 21:49 ` [PATCH 0/2] Add new rilmodem SMS " Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Tony Espy @ 2015-11-24 19:38 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 17641 bytes --]
Add new test-rilmodem-sms test cases for the remaining
untested atom functions, including two tests for incoming
SMS unsolicited responses. Also updated test-rilmodem-cs
due to rilmodem-test-server changes.
---
unit/test-rilmodem-cs.c | 6 +-
unit/test-rilmodem-sms.c | 356 +++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 346 insertions(+), 16 deletions(-)
diff --git a/unit/test-rilmodem-cs.c b/unit/test-rilmodem-cs.c
index e325033..bfa2a72 100644
--- a/unit/test-rilmodem-cs.c
+++ b/unit/test-rilmodem-cs.c
@@ -51,6 +51,7 @@ struct rilmodem_cs_data {
struct ofono_modem *modem;
gconstpointer test_data;
struct ofono_call_settings *cs;
+ struct server_data *serverd;
};
typedef gboolean (*StartFunc)(gpointer data);
@@ -476,7 +477,8 @@ static void test_cs_func(gconstpointer data)
rcd->test_data = csd;
- rilmodem_test_server_create(&server_connect_cb, &csd->rtd, rcd);
+ rcd->serverd = rilmodem_test_server_create(&server_connect_cb,
+ &csd->rtd, rcd);
rcd->ril = g_ril_new("/tmp/unittestril", OFONO_RIL_VENDOR_AOSP);
g_assert(rcd->ril != NULL);
@@ -490,7 +492,7 @@ static void test_cs_func(gconstpointer data)
g_ril_unref(rcd->ril);
g_free(rcd);
- rilmodem_test_server_close();
+ rilmodem_test_server_close(rcd->serverd);
ril_call_settings_exit();
}
diff --git a/unit/test-rilmodem-sms.c b/unit/test-rilmodem-sms.c
index 34b6737..ae3b1b3 100644
--- a/unit/test-rilmodem-sms.c
+++ b/unit/test-rilmodem-sms.c
@@ -51,20 +51,24 @@ struct rilmodem_sms_data {
struct ofono_modem *modem;
gconstpointer test_data;
struct ofono_sms *sms;
+ struct server_data *serverd;
};
typedef gboolean (*StartFunc)(gpointer data);
struct sms_data {
StartFunc start_func;
- const struct ofono_phone_number ph;
- gint param_int1;
- gint param_int2;
+
+ const unsigned char *pdu;
+ gint pdu_len;
+ gint tpdu_len;
+ gint mms;
struct rilmodem_test_data rtd;
enum ofono_error_type error_type;
- gint cb_int1;
- gint cb_int2;
+
+ const struct ofono_phone_number ph;
+ gint mr;
};
static void sca_query_callback(const struct ofono_error *error,
@@ -84,6 +88,28 @@ static void sca_query_callback(const struct ofono_error *error,
g_main_loop_quit(mainloop);
}
+static void sca_set_callback(const struct ofono_error *error, gpointer data)
+{
+ struct rilmodem_sms_data *rsd = data;
+ const struct sms_data *sd = rsd->test_data;
+
+ g_assert(error->type == sd->error_type);
+
+ g_main_loop_quit(mainloop);
+}
+
+static void submit_callback(const struct ofono_error *error, int mr,
+ gpointer data)
+{
+ struct rilmodem_sms_data *rsd = data;
+ const struct sms_data *sd = rsd->test_data;
+
+ g_assert(error->type == sd->error_type);
+ g_assert(mr == sd->mr);
+
+ g_main_loop_quit(mainloop);
+}
+
static gboolean trigger_sca_query(gpointer data)
{
struct rilmodem_sms_data *rsd = data;
@@ -94,6 +120,41 @@ static gboolean trigger_sca_query(gpointer data)
return FALSE;
}
+static gboolean trigger_sca_set(gpointer data)
+{
+ struct rilmodem_sms_data *rsd = data;
+ const struct sms_data *sd = rsd->test_data;
+
+ g_assert(smsdriver->sca_set != NULL);
+ smsdriver->sca_set(rsd->sms, &sd->ph, sca_set_callback, rsd);
+
+ return FALSE;
+}
+
+static gboolean trigger_submit(gpointer data)
+{
+ struct rilmodem_sms_data *rsd = data;
+ const struct sms_data *sd = rsd->test_data;
+
+ g_assert(smsdriver->submit != NULL);
+
+ smsdriver->submit(rsd->sms, sd->pdu, sd->pdu_len, sd->tpdu_len,
+ sd->mms, submit_callback, rsd);
+
+ return FALSE;
+}
+
+static gboolean trigger_new_sms(gpointer data)
+{
+ struct rilmodem_sms_data *rsd = data;
+ const struct sms_data *sd = rsd->test_data;
+
+ rilmodem_test_server_write(rsd->serverd, sd->rtd.req_data,
+ sd->rtd.req_size);
+
+ return FALSE;
+}
+
/* RIL_REQUEST_GET_SMSC_ADDRESS */
static const guchar req_get_smsc_address_parcel_1[] = {
0x00, 0x00, 0x00, 0x08, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -103,18 +164,16 @@ static const guchar req_get_smsc_address_parcel_1[] = {
/*
* RIL_REQUEST_GET_SMSC_ADDRESS reply with the following data:
*
- * {type=145,number=34607003110}
+ * {number="+34607003110"}
*/
static const guchar rsp_get_smsc_address_data_1[] = {
- 0x12, 0x00, 0x00, 0x00, 0x22, 0x00, 0x2b, 0x00, 0x33, 0x00, 0x34, 0x00,
+ 0x0d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x2b, 0x00, 0x33, 0x00, 0x34, 0x00,
0x36, 0x00, 0x30, 0x00, 0x37, 0x00, 0x30, 0x00, 0x30, 0x00, 0x33, 0x00,
- 0x31, 0x00, 0x31, 0x00, 0x30, 0x00, 0x22, 0x00, 0x2c, 0x00, 0x31, 0x00,
- 0x34, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x31, 0x00, 0x31, 0x00, 0x30, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const struct sms_data testdata_sca_query_valid_1 = {
.start_func = trigger_sca_query,
- .ph = { .number = "34607003110", .type = 145 },
.rtd = {
.req_data = req_get_smsc_address_parcel_1,
.req_size = sizeof(req_get_smsc_address_parcel_1),
@@ -122,16 +181,246 @@ static const struct sms_data testdata_sca_query_valid_1 = {
.rsp_size = sizeof(rsp_get_smsc_address_data_1),
.rsp_error = RIL_E_SUCCESS,
},
- .cb_int1 = 1,
+ .ph = { .number = "34607003110", .type = 145 },
.error_type = OFONO_ERROR_TYPE_NO_ERROR,
};
+/*
+ * RIL_REQUEST_GET_SMSC_ADDRESS reply with no data, which should
+ * trigger a callback failure.
+ */
+static const struct sms_data testdata_sca_query_invalid_1 = {
+ .start_func = trigger_sca_query,
+ .rtd = {
+ .req_data = req_get_smsc_address_parcel_1,
+ .req_size = sizeof(req_get_smsc_address_parcel_1),
+ .rsp_error = RIL_E_SUCCESS,
+ },
+ .error_type = OFONO_ERROR_TYPE_FAILURE,
+};
+
+/*
+ * RIL_REQUEST_GET_SMSC_ADDRESS reply with no quotes found which
+ * should trigger a callback failure.
+ */
+static const guchar rsp_get_smsc_address_data_3[] = {
+ 0x02, 0x00, 0x00, 0x00, 0x22, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const struct sms_data testdata_sca_query_invalid_2 = {
+ .start_func = trigger_sca_query,
+ .ph = { .number = "34607003110", .type = 145 },
+ .rtd = {
+ .req_data = req_get_smsc_address_parcel_1,
+ .req_size = sizeof(req_get_smsc_address_parcel_1),
+ .rsp_data = rsp_get_smsc_address_data_3,
+ .rsp_size = sizeof(rsp_get_smsc_address_data_3),
+ .rsp_error = RIL_E_SUCCESS,
+ },
+ .error_type = OFONO_ERROR_TYPE_FAILURE,
+};
+
+/* GENERIC_FAILURE returned in RIL reply */
+static const struct sms_data testdata_sca_query_invalid_3 = {
+ .start_func = trigger_sca_query,
+ .rtd = {
+ .req_data = req_get_smsc_address_parcel_1,
+ .req_size = sizeof(req_get_smsc_address_parcel_1),
+ .rsp_error = RIL_E_GENERIC_FAILURE,
+ },
+ .error_type = OFONO_ERROR_TYPE_FAILURE,
+};
+
+/*
+ * RIL_REQUEST_SET_SMSC_ADDRESS with the following data:
+ *
+ * {number="+34607003110"}
+ */
+static const guchar req_set_smsc_address_parcel_1[] = {
+ 0x00, 0x00, 0x00, 0x28, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x33, 0x00, 0x34, 0x00, 0x36, 0x00,
+ 0x30, 0x00, 0x37, 0x00, 0x30, 0x00, 0x30, 0x00, 0x33, 0x00, 0x31, 0x00,
+ 0x31, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const struct sms_data testdata_sca_set_valid_1 = {
+ .start_func = trigger_sca_set,
+ .ph = { .number = "34607003110", .type = 145 },
+ .rtd = {
+ .req_data = req_set_smsc_address_parcel_1,
+ .req_size = sizeof(req_set_smsc_address_parcel_1),
+ .rsp_error = RIL_E_SUCCESS,
+ },
+ .error_type = OFONO_ERROR_TYPE_NO_ERROR,
+};
+
+/* GENERIC_FAILURE returned in RIL reply */
+static const struct sms_data testdata_sca_set_invalid_1 = {
+ .start_func = trigger_sca_set,
+ .ph = { .number = "34607003110", .type = 145 },
+ .rtd = {
+ .req_data = req_set_smsc_address_parcel_1,
+ .req_size = sizeof(req_set_smsc_address_parcel_1),
+ .rsp_error = RIL_E_GENERIC_FAILURE,
+ },
+ .error_type = OFONO_ERROR_TYPE_FAILURE,
+};
+
+static const unsigned char req_send_sms_pdu_valid_1[] = {
+ 0x00, 0x11, 0x00, 0x09, 0x81, 0x36, 0x54, 0x39, 0x80, 0xf5, 0x00, 0x00,
+ 0xa7, 0x0a, 0xc8, 0x37, 0x3b, 0x0c, 0x6a, 0xd7, 0xdd, 0xe4, 0x37
+};
+
+static const guchar req_send_sms_parcel_1[] = {
+ 0x00, 0x00, 0x00, 0x70, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00,
+ 0x31, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x39, 0x00,
+ 0x38, 0x00, 0x31, 0x00, 0x33, 0x00, 0x36, 0x00, 0x35, 0x00, 0x34, 0x00,
+ 0x33, 0x00, 0x39, 0x00, 0x38, 0x00, 0x30, 0x00, 0x46, 0x00, 0x35, 0x00,
+ 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x41, 0x00, 0x37, 0x00,
+ 0x30, 0x00, 0x41, 0x00, 0x43, 0x00, 0x38, 0x00, 0x33, 0x00, 0x37, 0x00,
+ 0x33, 0x00, 0x42, 0x00, 0x30, 0x00, 0x43, 0x00, 0x36, 0x00, 0x41, 0x00,
+ 0x44, 0x00, 0x37, 0x00, 0x44, 0x00, 0x44, 0x00, 0x45, 0x00, 0x34, 0x00,
+ 0x33, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/*
+ * SEND_SMS reply with the following data:
+ *
+ * messageRef=1
+ * ackPDU=NULL
+ * errorCode=0
+ */
+static const guchar rsp_send_sms_valid_1[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const struct sms_data testdata_submit_valid_1 = {
+ .start_func = trigger_submit,
+ .pdu = req_send_sms_pdu_valid_1,
+ .pdu_len = sizeof(req_send_sms_pdu_valid_1),
+ .tpdu_len = sizeof(req_send_sms_pdu_valid_1) - 1,
+ .mms = 0,
+ .rtd = {
+ .req_data = req_send_sms_parcel_1,
+ .req_size = sizeof(req_send_sms_parcel_1),
+ .rsp_data = rsp_send_sms_valid_1,
+ .rsp_size = sizeof(rsp_send_sms_valid_1),
+ .rsp_error = RIL_E_SUCCESS,
+ },
+ .mr = 1,
+ .error_type = OFONO_ERROR_TYPE_NO_ERROR,
+};
+
+/*
+ * SEND_SMS reply with failure indicated
+ */
+static const struct sms_data testdata_submit_invalid_1 = {
+ .start_func = trigger_submit,
+ .pdu = req_send_sms_pdu_valid_1,
+ .pdu_len = sizeof(req_send_sms_pdu_valid_1),
+ .tpdu_len = sizeof(req_send_sms_pdu_valid_1) - 1,
+ .mms = 0,
+ .rtd = {
+ .req_data = req_send_sms_parcel_1,
+ .req_size = sizeof(req_send_sms_parcel_1),
+ .rsp_error = RIL_E_GENERIC_FAILURE,
+ },
+ .error_type = OFONO_ERROR_TYPE_FAILURE,
+};
+
+/*
+ * The following hexadecimal data represents a serialized Binder parcel
+ * instance containing a valid RIL_UNSOL_RESPONSE_NEW_SMS message
+ * with the following parameter (SMSC address length is 7):
+ *
+ * {07914306073011F0040B914336543980F50000310113212002400AC8373B0C6AD7DDE437}
+ * {069143060730F0040B914336543980F50000310113212002400AC8373B0C6AD7DDE437}
+ */
+static const guchar unsol_response_new_sms_parcel_1[] = {
+ 0x00, 0x00, 0x00, 0xA0, 0x01, 0x00, 0x00, 0x00, 0xEB, 0x03, 0x00, 0x00,
+ 0x48, 0x00, 0x00, 0x00, 0x30, 0x00, 0x37, 0x00, 0x39, 0x00, 0x31, 0x00,
+ 0x34, 0x00, 0x33, 0x00, 0x30, 0x00, 0x36, 0x00, 0x30, 0x00, 0x37, 0x00,
+ 0x33, 0x00, 0x30, 0x00, 0x31, 0x00, 0x31, 0x00, 0x46, 0x00, 0x30, 0x00,
+ 0x30, 0x00, 0x34, 0x00, 0x30, 0x00, 0x42, 0x00, 0x39, 0x00, 0x31, 0x00,
+ 0x34, 0x00, 0x33, 0x00, 0x33, 0x00, 0x36, 0x00, 0x35, 0x00, 0x34, 0x00,
+ 0x33, 0x00, 0x39, 0x00, 0x38, 0x00, 0x30, 0x00, 0x46, 0x00, 0x35, 0x00,
+ 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x33, 0x00, 0x31, 0x00,
+ 0x30, 0x00, 0x31, 0x00, 0x31, 0x00, 0x33, 0x00, 0x32, 0x00, 0x31, 0x00,
+ 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 0x00, 0x30, 0x00,
+ 0x30, 0x00, 0x41, 0x00, 0x43, 0x00, 0x38, 0x00, 0x33, 0x00, 0x37, 0x00,
+ 0x33, 0x00, 0x42, 0x00, 0x30, 0x00, 0x43, 0x00, 0x36, 0x00, 0x41, 0x00,
+ 0x44, 0x00, 0x37, 0x00, 0x44, 0x00, 0x44, 0x00, 0x45, 0x00, 0x34, 0x00,
+ 0x33, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+const unsigned char new_sms_pdu_valid_1[] = {
+ 0x07, 0x91, 0x43, 0x06, 0x07, 0x30, 0x11, 0xf0, 0x04, 0x0b, 0x91, 0x43,
+ 0x36, 0x54, 0x39, 0x80, 0xf5, 0x00, 0x00, 0x31, 0x01, 0x13, 0x21, 0x20,
+ 0x02, 0x40, 0x0a, 0xc8, 0x37, 0x3b, 0x0c, 0x6a, 0xd7, 0xdd, 0xe4, 0x37
+};
+
+static const struct sms_data testdata_new_sms_valid_1 = {
+ .start_func = trigger_new_sms,
+ .rtd = {
+ .req_data = unsol_response_new_sms_parcel_1,
+ .req_size = sizeof(unsol_response_new_sms_parcel_1),
+ .unsol_test = TRUE,
+ },
+ .pdu = new_sms_pdu_valid_1,
+ .pdu_len = sizeof(new_sms_pdu_valid_1),
+ .tpdu_len = 28,
+};
+
+/*
+ * The following hexadecimal data represents a serialized Binder parcel
+ * instance containing a valid UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT message
+ * with the following parameter (SMSC address length is 6):
+ *
+ * {069143060730F0040B914336543980F50000310113212002400AC8373B0C6AD7DDE437}
+ */
+static const guchar unsol_response_new_sms_parcel_2[] = {
+ 0x00, 0x00, 0x00, 0x9C, 0x01, 0x00, 0x00, 0x00, 0xEC, 0x03, 0x00, 0x00,
+ 0x46, 0x00, 0x00, 0x00, 0x30, 0x00, 0x36, 0x00, 0x39, 0x00, 0x31, 0x00,
+ 0x34, 0x00, 0x33, 0x00, 0x30, 0x00, 0x36, 0x00, 0x30, 0x00, 0x37, 0x00,
+ 0x33, 0x00, 0x30, 0x00, 0x46, 0x00, 0x30, 0x00, 0x30, 0x00, 0x34, 0x00,
+ 0x30, 0x00, 0x42, 0x00, 0x39, 0x00, 0x31, 0x00, 0x34, 0x00, 0x33, 0x00,
+ 0x33, 0x00, 0x36, 0x00, 0x35, 0x00, 0x34, 0x00, 0x33, 0x00, 0x39, 0x00,
+ 0x38, 0x00, 0x30, 0x00, 0x46, 0x00, 0x35, 0x00, 0x30, 0x00, 0x30, 0x00,
+ 0x30, 0x00, 0x30, 0x00, 0x33, 0x00, 0x31, 0x00, 0x30, 0x00, 0x31, 0x00,
+ 0x31, 0x00, 0x33, 0x00, 0x32, 0x00, 0x31, 0x00, 0x32, 0x00, 0x30, 0x00,
+ 0x30, 0x00, 0x32, 0x00, 0x34, 0x00, 0x30, 0x00, 0x30, 0x00, 0x41, 0x00,
+ 0x43, 0x00, 0x38, 0x00, 0x33, 0x00, 0x37, 0x00, 0x33, 0x00, 0x42, 0x00,
+ 0x30, 0x00, 0x43, 0x00, 0x36, 0x00, 0x41, 0x00, 0x44, 0x00, 0x37, 0x00,
+ 0x44, 0x00, 0x44, 0x00, 0x45, 0x00, 0x34, 0x00, 0x33, 0x00, 0x37, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+const unsigned char new_sms_pdu_valid_2[] = {
+ 0x06, 0x91, 0x43, 0x06, 0x07, 0x30, 0xf0, 0x04, 0x0b, 0x91, 0x43, 0x36,
+ 0x54, 0x39, 0x80, 0xf5, 0x00, 0x00, 0x31, 0x01, 0x13, 0x21, 0x20, 0x02,
+ 0x40, 0x0a, 0xc8, 0x37, 0x3b, 0x0c, 0x6a, 0xd7, 0xdd, 0xe4, 0x37
+};
+
+static const struct sms_data testdata_new_sms_valid_2 = {
+ .start_func = trigger_new_sms,
+ .rtd = {
+ .req_data = unsol_response_new_sms_parcel_2,
+ .req_size = sizeof(unsol_response_new_sms_parcel_2),
+ .unsol_test = TRUE,
+ },
+ .pdu = new_sms_pdu_valid_2,
+ .pdu_len = sizeof(new_sms_pdu_valid_2),
+ .tpdu_len = 28,
+};
+
/* Declarations && Re-implementations of core functions. */
void ril_sms_exit(void);
void ril_sms_init(void);
struct ofono_sms {
void *driver_data;
+ const struct sms_data *sd;
};
struct ofono_sms *ofono_sms_create(struct ofono_modem *modem,
@@ -178,11 +467,17 @@ void ofono_sms_driver_unregister(const struct ofono_sms_driver *d)
void ofono_sms_deliver_notify(struct ofono_sms *sms, const unsigned char *pdu,
int len, int tpdu_len)
{
+ g_assert(sms->sd->pdu_len == len);
+ g_assert(sms->sd->tpdu_len == tpdu_len);
+ g_assert(!memcmp(pdu, sms->sd->pdu, len));
+
+ g_main_loop_quit(mainloop);
}
void ofono_sms_status_notify(struct ofono_sms *sms, const unsigned char *pdu,
int len, int tpdu_len)
{
+ ofono_sms_deliver_notify(sms, pdu, len, tpdu_len);
}
static void server_connect_cb(gpointer data)
@@ -193,9 +488,14 @@ static void server_connect_cb(gpointer data)
/* This causes local impl of _create() to call driver's probe func. */
rsd->sms = ofono_sms_create(NULL, OFONO_RIL_VENDOR_AOSP,
"rilmodem", rsd);
+ rsd->sms->sd = sd;
/* add_idle doesn't work, read blocks main loop!!! */
- g_assert(sd->start_func(rsd) == FALSE);
+
+ if (sd->rtd.unsol_test)
+ g_idle_add(sd->start_func, (void *) rsd);
+ else
+ g_assert(sd->start_func(rsd) == FALSE);
}
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -220,7 +520,8 @@ static void test_sms_func(gconstpointer data)
rsd->test_data = sd;
- rilmodem_test_server_create(&server_connect_cb, &sd->rtd, rsd);
+ rsd->serverd = rilmodem_test_server_create(&server_connect_cb,
+ &sd->rtd, rsd);
rsd->ril = g_ril_new(RIL_SERVER_SOCK_PATH, OFONO_RIL_VENDOR_AOSP);
g_assert(rsd->ril != NULL);
@@ -234,7 +535,7 @@ static void test_sms_func(gconstpointer data)
g_ril_unref(rsd->ril);
g_free(rsd);
- rilmodem_test_server_close();
+ rilmodem_test_server_close(rsd->serverd);
ril_sms_exit();
}
@@ -255,6 +556,33 @@ int main(int argc, char **argv)
g_test_add_data_func("/testrilmodemsms/sca_query/valid/1",
&testdata_sca_query_valid_1,
test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/sca_query/invalid/1",
+ &testdata_sca_query_invalid_1,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/sca_query/invalid/2",
+ &testdata_sca_query_invalid_2,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/sca_query/invalid/3",
+ &testdata_sca_query_invalid_3,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/sca_set/valid/1",
+ &testdata_sca_set_valid_1,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/sca_set/invalid/1",
+ &testdata_sca_set_invalid_1,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/submit/valid/1",
+ &testdata_submit_valid_1,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/submit/invalid/1",
+ &testdata_submit_invalid_1,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/new_sms/valid/1",
+ &testdata_new_sms_valid_1,
+ test_sms_func);
+ g_test_add_data_func("/testrilmodemsms/new_sms/valid/2",
+ &testdata_new_sms_valid_2,
+ test_sms_func);
#endif
return g_test_run();
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Add new rilmodem SMS test cases
2015-11-24 19:38 [PATCH 0/2] Add new rilmodem SMS test cases Tony Espy
2015-11-24 19:38 ` [PATCH 1/2] unit: add write support to rilmodem-test-server Tony Espy
2015-11-24 19:38 ` [PATCH 2/2] unit: add new test-rilmodem-sms test cases Tony Espy
@ 2015-11-29 21:49 ` Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2015-11-29 21:49 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 618 bytes --]
Hi Tony,
On 11/24/2015 01:38 PM, Tony Espy wrote:
> This patchset adds new rilmodem SMS test cases, including
> tests for incoming SMS unsolicited responses.
>
> Tony Espy (2):
> unit: add write support to rilmodem-test-server
> unit: add new test-rilmodem-sms test cases
>
> unit/rilmodem-test-server.c | 113 ++++++++------
> unit/rilmodem-test-server.h | 11 +-
> unit/test-rilmodem-cs.c | 6 +-
> unit/test-rilmodem-sms.c | 356 ++++++++++++++++++++++++++++++++++++++++++--
> 4 files changed, 426 insertions(+), 60 deletions(-)
>
Both applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-29 21:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 19:38 [PATCH 0/2] Add new rilmodem SMS test cases Tony Espy
2015-11-24 19:38 ` [PATCH 1/2] unit: add write support to rilmodem-test-server Tony Espy
2015-11-24 19:38 ` [PATCH 2/2] unit: add new test-rilmodem-sms test cases Tony Espy
2015-11-29 21:49 ` [PATCH 0/2] Add new rilmodem SMS " Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.