Merge "vts(wifi): Separate P2P specific tests"
diff --git a/wifi/OWNERS b/wifi/OWNERS
new file mode 100644
index 0000000..3d11524
--- /dev/null
+++ b/wifi/OWNERS
@@ -0,0 +1,2 @@
+etancohen@google.com
+rpius@google.com
diff --git a/wifi/supplicant/V1_0/__init__.py b/wifi/supplicant/V1_0/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/supplicant/V1_0/__init__.py
diff --git a/wifi/supplicant/V1_0/target/Android.mk b/wifi/supplicant/V1_0/host/Android.mk
similarity index 86%
rename from wifi/supplicant/V1_0/target/Android.mk
rename to wifi/supplicant/V1_0/host/Android.mk
index 31d2785..e7a2411 100644
--- a/wifi/supplicant/V1_0/target/Android.mk
+++ b/wifi/supplicant/V1_0/host/Android.mk
@@ -18,5 +18,6 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := VtsHalWifiSupplicantV1_0Target
+LOCAL_MODULE := VtsHalWifiSupplicantV1_0Host
+VTS_CONFIG_SRC_DIR := testcases/hal/wifi/supplicant/V1_0/host
 include test/vts/tools/build/Android.host_config.mk
diff --git a/wifi/supplicant/V1_0/host/AndroidTest.xml b/wifi/supplicant/V1_0/host/AndroidTest.xml
new file mode 100644
index 0000000..3f1ddcf
--- /dev/null
+++ b/wifi/supplicant/V1_0/host/AndroidTest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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 VtsHalWifiSupplicantV1_0Host test cases">
+    <option name="config-descriptor:metadata" key="plan" value="vts-hal" />
+    <option name="config-descriptor:metadata" key="plan" value="vts-hal-host" />
+    <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"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/Supplicant.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/Supplicant.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantCallback.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantCallback.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantIface.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantIface.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantStaIface.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantStaIface.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantP2pIface.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantP2pIface.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantStaIfaceCallback.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantStaIfaceCallback.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantP2pIfaceCallback.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantP2pIfaceCallback.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantNetwork.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantNetwork.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantStaNetwork.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantStaNetwork.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantP2pNetwork.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantP2pNetwork.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantStaNetworkCallback.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantStaNetworkCallback.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/SupplicantP2pNetworkCallback.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/SupplicantP2pNetworkCallback.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.0/vts/types.vts->/data/local/tmp/spec/android/hardware/wifi/supplicant/1.0/types.vts"/>
+        <option name="push" value="DATA/lib/android.hardware.wifi.supplicant@1.0-vts.driver.so->/data/local/tmp/32/android.hardware.wifi.supplicant@1.0-vts.driver.so"/>
+        <option name="push" value="DATA/lib64/android.hardware.wifi.supplicant@1.0-vts.driver.so->/data/local/tmp/64/android.hardware.wifi.supplicant@1.0-vts.driver.so"/>
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+        <option name="test-module-name" value="VtsHalWifiSupplicantV1_0Host"/>
+        <option name="test-case-path" value="vts/testcases/hal/wifi/supplicant/V1_0/host/VtsHalWifiSupplicantV1_0HostTest"/>
+        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsHalWifiSupplicantV1_0TargetTest/VtsHalWifiSupplicantV1_0TargetTest" />
+        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsHalWifiSupplicantV1_0TargetTest/VtsHalWifiSupplicantV1_0TargetTest" />
+        <option name="binary-test-stop-native-servers" value="true"/>
+        <option name="test-timeout" value="10m"/>
+    </test>
+</configuration>
diff --git a/wifi/supplicant/V1_0/host/VtsHalWifiSupplicantV1_0HostTest.py b/wifi/supplicant/V1_0/host/VtsHalWifiSupplicantV1_0HostTest.py
new file mode 100644
index 0000000..18e3071
--- /dev/null
+++ b/wifi/supplicant/V1_0/host/VtsHalWifiSupplicantV1_0HostTest.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018 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
+
+
+class VtsHalWifiSupplicantV1_0Host(hal_hidl_gtest.HidlHalGTest):
+    """Host test class to run the WiFi Supplicant V1.0 HAL's VTS tests."""
+
+    WIFI_DIRECT_FEATURE_NAME = "android.hardware.wifi.direct"
+
+    def CreateTestCases(self):
+        """Get all registered test components and create test case objects."""
+        pm_list = self.shell.Execute("pm list features")
+        self._p2p_on = self.WIFI_DIRECT_FEATURE_NAME in pm_list[const.STDOUT][0]
+        logging.info("Wifi P2P Feature Supported: %s", self._p2p_on)
+        super(VtsHalWifiSupplicantV1_0Host, self).CreateTestCases()
+
+    # @Override
+    def CreateTestCase(self, path, tag=''):
+        """Create a list of VtsHalWifiSupplicantV1_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 VtsHalWifiSupplicantV1_0TestCase objects
+        """
+        gtest_cases = super(VtsHalWifiSupplicantV1_0Host, self).CreateTestCase(path, tag)
+        for gtest_case in gtest_cases:
+            if not self._p2p_on:
+                gtest_case.args += " --p2p_off"
+        return gtest_cases
+
+
+if __name__ == "__main__":
+    test_runner.main()
diff --git a/wifi/supplicant/V1_0/host/__init__.py b/wifi/supplicant/V1_0/host/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/supplicant/V1_0/host/__init__.py
diff --git a/wifi/supplicant/V1_0/target/AndroidTest.xml b/wifi/supplicant/V1_0/target/AndroidTest.xml
deleted file mode 100644
index df7ad64..0000000
--- a/wifi/supplicant/V1_0/target/AndroidTest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?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 VtsHalWifiSupplicantV1_0Target test cases">
-    <option name="config-descriptor:metadata" key="plan" value="vts-hal" />
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
-        <option name="abort-on-push-failure" value="false"/>
-        <option name="push-group" value="HalHidlTargetTest.push"/>
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
-        <option name="test-module-name" value="VtsHalWifiSupplicantV1_0Target"/>
-        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsHalWifiSupplicantV1_0TargetTest/VtsHalWifiSupplicantV1_0TargetTest"/>
-        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsHalWifiSupplicantV1_0TargetTest/VtsHalWifiSupplicantV1_0TargetTest"/>
-        <option name="binary-test-type" value="hal_hidl_gtest"/>
-        <option name="binary-test-disable-framework" value="true"/>
-        <option name="test-timeout" value="30m"/>
-    </test>
-</configuration>
diff --git a/wifi/supplicant/V1_0/target/Android.mk b/wifi/supplicant/V1_0/target/p2p/Android.mk
similarity index 85%
copy from wifi/supplicant/V1_0/target/Android.mk
copy to wifi/supplicant/V1_0/target/p2p/Android.mk
index 31d2785..b0f5889 100644
--- a/wifi/supplicant/V1_0/target/Android.mk
+++ b/wifi/supplicant/V1_0/target/p2p/Android.mk
@@ -18,5 +18,6 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := VtsHalWifiSupplicantV1_0Target
+LOCAL_MODULE := VtsHalWifiSupplicantP2pV1_0Target
+VTS_CONFIG_SRC_DIR := testcases/hal/wifi/supplicant/V1_0/target/p2p
 include test/vts/tools/build/Android.host_config.mk
