mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "Convert wifi hal test to use VtsHalHidlTargetTestEnvBase" am: 3690d19e68
am: 5000aa1605
Change-Id: I6ee6f9a155d85bb92236a926254e959db255ee22
This commit is contained in:
@@ -20,7 +20,8 @@ cc_library_static {
|
||||
srcs: [
|
||||
"wifi_hidl_call_util_selftest.cpp",
|
||||
"wifi_hidl_test.cpp",
|
||||
"wifi_hidl_test_utils.cpp"],
|
||||
"wifi_hidl_test_utils.cpp",
|
||||
],
|
||||
export_include_dirs: [
|
||||
"."
|
||||
],
|
||||
|
||||
@@ -16,16 +16,31 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
|
||||
#include "wifi_hidl_test_utils.h"
|
||||
|
||||
WifiHidlEnvironment* gEnv;
|
||||
class WifiVtsHidlEnvironment_1_0 : public WifiHidlEnvironment {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static WifiVtsHidlEnvironment_1_0* Instance() {
|
||||
static WifiVtsHidlEnvironment_1_0* instance =
|
||||
new WifiVtsHidlEnvironment_1_0;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override {
|
||||
registerTestService<android::hardware::wifi::V1_0::IWifi>();
|
||||
}
|
||||
|
||||
private:
|
||||
WifiVtsHidlEnvironment_1_0() {}
|
||||
};
|
||||
|
||||
WifiHidlEnvironment* gEnv = WifiVtsHidlEnvironment_1_0::Instance();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
gEnv = new WifiHidlEnvironment();
|
||||
::testing::AddGlobalTestEnvironment(gEnv);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
gEnv->init(&argc, argv);
|
||||
int status = gEnv->initFromOptions(argc, argv);
|
||||
if (status == 0) {
|
||||
status = RUN_ALL_TESTS();
|
||||
|
||||
@@ -35,6 +35,8 @@ using ::android::sp;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
||||
extern WifiHidlEnvironment* gEnv;
|
||||
|
||||
namespace {
|
||||
constexpr uint32_t kHalStartRetryMaxCount = 5;
|
||||
constexpr uint32_t kHalStartRetryIntervalInMs = 2;
|
||||
@@ -86,7 +88,8 @@ bool configureChipToSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
|
||||
} // namespace
|
||||
|
||||
sp<IWifi> getWifi() {
|
||||
sp<IWifi> wifi = ::testing::VtsHalHidlTargetTestBase::getService<IWifi>();
|
||||
sp<IWifi> wifi = ::testing::VtsHalHidlTargetTestBase::getService<IWifi>(
|
||||
gEnv->getServiceName<IWifi>());
|
||||
return wifi;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
// Helper functions to obtain references to the various HIDL interface objects.
|
||||
// Note: We only have a single instance of each of these objects currently.
|
||||
// These helper functions should be modified to return vectors if we support
|
||||
@@ -47,9 +48,9 @@ bool configureChipToSupportIfaceType(
|
||||
// Used to trigger IWifi.stop() at the end of every test.
|
||||
void stopWifi();
|
||||
|
||||
class WifiHidlEnvironment : public ::testing::Environment {
|
||||
class WifiHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
protected:
|
||||
virtual void SetUp() override {
|
||||
virtual void HidlSetUp() override {
|
||||
stopWifi();
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
@@ -15,17 +15,32 @@
|
||||
*/
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android/hardware/wifi/1.1/IWifi.h>
|
||||
|
||||
#include "wifi_hidl_test_utils.h"
|
||||
|
||||
WifiHidlEnvironment* gEnv;
|
||||
class WifiHidlEnvironment_1_1 : public WifiHidlEnvironment {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static WifiHidlEnvironment_1_1* Instance() {
|
||||
static WifiHidlEnvironment_1_1* instance = new WifiHidlEnvironment_1_1;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override {
|
||||
registerTestService<android::hardware::wifi::V1_1::IWifi>();
|
||||
}
|
||||
|
||||
private:
|
||||
WifiHidlEnvironment_1_1() {}
|
||||
};
|
||||
|
||||
WifiHidlEnvironment* gEnv = WifiHidlEnvironment_1_1::Instance();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
gEnv = new WifiHidlEnvironment();
|
||||
::testing::AddGlobalTestEnvironment(gEnv);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
gEnv->init(&argc, argv);
|
||||
int status = gEnv->initFromOptions(argc, argv);
|
||||
if (status == 0) {
|
||||
int status = RUN_ALL_TESTS();
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <VtsHalHidlTargetCallbackBase.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -68,12 +69,33 @@ class OffloadCallbackArgs {
|
||||
OffloadStatus error_code_;
|
||||
};
|
||||
|
||||
// Test environment for Weaver HIDL HAL.
|
||||
class WifiOffloadHidlEnvironment
|
||||
: public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static WifiOffloadHidlEnvironment* Instance() {
|
||||
static WifiOffloadHidlEnvironment* instance =
|
||||
new WifiOffloadHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override {
|
||||
registerTestService<IOffload>();
|
||||
}
|
||||
|
||||
private:
|
||||
WifiOffloadHidlEnvironment() {}
|
||||
};
|
||||
|
||||
// The main test class for WifiOffload HIDL HAL.
|
||||
class WifiOffloadHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
wifi_offload_ =
|
||||
::testing::VtsHalHidlTargetTestBase::getService<IOffload>();
|
||||
::testing::VtsHalHidlTargetTestBase::getService<IOffload>(
|
||||
WifiOffloadHidlEnvironment::Instance()
|
||||
->getServiceName<IOffload>());
|
||||
ASSERT_NE(wifi_offload_, nullptr);
|
||||
|
||||
wifi_offload_cb_ = new OffloadCallback();
|
||||
@@ -209,17 +231,10 @@ TEST_F(WifiOffloadHidlTest, getError) {
|
||||
ASSERT_EQ(true, res.no_timeout);
|
||||
}
|
||||
|
||||
// A class for test environment setup
|
||||
class WifiOffloadHalHidlEnvironment : public ::testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {}
|
||||
virtual void TearDown() {}
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(new WifiOffloadHalHidlEnvironment);
|
||||
::testing::AddGlobalTestEnvironment(WifiOffloadHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
WifiOffloadHidlEnvironment::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
|
||||
|
||||
@@ -16,22 +16,34 @@
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
|
||||
#include "supplicant_hidl_test_utils.h"
|
||||
#include "wifi_hidl_test_utils.h"
|
||||
|
||||
class SupplicantHidlEnvironment : public ::testing::Environment {
|
||||
class WifiSupplicantHidlEnvironment_1_0 : public WifiSupplicantHidlEnvironment {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
stopSupplicant();
|
||||
// get the test environment singleton
|
||||
static WifiSupplicantHidlEnvironment_1_0* Instance() {
|
||||
static WifiSupplicantHidlEnvironment_1_0* instance =
|
||||
new WifiSupplicantHidlEnvironment_1_0;
|
||||
return instance;
|
||||
}
|
||||
virtual void TearDown() override {
|
||||
virtual void registerTestServices() override {
|
||||
registerTestService<::android::hardware::wifi::V1_0::IWifi>();
|
||||
registerTestService<
|
||||
::android::hardware::wifi::supplicant::V1_0::ISupplicant>();
|
||||
}
|
||||
|
||||
private:
|
||||
WifiSupplicantHidlEnvironment_1_0() {}
|
||||
};
|
||||
|
||||
WifiSupplicantHidlEnvironment* gEnv =
|
||||
WifiSupplicantHidlEnvironment_1_0::Instance();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(new SupplicantHidlEnvironment);
|
||||
::testing::AddGlobalTestEnvironment(gEnv);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
gEnv->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <android/hidl/manager/1.0/IServiceManager.h>
|
||||
#include <android/hidl/manager/1.0/IServiceNotification.h>
|
||||
@@ -49,8 +49,9 @@ using ::android::hidl::manager::V1_0::IServiceNotification;
|
||||
using ::android::wifi_system::InterfaceTool;
|
||||
using ::android::wifi_system::SupplicantManager;
|
||||
|
||||
extern WifiSupplicantHidlEnvironment* gEnv;
|
||||
|
||||
namespace {
|
||||
const char kSupplicantServiceName[] = "default";
|
||||
|
||||
// Helper function to initialize the driver and firmware to STA mode
|
||||
// using the vendor HAL HIDL interface.
|
||||
@@ -153,19 +154,20 @@ void startSupplicantAndWaitForHidlService() {
|
||||
|
||||
android::sp<ServiceNotificationListener> notification_listener =
|
||||
new ServiceNotificationListener();
|
||||
string service_name = gEnv->getServiceName<ISupplicant>();
|
||||
ASSERT_TRUE(notification_listener->registerForHidlServiceNotifications(
|
||||
kSupplicantServiceName));
|
||||
service_name));
|
||||
|
||||
SupplicantManager supplicant_manager;
|
||||
ASSERT_TRUE(supplicant_manager.StartSupplicant());
|
||||
ASSERT_TRUE(supplicant_manager.IsSupplicantRunning());
|
||||
|
||||
ASSERT_TRUE(
|
||||
notification_listener->waitForHidlService(200, kSupplicantServiceName));
|
||||
ASSERT_TRUE(notification_listener->waitForHidlService(200, service_name));
|
||||
}
|
||||
|
||||
sp<ISupplicant> getSupplicant() {
|
||||
return ::testing::VtsHalHidlTargetTestBase::getService<ISupplicant>();
|
||||
return ::testing::VtsHalHidlTargetTestBase::getService<ISupplicant>(
|
||||
gEnv->getServiceName<ISupplicant>());
|
||||
}
|
||||
|
||||
sp<ISupplicantStaIface> getSupplicantStaIface() {
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h>
|
||||
#include <android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
// Used to stop the android wifi framework before every test.
|
||||
void stopWifiFramework();
|
||||
void startWifiFramework();
|
||||
@@ -45,4 +47,13 @@ getSupplicantP2pIface();
|
||||
|
||||
bool turnOnExcessiveLogging();
|
||||
|
||||
class WifiSupplicantHidlEnvironment
|
||||
: public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
virtual void HidlSetUp() override { stopSupplicant(); }
|
||||
virtual void HidlTearDown() override {
|
||||
startSupplicantAndWaitForHidlService();
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SUPPLICANT_HIDL_TEST_UTILS_H */
|
||||
|
||||
Reference in New Issue
Block a user