From 64aae865f0b2b05c1847e503f8ef3c550525f2e3 Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Wed, 19 Jul 2017 16:48:44 -0700 Subject: [PATCH] RadioV1_1 VTS Tests: startKeepalive, stopKeepalive VTS tests for the initial implementaion of NATT Keepalive support in the V1_1 HAL. Bug:63530561 Test: this Change-Id: Iafabd4b0f8a8f4da78f65bf4061d47f4bfd69a7a --- radio/1.1/vts/functional/radio_hidl_hal_api.cpp | 115 ++++++++++++++++++++- .../1.1/vts/functional/radio_hidl_hal_utils_v1_1.h | 3 +- radio/1.1/vts/functional/radio_response.cpp | 13 ++- 3 files changed, 125 insertions(+), 6 deletions(-) diff --git a/radio/1.1/vts/functional/radio_hidl_hal_api.cpp b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp index 549b5926..36fd7c29 100644 --- a/radio/1.1/vts/functional/radio_hidl_hal_api.cpp +++ b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp @@ -15,6 +15,7 @@ */ #include +#include /* * Test IRadio.setSimCardPower() for the response returned. @@ -129,4 +130,116 @@ TEST_F(RadioHidlTest_v1_1, setCarrierInfoForImsiEncryption) { ASSERT_TRUE(radioRsp_v1_1->rspInfo.error == RadioError::NONE || radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); } -} \ No newline at end of file +} + +/* + * Test IRadio.startKeepalive() for the response returned. + */ +TEST_F(RadioHidlTest_v1_1, startKeepalive) { + std::vector requests = { + { + // Invalid IPv4 source address + KeepaliveType::NATT_IPV4, + {192, 168, 0 /*, 100*/}, + 1234, + {8, 8, 4, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid IPv4 destination address + KeepaliveType::NATT_IPV4, + {192, 168, 0, 100}, + 1234, + {8, 8, 4, 4, 1, 2, 3, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid Keepalive Type + static_cast(-1), + {192, 168, 0, 100}, + 1234, + {8, 8, 4, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid IPv6 source address + KeepaliveType::NATT_IPV6, + {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xED, + 0xBE, 0xEF, 0xBD}, + 1234, + {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x88, 0x44}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid IPv6 destination address + KeepaliveType::NATT_IPV6, + {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xED, + 0xBE, 0xEF}, + 1234, + {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x88, + /*0x44*/}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid Context ID (cid), this should survive the initial + // range checking and fail in the modem data layer + KeepaliveType::NATT_IPV4, + {192, 168, 0, 100}, + 1234, + {8, 8, 4, 4}, + 4500, + 20000, + 0xBAD, + }, + { + // Invalid Context ID (cid), this should survive the initial + // range checking and fail in the modem data layer + KeepaliveType::NATT_IPV6, + {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xED, + 0xBE, 0xEF}, + 1234, + {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x88, 0x44}, + 4500, + 20000, + 0xBAD, + }}; + + for (auto req = requests.begin(); req != requests.end(); req++) { + int serial = GetRandomSerialNumber(); + radio_v1_1->startKeepalive(serial, *req); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial); + + ASSERT_TRUE(radioRsp_v1_1->rspInfo.error == RadioError::INVALID_ARGUMENTS || + radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); + } +} + +/* + * Test IRadio.stopKeepalive() for the response returned. + */ +TEST_F(RadioHidlTest_v1_1, stopKeepalive) { + int serial = GetRandomSerialNumber(); + + radio_v1_1->stopKeepalive(serial, 0xBAD); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial); + + ASSERT_TRUE(radioRsp_v1_1->rspInfo.error == RadioError::INVALID_ARGUMENTS || + radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED); +} diff --git a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h index dd4f1efc..c797e352 100644 --- a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h +++ b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h @@ -53,6 +53,7 @@ class RadioResponse_v1_1 : public ::android::hardware::radio::V1_1::IRadioRespon hidl_string imsi; IccIoResult iccIoResult; int channelId; + KeepaliveStatus keepaliveStatus; // Sms SendSmsResult sendSmsResult; @@ -567,4 +568,4 @@ class RadioHidlEnvironment : public ::testing::Environment { public: virtual void SetUp() {} virtual void TearDown() {} -}; \ No newline at end of file +}; diff --git a/radio/1.1/vts/functional/radio_response.cpp b/radio/1.1/vts/functional/radio_response.cpp index 407b4640..400ef3c0 100644 --- a/radio/1.1/vts/functional/radio_response.cpp +++ b/radio/1.1/vts/functional/radio_response.cpp @@ -683,11 +683,16 @@ Return RadioResponse_v1_1::stopNetworkScanResponse(const RadioResponseInfo return Void(); } -Return RadioResponse_v1_1::startKeepaliveResponse(const RadioResponseInfo& /*info*/, - const KeepaliveStatus& /*status*/) { +Return RadioResponse_v1_1::startKeepaliveResponse(const RadioResponseInfo& info, + const KeepaliveStatus& status) { + rspInfo = info; + keepaliveStatus = status; + parent_v1_1.notify(); return Void(); } -Return RadioResponse_v1_1::stopKeepaliveResponse(const RadioResponseInfo& /*info*/) { +Return RadioResponse_v1_1::stopKeepaliveResponse(const RadioResponseInfo& info) { + rspInfo = info; + parent_v1_1.notify(); return Void(); -} \ No newline at end of file +} -- 2.11.0