diff --git a/wifi/supplicant/V1_1/target/AndroidTest.xml b/wifi/supplicant/V1_0/target/p2p/AndroidTest.xml
similarity index 76%
rename from wifi/supplicant/V1_1/target/AndroidTest.xml
rename to wifi/supplicant/V1_0/target/p2p/AndroidTest.xml
index 8dac0e9..0ab69ed 100644
--- a/wifi/supplicant/V1_1/target/AndroidTest.xml
+++ b/wifi/supplicant/V1_0/target/p2p/AndroidTest.xml
@@ -13,19 +13,20 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<configuration description="Config for VTS VtsHalWifiSupplicantV1_1Target test cases">
+<configuration description="Config for VTS VtsHalWifiSupplicantP2pV1_0Target test cases">
     <option name="config-descriptor:metadata" key="plan" value="vts-hal" />
     <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
         <option name="abort-on-push-failure" value="false"/>
         <option name="push-group" value="HalHidlTargetTest.push"/>
     </target_preparer>
-    <multi_target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
     <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
-        <option name="test-module-name" value="VtsHalWifiSupplicantV1_1Target"/>
-        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsHalWifiSupplicantV1_1TargetTest/VtsHalWifiSupplicantV1_1TargetTest"/>
-        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsHalWifiSupplicantV1_1TargetTest/VtsHalWifiSupplicantV1_1TargetTest"/>
+        <option name="test-module-name" value="VtsHalWifiSupplicantP2pV1_0Target"/>
+        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsHalWifiSupplicantP2pV1_0TargetTest/VtsHalWifiSupplicantP2pV1_0TargetTest"/>
+        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsHalWifiSupplicantP2pV1_0TargetTest/VtsHalWifiSupplicantP2pV1_0TargetTest"/>
         <option name="binary-test-type" value="hal_hidl_gtest"/>
         <option name="binary-test-disable-framework" value="true"/>
+        <option name="binary-test-stop-native-servers" value="true"/>
+        <option name="precondition-feature" value="android.hardware.wifi.direct" />
         <option name="test-timeout" value="30m"/>
     </test>
 </configuration>
diff --git a/wifi/supplicant/V1_1/__init__.py b/wifi/supplicant/V1_1/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/supplicant/V1_1/__init__.py
diff --git a/wifi/supplicant/V1_0/target/Android.mk b/wifi/supplicant/V1_1/host/Android.mk
similarity index 86%
copy from wifi/supplicant/V1_0/target/Android.mk
copy to wifi/supplicant/V1_1/host/Android.mk
index 31d2785..a2a17b9 100644
--- a/wifi/supplicant/V1_0/target/Android.mk
+++ b/wifi/supplicant/V1_1/host/Android.mk
@@ -18,5 +18,6 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := VtsHalWifiSupplicantV1_0Target
+LOCAL_MODULE := VtsHalWifiSupplicantV1_1Host
+VTS_CONFIG_SRC_DIR := testcases/hal/wifi/supplicant/V1_1/host
 include test/vts/tools/build/Android.host_config.mk
