From ddaea2e5a4cca53319a3cb61974c03fc32b50930 Mon Sep 17 00:00:00 2001 From: Sarah Chin Date: Thu, 20 Apr 2023 16:10:37 -0700 Subject: [PATCH] Fix broken and flaky VTS tests 1. nvResetConfig takes some time to reset the modem, causing subsequent tests to fail with a timeout since the modem is unavailabe. Add a timeout after nvResetConfig to allow the modem to be up again before running the next test. 2. Remove invalid errors for start/stopKeepalive. These tests should fail due to invalid arguments, so remove NONE as a possible error. RADIO_NOT_AVAILABLE should also be removed. 3. Fix incorrect startNetworkScan_InvalidInterval tests, since we only check the interval when the scan type is PERIODIC. 4. Save and reset the previous allowed network type bitmap after the test. Combine get/set into one test that tests both behaviors. 5. Fix checks for MCC/MNC in getDataRegistrationState Bug: 277626718 Bug: 240953393 Bug: 264913330 Bug: 259674407 Bug: 242801688 Test: atest VtsHalRadioTargetTest Change-Id: Ic7188f9d8ccfcd90d844b45e3b370a3be3c515d6 Merged-In: Ic7188f9d8ccfcd90d844b45e3b370a3be3c515d6 --- .../vts/functional/radio_hidl_hal_misc.cpp | 2 + radio/aidl/vts/radio_data_test.cpp | 6 +-- radio/aidl/vts/radio_modem_test.cpp | 2 + radio/aidl/vts/radio_network_test.cpp | 43 ++++++++++--------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp index 624d00381f..ee8b4dcb95 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp @@ -654,6 +654,8 @@ TEST_P(RadioHidlTest, nvResetConfig) { ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); } + // wait until modem reset finishes + sleep(10); LOG(DEBUG) << "nvResetConfig finished"; } diff --git a/radio/aidl/vts/radio_data_test.cpp b/radio/aidl/vts/radio_data_test.cpp index aa6ac88e1f..3eedc146ff 100644 --- a/radio/aidl/vts/radio_data_test.cpp +++ b/radio/aidl/vts/radio_data_test.cpp @@ -531,8 +531,7 @@ TEST_P(RadioDataTest, startKeepalive) { ASSERT_TRUE(CheckAnyOfErrors( radioRsp_data->rspInfo.error, - {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS, - RadioError::REQUEST_NOT_SUPPORTED})); + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); } } @@ -549,8 +548,7 @@ TEST_P(RadioDataTest, stopKeepalive) { ASSERT_TRUE( CheckAnyOfErrors(radioRsp_data->rspInfo.error, - {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, - RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); + {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); } /* diff --git a/radio/aidl/vts/radio_modem_test.cpp b/radio/aidl/vts/radio_modem_test.cpp index f88da13af1..e86737888f 100644 --- a/radio/aidl/vts/radio_modem_test.cpp +++ b/radio/aidl/vts/radio_modem_test.cpp @@ -264,6 +264,8 @@ TEST_P(RadioModemTest, nvResetConfig) { ASSERT_TRUE(CheckAnyOfErrors(radioRsp_modem->rspInfo.error, {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED})); } + // wait until modem reset finishes + sleep(10); LOG(DEBUG) << "nvResetConfig finished"; } diff --git a/radio/aidl/vts/radio_network_test.cpp b/radio/aidl/vts/radio_network_test.cpp index 61b34d7db5..86cf2d23dc 100644 --- a/radio/aidl/vts/radio_network_test.cpp +++ b/radio/aidl/vts/radio_network_test.cpp @@ -66,12 +66,20 @@ void RadioNetworkTest::stopNetworkScan() { } /* - * Test IRadioNetwork.setAllowedNetworkTypesBitmap for the response returned. + * Test IRadioNetwork.setAllowedNetworkTypesBitmap and IRadioNetwork.getAllowedNetworkTypesBitmap + * for the response returned. */ -TEST_P(RadioNetworkTest, setAllowedNetworkTypesBitmap) { +TEST_P(RadioNetworkTest, setGetAllowedNetworkTypesBitmap) { serial = GetRandomSerialNumber(); - int32_t allowedNetworkTypesBitmap = static_cast(RadioAccessFamily::LTE); + // save current value + radio_network->getAllowedNetworkTypesBitmap(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + int32_t currentAllowedNetworkTypesBitmap = radioRsp_network->networkTypeBitmapResponse; + + // set new value + int32_t allowedNetworkTypesBitmap = static_cast(RadioAccessFamily::LTE); + serial = GetRandomSerialNumber(); radio_network->setAllowedNetworkTypesBitmap(serial, allowedNetworkTypesBitmap); EXPECT_EQ(std::cv_status::no_timeout, wait()); @@ -83,20 +91,6 @@ TEST_P(RadioNetworkTest, setAllowedNetworkTypesBitmap) { RadioError::MODE_NOT_SUPPORTED, RadioError::INTERNAL_ERR, RadioError::MODEM_ERR, RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED, RadioError::NO_RESOURCES})); -} - -/* - * Test IRadioNetwork.getAllowedNetworkTypesBitmap for the response returned. - */ -TEST_P(RadioNetworkTest, getAllowedNetworkTypesBitmap) { - serial = GetRandomSerialNumber(); - int32_t allowedNetworkTypesBitmap = static_cast(RadioAccessFamily::LTE); - - radio_network->setAllowedNetworkTypesBitmap(serial, allowedNetworkTypesBitmap); - - EXPECT_EQ(std::cv_status::no_timeout, wait()); - EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type); - EXPECT_EQ(serial, radioRsp_network->rspInfo.serial); if (radioRsp_network->rspInfo.error == RadioError::NONE) { sleep(3); // wait for modem @@ -112,7 +106,16 @@ TEST_P(RadioNetworkTest, getAllowedNetworkTypesBitmap) { RadioError::OPERATION_NOT_ALLOWED, RadioError::MODE_NOT_SUPPORTED, RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED, RadioError::NO_RESOURCES})); + if (radioRsp_network->rspInfo.error == RadioError::NONE) { + // verify we get the value we set + ASSERT_EQ(radioRsp_network->networkTypeBitmapResponse, allowedNetworkTypesBitmap); + } } + + // reset value to previous + serial = GetRandomSerialNumber(); + radio_network->setAllowedNetworkTypesBitmap(serial, currentAllowedNetworkTypesBitmap); + EXPECT_EQ(std::cv_status::no_timeout, wait()); } /* @@ -920,7 +923,7 @@ TEST_P(RadioNetworkTest, startNetworkScan_InvalidInterval1) { RadioAccessSpecifier specifier850 = { .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; - NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_PERIODIC, .interval = 4, .specifiers = {specifierP900, specifier850}, .maxSearchTime = 60, @@ -961,7 +964,7 @@ TEST_P(RadioNetworkTest, startNetworkScan_InvalidInterval2) { RadioAccessSpecifier specifier850 = { .accessNetwork = AccessNetwork::GERAN, .bands = band850, .channels = {128, 129}}; - NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, + NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_PERIODIC, .interval = 301, .specifiers = {specifierP900, specifier850}, .maxSearchTime = 60, @@ -1494,7 +1497,7 @@ TEST_P(RadioNetworkTest, getDataRegistrationState) { } // 32 bit system might return invalid mcc and mnc string "\xff\xff..." - if (checkMccMnc && mcc.size() < 4 && mnc.size() < 4) { + if (checkMccMnc && mcc.size() == 3 && (mnc.size() == 2 || mnc.size() == 3)) { int mcc_int = stoi(mcc); int mnc_int = stoi(mnc); EXPECT_TRUE(mcc_int >= 0 && mcc_int <= 999);