~ubuntu-branches/ubuntu/wily/ofono/wily-proposed

« back to all changes in this revision

Viewing changes to unit/test-grilreply.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Martti Piirainen, Alfonso Sanchez-Beato, Tony Espy
  • Date: 2014-07-21 18:59:17 UTC
  • mfrom: (1.3.21)
  • Revision ID: package-import@ubuntu.com-20140721185917-vwillk54uiajs9lb
Tags: 1.12.bzr6870+14.10.20140721-0ubuntu1
[ Martti Piirainen ]
* drivers/rilmodem/sim.c: notify on SIM removal (LP: #1332306)
* unit/rilmodem/test-sim-online: fix serial number check (LP: #1334867)

[ Alfonso Sanchez-Beato ]
* plugins/mtk.c: fix race condition when onlining modem
* build, drivers/infeonmodem, drivers/rilmodem, gril,
  plugins/infeon.c, plugins/ril.*, unit: add Infeon OEM hooks

[ Tony Espy ]
* build, plugins/ubuntu-provision.c, ubuntu-apndb.*: re-named
  provisioning plugin code from android-* to ubuntu-*.  Also removed
  code that queries mobile-broadband-provider-info's db, and finally
  implemented a /custom hook for custom apn dbs (LP: #1315509).

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        const struct ril_msg msg;
80
80
};
81
81
 
 
82
struct oem_hook_raw_test {
 
83
        const unsigned char *data;
 
84
        int size;
 
85
        const struct ril_msg msg;
 
86
};
 
87
 
82
88
/* Invalid RIL_REQUEST_DATA_REGISTRATION_STATE: buffer too small */
83
89
static const struct ril_msg reply_data_reg_state_invalid_1 = {
84
90
        .buf = "XYZ",
1451
1457
        }
1452
1458
};
1453
1459
 
 
1460
/*
 
1461
 * The following structure contains test data for a valid
 
1462
 * RIL_REQUEST_OEM_HOOK_RAW reply with parameter {4,0x11111111}
 
1463
 */
 
1464
static const guchar reply_oem_hook_raw_valid_parcel1[] = {
 
1465
        0x04, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11
 
1466
};
 
1467
 
 
1468
static const struct oem_hook_raw_test reply_oem_hook_raw_valid_1 = {
 
1469
        .data = reply_oem_hook_raw_valid_parcel1 + sizeof(int32_t),
 
1470
        .size = (int) (sizeof(reply_oem_hook_raw_valid_parcel1)
 
1471
                        - sizeof(int32_t)),
 
1472
        .msg = {
 
1473
                .buf = (gchar *) reply_oem_hook_raw_valid_parcel1,
 
1474
                .buf_len = sizeof(reply_oem_hook_raw_valid_parcel1),
 
1475
                .unsolicited = FALSE,
 
1476
                .req = RIL_REQUEST_OEM_HOOK_RAW,
 
1477
                .serial_no = 0,
 
1478
                .error = RIL_E_SUCCESS,
 
1479
        }
 
1480
};
 
1481
 
 
1482
/*
 
1483
 * The following structure contains test data for a valid
 
1484
 * RIL_REQUEST_OEM_HOOK_RAW reply with parameter {-1}
 
1485
 */
 
1486
static const guchar reply_oem_hook_raw_valid_parcel2[] = {
 
1487
        0xFF, 0xFF, 0xFF, 0xFF
 
1488
};
 
1489
 
 
1490
static const struct oem_hook_raw_test reply_oem_hook_raw_valid_2 = {
 
1491
        .data = NULL,
 
1492
        .size = -1,
 
1493
        .msg = {
 
1494
                .buf = (gchar *) reply_oem_hook_raw_valid_parcel2,
 
1495
                .buf_len = sizeof(reply_oem_hook_raw_valid_parcel2),
 
1496
                .unsolicited = FALSE,
 
1497
                .req = RIL_REQUEST_OEM_HOOK_RAW,
 
1498
                .serial_no = 0,
 
1499
                .error = RIL_E_SUCCESS,
 
1500
        }
 
1501
};
 
1502
 
1454
1503
static void test_reply_reg_state_invalid(gconstpointer data)
1455
1504
{
1456
1505
        struct reply_reg_state *reply = g_ril_reply_parse_reg_state(NULL, data);
1669
1718
        g_free(retries);
1670
1719
}
1671
1720
 
 
1721
static void test_reply_oem_hook_raw_valid(gconstpointer data)
 
1722
{
 
1723
        const struct oem_hook_raw_test *test = data;
 
1724
        struct reply_oem_hook *reply =
 
1725
                g_ril_reply_oem_hook_raw(NULL, &test->msg);
 
1726
 
 
1727
        g_assert(reply->length == test->size);
 
1728
        if (reply->length >= 0)
 
1729
                g_assert(!memcmp(reply->data, test->data, test->size));
 
1730
        else
 
1731
                g_assert(reply->data == NULL);
 
1732
}
 
1733
 
1672
1734
#endif
1673
1735
 
1674
1736
int main(int argc, char **argv)
1958
2020
                                &reply_enter_sim_pin_valid_2,
1959
2021
                                test_reply_enter_sim_pin_valid);
1960
2022
 
 
2023
        g_test_add_data_func("/testgrilreply/oem: "
 
2024
                                "valid OEM_HOOK_RAW Test 1",
 
2025
                                &reply_oem_hook_raw_valid_1,
 
2026
                                test_reply_oem_hook_raw_valid);
 
2027
 
 
2028
        g_test_add_data_func("/testgrilreply/oem: "
 
2029
                                "valid OEM_HOOK_RAW Test 2",
 
2030
                                &reply_oem_hook_raw_valid_2,
 
2031
                                test_reply_oem_hook_raw_valid);
 
2032
 
1961
2033
#endif
1962
2034
 
1963
2035
        return g_test_run();