Create Wifi host-side test template

to customize the target-side test binary's
command-line arg (based on the features available on device).

Test: vts-tradefed run commandAndExit vts --skip-all-system-status-check
--primary-abi-only --skip-preconditions --module VtsHalWifiV1_0Host -l
INFO
Bug: 63131342

Change-Id: Ic89310db3eca32cb5b3e93f8472aba33fe176d4a
diff --git a/wifi/V1_0/__init__.py b/wifi/V1_0/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/V1_0/__init__.py
diff --git a/wifi/V1_0/host/Android.mk b/wifi/V1_0/host/Android.mk
new file mode 100644
index 0000000..aafaebb
--- /dev/null
+++ b/wifi/V1_0/host/Android.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VtsHalWifiV1_0Host
+VTS_CONFIG_SRC_DIR := testcases/hal/wifi/V1_0/host
+include test/vts/tools/build/Android.host_config.mk
diff --git a/wifi/V1_0/host/AndroidTest.xml b/wifi/V1_0/host/AndroidTest.xml
new file mode 100644
index 0000000..87720e4
--- /dev/null
+++ b/wifi/V1_0/host/AndroidTest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<configuration description="Config for VTS VtsHalWifiV1_0Host test cases">
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+        <option name="abort-on-push-failure" value="true"/>
+        <option name="push-group" value="HalHidlHostTest.push"/>
+        <option name="cleanup" value="true"/>
+    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer"/>
+    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+        <option name="test-module-name" value="VtsHalWifiV1_0Host"/>
+        <option name="test-case-path" value="vts/testcases/hal/wifi/V1_0/host/VtsHalWifiV1_0HostTest"/>
+        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsHalWifiV1_0TargetTest/VtsHalWifiV1_0TargetTest" />
+        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsHalWifiV1_0TargetTest/VtsHalWifiV1_0TargetTest" />
+        <option name="binary-test-disable-framework" value="true"/>
+        <option name="binary-test-stop-native-servers" value="true"/>
+        <option name="precondition-lshal" value="android.hardware.wifi@1.0"/>
+        <option name="test-timeout" value="10m"/>
+    </test>
+</configuration>
diff --git a/wifi/V1_0/host/VtsHalWifiV1_0HostTest.py b/wifi/V1_0/host/VtsHalWifiV1_0HostTest.py
new file mode 100644
index 0000000..c2c313d
--- /dev/null
+++ b/wifi/V1_0/host/VtsHalWifiV1_0HostTest.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import logging
+
+from vts.runners.host import const
+from vts.runners.host import test_runner
+from vts.testcases.template.hal_hidl_gtest import hal_hidl_gtest
+from vts.testcases.hal.wifi.V1_0.host import VtsHalWifiV1_0TestCase as wifi_test_case
+
+
+class VtsHalWifiV1_0Host(hal_hidl_gtest.HidlHalGTest):
+    """Host test class to run the WiFi V1.0 HAL's VTS tests."""
+
+    WIFI_AWARE_FEATURE_NAME = "android.hardware.wifi.aware"
+
+    def CreateTestCases(self):
+        """Get all registered test components and create test case objects."""
+        pm_list = self.shell.Execute("pm list features")
+        self._nan_on = self.WIFI_AWARE_FEATURE_NAME in pm_list[const.STDOUT][0]
+        logging.info("Wifi NaN Feature Supported: %s", self._nan_on)
+        super(VtsHalWifiV1_0Host, self).CreateTestCases()
+
+    # @Override
+    def CreateTestCase(self, path, tag=''):
+        """Create a list of VtsHalWifiV1_0TestCase objects.
+
+        Args:
+            path: string, absolute path of a gtest binary on device
+            tag: string, a tag that will be appended to the end of test name
+
+        Returns:
+            A list of VtsHalWifiV1_0TestCase objects
+        """
+        gtest_cases = super(VtsHalWifiV1_0Host, self).CreateTestCase(path, tag)
+        test_cases = []
+        for gtest_case in gtest_cases:
+            test_case = wifi_test_case.VtsHalWifiV1_0TestCase(
+                self._nan_on, gtest_case.full_name, gtest_case.test_name, path)
+            test_cases.append(test_case)
+        logging.info("num of test_testcases: %s", len(test_cases))
+        return test_cases
+
+
+if __name__ == "__main__":
+    test_runner.main()
diff --git a/wifi/V1_0/host/VtsHalWifiV1_0TestCase.py b/wifi/V1_0/host/VtsHalWifiV1_0TestCase.py
new file mode 100644
index 0000000..bc8af65
--- /dev/null
+++ b/wifi/V1_0/host/VtsHalWifiV1_0TestCase.py
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from vts.testcases.template.gtest_binary_test import gtest_test_case
+
+class VtsHalWifiV1_0TestCase(gtest_test_case.GtestTestCase):
+    """A class to represent a WiFi HAL VTS test case.
+
+    Attributes:
+        _nan: boolean, whether WiFi NAN feature is supported on the device.
+    """
+
+    def __init__(self, nan, *args, **kwargs):
+        super(VtsHalWifiV1_0TestCase, self).__init__(*args, **kwargs)
+        self._nan = nan
+
+    # @Override
+    def GetRunCommand(self):
+        """Get the command to run the test. """
+        orig_cmds = super(VtsHalWifiV1_0TestCase,
+                          self).GetRunCommand(test_name=self.test_suite),
+        new_cmd = [('{cmd}{nan_on}').format(
+            cmd=orig_cmds[0][0], nan_on=" --nan_on" if self._nan else ""),
+            orig_cmds[0][1]]
+        return new_cmd
diff --git a/wifi/V1_0/host/__init__.py b/wifi/V1_0/host/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/V1_0/host/__init__.py
diff --git a/wifi/__init__.py b/wifi/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/__init__.py