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

Commit 64f9d98e authored by Keun Soo Yim's avatar Keun Soo Yim Committed by android-build-merger
Browse files

Accept a command line arg (nan_on) in wifi vts

am: e034df06

Change-Id: Ic0acbec19aa0d9fd50dc532e0076a91f58638884
parents 0ac1ac06 e034df06
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;
    }
};