Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e034df06 authored by Keun Soo Yim's avatar Keun Soo Yim Committed by Etan Cohen
Browse files

Accept a command line arg (nan_on) in wifi vts

Test: make vts -j30 BUILD_GOOGLE_VTS=true TARGET_PRODUCT=aosp_arm64 &&
vts-tradefed run commandAndExit vts --skip-all-system-status-check
--primary-abi-only --skip-preconditions --module VtsHalWifiV1_0Host -l
INFO

Test: VtsHalWifiV1_0TargetTest
Test: VtsHalWifiV1_0TargetTest -N
Test: VtsHalWifiV1_0TargetTest --nan_on
Test: VtsHalWifiV1_0TargetTest -f (fails)
Test: VtsHalWifiV1_0TargetTest --gtest_filter=foo
Test: VtsHalWifiV1_0TargetTest --gtest_filter=foo -N
Test: VtsHalWifiV1_0TargetTest -N --gtest_filter=foo

Bug: 63131342

Change-Id: I359ac7238496e64c7ace1e14e797d4fcfc8cc0e4
parent 92cc6209
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -21,9 +21,13 @@
#include "wifi_hidl_test_utils.h"

int main(int argc, char** argv) {
    ::testing::AddGlobalTestEnvironment(new WifiHidlEnvironment);
    WifiHidlEnvironment* gEnv = new WifiHidlEnvironment();
    ::testing::AddGlobalTestEnvironment(gEnv);
    ::testing::InitGoogleTest(&argc, argv);
    int status = RUN_ALL_TESTS();
    int status = gEnv->initFromOptions(argc, argv);
    if (status == 0) {
        status = RUN_ALL_TESTS();
        LOG(INFO) << "Test result = " << status;
    }
    return status;
}
+45 −7
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#include <android/hardware/wifi/1.0/IWifiRttController.h>
#include <android/hardware/wifi/1.0/IWifiStaIface.h>

#include <getopt.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
@@ -46,10 +48,46 @@ bool configureChipToSupportIfaceType(
void stopWifi();

class WifiHidlEnvironment : public ::testing::Environment {
 public:
   protected:
    virtual void SetUp() override {
        stopWifi();
        sleep(5);
    }
  virtual void TearDown() override {}

   public:
    // Whether NaN feature is supported on the device.
    bool isNanOn = false;

    void usage(char* me, char* arg) {
        fprintf(stderr,
                "unrecognized option: %s\n\n"
                "usage: %s <gtest options> <test options>\n\n"
                "test options are:\n\n"
                "-N, --nan_on: Whether NAN feature is supported\n",
                arg, me);
    }

    int initFromOptions(int argc, char** argv) {
        static struct option options[] = {{"nan_on", no_argument, 0, 'N'},
                                          {0, 0, 0, 0}};

        int c;
        while ((c = getopt_long(argc, argv, "N", options, NULL)) >= 0) {
            switch (c) {
                case 'N':
                    isNanOn = true;
                    break;
                default:
                    usage(argv[0], argv[optind]);
                    return 2;
            }
        }

        if (optind < argc) {
            usage(argv[0], argv[optind]);
            return 2;
        }

        return 0;
    }
};