diff --git a/wifi/supplicant/V1_1/host/AndroidTest.xml b/wifi/supplicant/V1_1/host/AndroidTest.xml
new file mode 100644
index 0000000..a65b69c
--- /dev/null
+++ b/wifi/supplicant/V1_1/host/AndroidTest.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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 VtsHalWifiSupplicantV1_1Host test cases">
+    <option name="config-descriptor:metadata" key="plan" value="vts-hal" />
+    <option name="config-descriptor:metadata" key="plan" value="vts-hal-host" />
+    <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"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.1/vts/Supplicant.vts->/data/local/tmp/spec/android/hardware.wifi.supplicant/1.1/Supplicant.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.1/vts/SupplicantStaIface.vts->/data/local/tmp/spec/android/hardware.wifi.supplicant/1.1/SupplicantStaIface.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.1/vts/SupplicantStaIfaceCallback.vts->/data/local/tmp/spec/android/hardware.wifi.supplicant/1.1/SupplicantStaIfaceCallback.vts"/>
+        <option name="push" value="spec/hardware/interfaces/wifi/supplicant/1.1/vts/SupplicantStaNetwork.vts->/data/local/tmp/spec/android/hardware.wifi.supplicant/1.1/SupplicantStaNetwork.vts"/>
+        <option name="push" value="DATA/lib/android.hardware.wifi.supplicant@1.1-vts.driver.so->/data/local/tmp/32/android.hardware.wifi.supplicant@1.1-vts.driver.so"/>
+        <option name="push" value="DATA/lib64/android.hardware.wifi.supplicant@1.1-vts.driver.so->/data/local/tmp/64/android.hardware.wifi.supplicant@1.1-vts.driver.so"/>
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+        <option name="test-module-name" value="VtsHalWifiSupplicantV1_1Host"/>
+        <option name="test-case-path" value="vts/testcases/hal/wifi/supplicant/V1_1/host/VtsHalWifiSupplicantV1_1HostTest"/>
+        <option name="binary-test-source" value="_32bit::DATA/nativetest/VtsHalWifiSupplicantV1_1TargetTest/VtsHalWifiSupplicantV1_1TargetTest" />
+        <option name="binary-test-source" value="_64bit::DATA/nativetest64/VtsHalWifiSupplicantV1_1TargetTest/VtsHalWifiSupplicantV1_1TargetTest" />
+        <option name="binary-test-stop-native-servers" value="true"/>
+        <option name="test-timeout" value="10m"/>
+    </test>
+</configuration>
diff --git a/wifi/supplicant/V1_1/host/VtsHalWifiSupplicantV1_1HostTest.py b/wifi/supplicant/V1_1/host/VtsHalWifiSupplicantV1_1HostTest.py
new file mode 100644
index 0000000..8f1fa55
--- /dev/null
+++ b/wifi/supplicant/V1_1/host/VtsHalWifiSupplicantV1_1HostTest.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018 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
+
+
+class VtsHalWifiSupplicantV1_1Host(hal_hidl_gtest.HidlHalGTest):
+    """Host test class to run the WiFi Supplicant V1.0 HAL's VTS tests."""
+
+    WIFI_DIRECT_FEATURE_NAME = "android.hardware.wifi.direct"
+
+    def CreateTestCases(self):
+        """Get all registered test components and create test case objects."""
+        pm_list = self.shell.Execute("pm list features")
+        self._p2p_on = self.WIFI_DIRECT_FEATURE_NAME in pm_list[const.STDOUT][0]
+        logging.info("Wifi P2P Feature Supported: %s", self._p2p_on)
+        super(VtsHalWifiSupplicantV1_1Host, self).CreateTestCases()
+
+    # @Override
+    def CreateTestCase(self, path, tag=''):
+        """Create a list of VtsHalWifiSupplicantV1_1TestCase 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 VtsHalWifiSupplicantV1_1TestCase objects
+        """
+        gtest_cases = super(VtsHalWifiSupplicantV1_1Host, self).CreateTestCase(path, tag)
+        for gtest_case in gtest_cases:
+            if not self._p2p_on:
+                gtest_case.args += " --p2p_off"
+        return gtest_cases
+
+
+if __name__ == "__main__":
+    test_runner.main()
diff --git a/wifi/supplicant/V1_1/host/__init__.py b/wifi/supplicant/V1_1/host/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/supplicant/V1_1/host/__init__.py
diff --git a/wifi/supplicant/V1_1/target/Android.mk b/wifi/supplicant/V1_1/target/Android.mk
deleted file mode 100644
index a3acd1f..0000000
--- a/wifi/supplicant/V1_1/target/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# 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 := VtsHalWifiSupplicantV1_1Target
-include test/vts/tools/build/Android.host_config.mk
diff --git a/wifi/supplicant/__init__.py b/wifi/supplicant/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wifi/supplicant/__init__.py