summaryrefslogtreecommitdiff
path: root/unit
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2017-11-07 12:36:43 -0600
committerDenis Kenzior <denkenz@gmail.com>2017-11-08 21:02:22 -0600
commit1d7a41205b3433ace8c894a5c6818b51178229a8 (patch)
treefc9e253d21231e8b3d7b3413430f576c6b32243b /unit
parent1bf22999e594faf75c96d1b9a53c1b1f8b87a345 (diff)
downloadofono-1d7a41205b3433ace8c894a5c6818b51178229a8.tar.gz
unit: Add SMS Read response tests
Diffstat (limited to 'unit')
-rw-r--r--unit/test-mbim.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/unit/test-mbim.c b/unit/test-mbim.c
index 4c1a021f..40b924ec 100644
--- a/unit/test-mbim.c
+++ b/unit/test-mbim.c
@@ -125,6 +125,44 @@ static const struct message_data message_data_phonebook_read = {
.binary_len = sizeof(message_binary_phonebook_read),
};
+static const unsigned char message_binary_sms_read_all_empty[] = {
+ 0x03, 0x00, 0x00, 0x80, 0x38, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x3f, 0xbe, 0xeb,
+ 0x14, 0xfe, 0x44, 0x67, 0x9f, 0x90, 0x33, 0xa2, 0x23, 0xe5, 0x6c, 0x3f,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct message_data message_data_sms_read_all_empty = {
+ .tid = 8,
+ .binary = message_binary_sms_read_all_empty,
+ .binary_len = sizeof(message_binary_sms_read_all_empty),
+};
+
+static const unsigned char message_binary_sms_read_all[] = {
+ 0x03, 0x00, 0x00, 0x80, 0xac, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x3f, 0xbe, 0xeb,
+ 0x14, 0xfe, 0x44, 0x67, 0x9f, 0x90, 0x33, 0xa2, 0x23, 0xe5, 0x6c, 0x3f,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+ 0x2f, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0x1f, 0x00, 0x00, 0x00, 0x07, 0x91, 0x61, 0x63, 0x83, 0x84, 0x29, 0xf3,
+ 0x04, 0x0b, 0x91, 0x51, 0x21, 0x55, 0x30, 0x71, 0xf9, 0x00, 0x00, 0x71,
+ 0x11, 0x70, 0x91, 0x62, 0x65, 0x4a, 0x04, 0xd4, 0xf2, 0x9c, 0x0e, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0x21, 0x00, 0x00, 0x00, 0x07, 0x91, 0x61, 0x63, 0x83, 0x84, 0x29, 0xf2,
+ 0x04, 0x0b, 0x91, 0x51, 0x21, 0x55, 0x30, 0x71, 0xf9, 0x00, 0x00, 0x71,
+ 0x11, 0x80, 0x41, 0x70, 0x55, 0x4a, 0x06, 0xc6, 0xf7, 0x1b, 0x74, 0x2f,
+ 0x03, 0x00, 0x00, 0x00
+};
+
+static const struct message_data message_data_sms_read_all = {
+ .tid = 0xc,
+ .binary = message_binary_sms_read_all,
+ .binary_len = sizeof(message_binary_sms_read_all),
+};
+
static void do_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -420,6 +458,43 @@ static void build_phonebook_read(const void *data)
mbim_message_unref(message);
}
+static void parse_sms_read_all(const void *data)
+{
+ struct mbim_message *msg = build_message(data);
+ uint32_t format;
+ uint32_t n_sms;
+ struct mbim_message_iter array;
+ struct mbim_message_iter bytes;
+ uint32_t index;
+ uint32_t status;
+ uint32_t pdu_len;
+ uint8_t pdu[176];
+ uint32_t i = 0;
+ uint32_t j = 0;
+
+ assert(mbim_message_get_arguments(msg, "ua(uuay)",
+ &format, &n_sms, &array));
+
+ assert(format == 0);
+
+ i = 0;
+
+ while (mbim_message_iter_next_entry(&array, &index, &status,
+ &pdu_len, &bytes)) {
+ i += 1;
+ j = 0;
+
+ while (mbim_message_iter_next_entry(&bytes, pdu + j))
+ j += 1;
+
+ assert(j == pdu_len);
+ }
+
+ assert(i == n_sms);
+
+ mbim_message_unref(msg);
+}
+
int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
@@ -444,5 +519,10 @@ int main(int argc, char *argv[])
l_test_add("Phonebook Read (build)", build_phonebook_read,
&message_data_phonebook_read);
+ l_test_add("SMS Read All [Empty] (parse)", parse_sms_read_all,
+ &message_data_sms_read_all_empty);
+ l_test_add("SMS Read All [1] (parse)", parse_sms_read_all,
+ &message_data_sms_read_all);
+
return l_test_run();
}