Compatibility build rule rather than library
bug:21762834
Change-Id: I81a07d545cd7d34ede9127cacdeab975d6585c4e
diff --git a/build/compatibility_test_suite.mk b/build/compatibility_test_suite.mk
new file mode 100644
index 0000000..6430efa
--- /dev/null
+++ b/build/compatibility_test_suite.mk
@@ -0,0 +1,51 @@
+# Copyright (C) 2015 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.
+
+#
+# Builds a compatibility test suite.
+#
+
+# Generate the SuiteInfo.java
+suite_info_java := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),true,COMMON)/com/android/compatibility/SuiteInfo.java
+$(suite_info_java): PRIVATE_SUITE_BUILD_NUMBER := $(LOCAL_SUITE_BUILD_NUMBER)
+$(suite_info_java): PRIVATE_SUITE_NAME := $(LOCAL_SUITE_NAME)
+$(suite_info_java): PRIVATE_SUITE_FULLNAME := $(LOCAL_SUITE_FULLNAME)
+$(suite_info_java): PRIVATE_SUITE_VERSION := $(LOCAL_SUITE_VERSION)
+$(suite_info_java): cts/build/compatibility_test_suite.mk $(LOCAL_MODULE_MAKEFILE)
+ @echo Generating: $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) echo "/* This file is auto generated by Android.mk. Do not modify. */" > $@
+ $(hide) echo "package com.android.compatibility;" >> $@
+ $(hide) echo "public class SuiteInfo {" >> $@
+ $(hide) echo " public static final String BUILD_NUMBER = \"$(PRIVATE_SUITE_BUILD_NUMBER)\";" >> $@
+ $(hide) echo " public static final String NAME = \"$(PRIVATE_SUITE_NAME)\";" >> $@
+ $(hide) echo " public static final String FULLNAME = \"$(PRIVATE_SUITE_FULLNAME)\";" >> $@
+ $(hide) echo " public static final String VERSION = \"$(PRIVATE_SUITE_VERSION)\";" >> $@
+ $(hide) echo "}" >> $@
+
+# Reset variables
+LOCAL_SUITE_BUILD_NUMBER :=
+LOCAL_SUITE_NAME :=
+LOCAL_SUITE_FULLNAME :=
+LOCAL_SUITE_VERSION :=
+
+# Include the SuiteInfo.java
+LOCAL_GENERATED_SOURCES := $(suite_info_java)
+
+# Add the base libraries
+LOCAL_JAVA_LIBRARIES += tradefed-prebuilt hosttestlib compatibility-host-util
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/build/config.mk b/build/config.mk
index cded802..eae7c00 100644
--- a/build/config.mk
+++ b/build/config.mk
@@ -40,6 +40,7 @@
CTS_MODULE_TEST_CONFIG := AndroidTest.xml
# CTS build rules
+BUILD_COMPATIBILITY_SUITE := cts/build/compatibility_test_suite.mk
BUILD_CTS_EXECUTABLE := cts/build/test_executable.mk
BUILD_CTS_PACKAGE := cts/build/test_package.mk
BUILD_CTS_GTEST_PACKAGE := cts/build/test_gtest_package.mk
diff --git a/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java b/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java
index fb1062a..5b834c7 100644
--- a/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java
+++ b/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java
@@ -54,7 +54,7 @@
public void testJsonFile() throws IOException {
String errorMessage = mActivity.getErrorMessage();
// Check no errors
- assertNull("Expected no errors", errorMessage);
+ assertEquals("Expected no errors", null, errorMessage);
String resultFilePath = mActivity.getResultFilePath();
// Check file path exist
assertNotNull("Expected a non-null resultFilePath", resultFilePath);
diff --git a/common/host-side/tradefed/Android.mk b/common/host-side/tradefed/Android.mk
index 9faabed..3ed225ed 100644
--- a/common/host-side/tradefed/Android.mk
+++ b/common/host-side/tradefed/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2014 The Android Open Source Project
+# Copyright (C) 2015 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.
@@ -12,20 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_RESOURCE_DIRS := res
-
-LOCAL_MODULE := compatibility-tradefed
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib compatibility-host-util
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
+include $(call all-subdir-makefiles)
\ No newline at end of file
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
index 4af16bb..39a5ca6 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelper.java
@@ -15,6 +15,7 @@
*/
package com.android.compatibility.common.tradefed.build;
+import com.android.compatibility.SuiteInfo;
import com.android.tradefed.build.IFolderBuildInfo;
import java.io.File;
@@ -54,22 +55,20 @@
return;
}
mInitialized = true;
- Package pkg = Package.getPackage("com.android.compatibility.tradefed.command");
- String suiteFullName = pkg.getSpecificationTitle();
- String suiteName = pkg.getSpecificationVendor();
- String suiteVersion = pkg.getSpecificationVersion();
- String suiteBuild = pkg.getImplementationVersion();
- mBuildInfo.addBuildAttribute(SUITE_BUILD, suiteBuild);
- mBuildInfo.addBuildAttribute(SUITE_NAME, suiteName);
- mBuildInfo.addBuildAttribute(SUITE_FULL_NAME, suiteFullName);
- mBuildInfo.addBuildAttribute(SUITE_VERSION, suiteVersion);
+ mBuildInfo.addBuildAttribute(SUITE_BUILD, SuiteInfo.BUILD_NUMBER);
+ mBuildInfo.addBuildAttribute(SUITE_NAME, SuiteInfo.NAME);
+ mBuildInfo.addBuildAttribute(SUITE_FULL_NAME, SuiteInfo.FULLNAME);
+ mBuildInfo.addBuildAttribute(SUITE_VERSION, SuiteInfo.VERSION);
mBuildInfo.addBuildAttribute(SUITE_PLAN, suitePlan);
- String mRootDirPath = System.getProperty(String.format("%s_ROOT", suiteName));
+ String mRootDirPath = System.getProperty(String.format("%s_ROOT", SuiteInfo.NAME));
if (mRootDirPath == null || mRootDirPath.trim().equals("")) {
- mRootDirPath = mBuildInfo.getRootDir().getAbsolutePath();
- if (mRootDirPath == null || mRootDirPath.equals("")) {
+ File root = mBuildInfo.getRootDir();
+ if (root != null) {
+ mRootDirPath = root.getAbsolutePath();
+ }
+ if (mRootDirPath == null || mRootDirPath.trim().equals("")) {
throw new IllegalArgumentException(
- String.format("Missing install path property %s_ROOT", suiteName));
+ String.format("Missing install path property %s_ROOT", SuiteInfo.NAME));
}
}
File rootDir = new File(mRootDirPath);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
index 099fdeb..95fc891 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
@@ -15,6 +15,7 @@
*/
package com.android.compatibility.common.tradefed.command;
+import com.android.compatibility.SuiteInfo;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
import com.android.compatibility.common.tradefed.result.IInvocationResultRepo;
@@ -24,6 +25,7 @@
import com.android.compatibility.common.util.TestStatus;
import com.android.tradefed.build.IFolderBuildInfo;
import com.android.tradefed.command.Console;
+import com.android.tradefed.config.ConfigurationException;
import com.android.tradefed.util.ArrayUtil;
import com.android.tradefed.util.FileUtil;
import com.android.tradefed.util.RegexTrie;
@@ -32,7 +34,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,18 +44,17 @@
/**
* An extension of Tradefed's console which adds features specific to compatibility testing.
*/
-public abstract class CompatibilityConsole extends Console {
+public class CompatibilityConsole extends Console {
- private CompatibilityBuildHelper mBuildHelper = null;
+ private CompatibilityBuildHelper mBuildHelper;
/**
* {@inheritDoc}
*/
@Override
public void run() {
- CompatibilityBuildHelper buildHelper = getCompatibilityBuildHelper();
- printLine(String.format("Android %s %s (%s)", buildHelper.getSuiteName(),
- buildHelper.getSuiteVersion(), buildHelper.getSuiteBuild()));
+ printLine(String.format("Android %s %s (%s)", SuiteInfo.FULLNAME, SuiteInfo.VERSION,
+ SuiteInfo.BUILD_NUMBER));
super.run();
}
@@ -67,28 +67,19 @@
trie.put(new Runnable() {
@Override
public void run() {
- CompatibilityBuildHelper buildHelper = getCompatibilityBuildHelper();
- if (buildHelper != null) {
- // TODO(stuartscott)" listPlans(buildHelper);
- }
+ // TODO(stuartscott)" listPlans(buildHelper);
}
}, LIST_PATTERN, "p(?:lans)?");
trie.put(new Runnable() {
@Override
public void run() {
- CompatibilityBuildHelper buildHelper = getCompatibilityBuildHelper();
- if (buildHelper != null) {
- listModules(buildHelper);
- }
+ listModules();
}
}, LIST_PATTERN, "m(?:odules)?");
trie.put(new Runnable() {
@Override
public void run() {
- CompatibilityBuildHelper buildHelper = getCompatibilityBuildHelper();
- if (buildHelper != null) {
- listResults(buildHelper);
- }
+ listResults();
}
}, LIST_PATTERN, "r(?:esults)?");
@@ -110,8 +101,7 @@
*/
@Override
protected String getConsolePrompt() {
- return String.format("%s-tf > ",
- getCompatibilityBuildHelper().getSuiteName().toLowerCase());
+ return String.format("%s-tf > ", SuiteInfo.NAME.toLowerCase());
}
/**
@@ -119,11 +109,10 @@
*/
@Override
protected String getGenericHelpString(List<String> genericHelp) {
- CompatibilityBuildHelper buildHelper = getCompatibilityBuildHelper();
StringBuilder helpBuilder = new StringBuilder();
- helpBuilder.append(buildHelper.getSuiteFullName());
+ helpBuilder.append(SuiteInfo.FULLNAME);
helpBuilder.append("\n\n");
- helpBuilder.append(buildHelper.getSuiteName());
+ helpBuilder.append(SuiteInfo.NAME);
helpBuilder.append(" is the test harness for running the Android Compatibility Suite, ");
helpBuilder.append("built on top of Trade Federation.\n\n");
helpBuilder.append("Available commands and options\n");
@@ -152,7 +141,7 @@
helpBuilder.append("independent chunks, to run on multiple devices in parallel\n");
helpBuilder.append(runPrompt);
helpBuilder.append("--help/--help-all: get help for ");
- helpBuilder.append(buildHelper.getSuiteFullName());
+ helpBuilder.append(SuiteInfo.FULLNAME);
helpBuilder.append("\n");
helpBuilder.append("List:\n");
helpBuilder.append(" l/list d/devices: list connected devices and their state\n");
@@ -170,10 +159,10 @@
return helpBuilder.toString();
}
- private void listModules(CompatibilityBuildHelper buildHelper) {
+ private void listModules() {
File[] files = null;
try {
- files = buildHelper.getTestsDir().listFiles(new ModuleRepo.ConfigFilter());
+ files = getBuildHelper().getTestsDir().listFiles(new ModuleRepo.ConfigFilter());
} catch (FileNotFoundException e) {
printLine(e.getMessage());
e.printStackTrace();
@@ -192,7 +181,7 @@
}
}
- private void listResults(CompatibilityBuildHelper buildHelper) {
+ private void listResults() {
TableFormatter tableFormatter = new TableFormatter();
List<List<String>> table = new ArrayList<>();
table.add(Arrays.asList("Session","Pass", "Fail", "Not Executed", "Start Time", "Test Plan",
@@ -200,7 +189,7 @@
IInvocationResultRepo testResultRepo = null;
List<IInvocationResult> results = null;
try {
- testResultRepo = new InvocationResultRepo(buildHelper.getResultsDir());
+ testResultRepo = new InvocationResultRepo(getBuildHelper().getResultsDir());
results = testResultRepo.getResults();
} catch (FileNotFoundException e) {
printLine(e.getMessage());
@@ -223,20 +212,18 @@
}
}
- public CompatibilityBuildHelper getCompatibilityBuildHelper() {
+ private CompatibilityBuildHelper getBuildHelper() {
if (mBuildHelper == null) {
CompatibilityBuildProvider buildProvider = new CompatibilityBuildProvider();
IFolderBuildInfo buildInfo = (IFolderBuildInfo) buildProvider.getBuild();
- try {
- File file = File.createTempFile("root", "tmp");
- file.deleteOnExit();
- buildInfo.setRootDir(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
mBuildHelper = new CompatibilityBuildHelper(buildInfo);
- mBuildHelper.init(""/* plan */, ""/* dynamic config url */);
+ mBuildHelper.init("" /* suite plan */, "" /* dynamic config url */);
}
return mBuildHelper;
}
+
+ public static void main(String[] args) throws InterruptedException, ConfigurationException {
+ Console console = new CompatibilityConsole();
+ Console.startConsole(console, args);
+ }
}
diff --git a/common/host-side/tradefed/tests/Android.mk b/common/host-side/tradefed/tests/Android.mk
index 959aff5..b07fa1e 100644
--- a/common/host-side/tradefed/tests/Android.mk
+++ b/common/host-side/tradefed/tests/Android.mk
@@ -12,18 +12,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-LOCAL_PATH:= $(call my-dir)
+# Make a mock compatibility suite to test
+LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
+LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
+LOCAL_JAVA_RESOURCE_DIRS := ../res
+
+LOCAL_SUITE_BUILD_NUMBER := 2
+LOCAL_SUITE_NAME := TESTS
+LOCAL_SUITE_FULLNAME := "Compatibility Tests"
+LOCAL_SUITE_VERSION := 1
+
+LOCAL_MODULE := compatibility-mock-tradefed
+
+include $(BUILD_COMPATIBILITY_SUITE)
+
+# Make the tests
+include $(CLEAR_VARS)
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_MODULE := compatibility-tradefed-tests
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt compatibility-tradefed junit compatibility-host-util
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt compatibility-mock-tradefed junit compatibility-host-util
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/host-side/tradefed/tests/MANIFEST.mf b/common/host-side/tradefed/tests/MANIFEST.mf
deleted file mode 100644
index 017dc9f..0000000
--- a/common/host-side/tradefed/tests/MANIFEST.mf
+++ /dev/null
@@ -1,6 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.compatibility.tradefed.command.MockConsole
-Specification-Title: Compatibility Tests
-Specification-Vendor: TESTS
-Specification-Version: 1
-Implementation-Version: 2
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
new file mode 100644
index 0000000..588936a
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+package com.android.compatibility.common.tradefed;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelperTest;
+import com.android.compatibility.common.tradefed.command.CompatibilityConsoleTest;
+import com.android.compatibility.common.tradefed.result.ResultReporterTest;
+import com.android.compatibility.common.tradefed.testtype.CompatibilityTestTest;
+import com.android.compatibility.common.tradefed.testtype.ModuleDefTest;
+import com.android.compatibility.common.tradefed.testtype.ModuleRepoTest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * A test suite for all compatibility tradefed unit tests.
+ * <p/>
+ * All tests listed here should be self-contained, and do not require any external dependencies.
+ */
+public class UnitTests extends TestSuite {
+
+ public UnitTests() {
+ super();
+ addTestSuite(CompatibilityBuildHelperTest.class);
+ addTestSuite(CompatibilityConsoleTest.class);
+ addTestSuite(ResultReporterTest.class);
+ addTestSuite(CompatibilityTestTest.class);
+ addTestSuite(ModuleDefTest.class);
+ addTestSuite(ModuleRepoTest.class);
+ }
+
+ public static Test suite() {
+ return new UnitTests();
+ }
+}
\ No newline at end of file
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java
index 897514e..99847f5 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildHelperTest.java
@@ -16,7 +16,6 @@
package com.android.compatibility.common.tradefed.build;
-import com.android.compatibility.tradefed.command.MockConsole;
import com.android.tradefed.build.IFolderBuildInfo;
import com.android.tradefed.util.FileUtil;
@@ -28,7 +27,7 @@
public class CompatibilityBuildHelperTest extends TestCase {
private static final String ROOT_PROPERTY = "TESTS_ROOT";
- private static final String BUILD_ID = "2";
+ private static final String BUILD_NUMBER = "2";
private static final String SUITE_NAME = "TESTS";
private static final String SUITE_FULL_NAME = "Compatibility Tests";
private static final String SUITE_VERSION = "1";
@@ -38,10 +37,6 @@
private static final String BASE_DIR_NAME = "android-tests";
private static final String TESTCASES = "testcases";
- // Make sure the mock is in the ClassLoader
- @SuppressWarnings("unused")
- private MockConsole mMockConsole;
-
private File mRoot = null;
private File mBase = null;
private File mTests = null;
@@ -50,7 +45,6 @@
@Override
public void setUp() throws Exception {
- mMockConsole = new MockConsole();
mRoot = FileUtil.createTempDir(ROOT_DIR_NAME);
CompatibilityBuildProvider provider = new CompatibilityBuildProvider();
mBuild = (IFolderBuildInfo) provider.getBuild();
@@ -60,7 +54,6 @@
@Override
public void tearDown() throws Exception {
setProperty(null);
- mMockConsole = null;
FileUtil.recursiveDelete(mRoot);
mRoot = null;
mBase = null;
@@ -74,10 +67,10 @@
mTests.mkdirs();
}
- public void testManifestLoad() throws Exception {
+ public void testSuiteInfoLoad() throws Exception {
setProperty(mRoot.getAbsolutePath());
mHelper.init(SUITE_PLAN, DYNAMIC_CONFIG_URL);
- assertEquals("Incorrect suite build id", BUILD_ID, mHelper.getSuiteBuild());
+ assertEquals("Incorrect suite build number", BUILD_NUMBER, mHelper.getSuiteBuild());
assertEquals("Incorrect suite name", SUITE_NAME, mHelper.getSuiteName());
assertEquals("Incorrect suite full name", SUITE_FULL_NAME, mHelper.getSuiteFullName());
assertEquals("Incorrect suite version", SUITE_VERSION, mHelper.getSuiteVersion());
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/command/CompatibilityConsoleTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/command/CompatibilityConsoleTest.java
index af57215..55c1651 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/command/CompatibilityConsoleTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/command/CompatibilityConsoleTest.java
@@ -17,26 +17,19 @@
package com.android.compatibility.common.tradefed.command;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelperTest;
-import com.android.compatibility.tradefed.command.MockConsole;
import junit.framework.TestCase;
public class CompatibilityConsoleTest extends TestCase {
- // Make sure the mock is in the ClassLoader
- @SuppressWarnings("unused")
- private MockConsole mMockConsole;
-
@Override
public void setUp() throws Exception {
CompatibilityBuildHelperTest.setProperty("/tmp/foobar");
- mMockConsole = new MockConsole();
}
@Override
public void tearDown() throws Exception {
CompatibilityBuildHelperTest.setProperty(null);
- mMockConsole = null;
}
public void testHelpExists() throws Exception {
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java
index 0b9bf92..989e255 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java
@@ -23,7 +23,6 @@
import com.android.compatibility.common.util.IModuleResult;
import com.android.compatibility.common.util.ITestResult;
import com.android.compatibility.common.util.TestStatus;
-import com.android.compatibility.tradefed.command.MockConsole;
import com.android.ddmlib.testrunner.TestIdentifier;
import com.android.tradefed.build.FolderBuildInfo;
import com.android.tradefed.build.IFolderBuildInfo;
@@ -39,7 +38,7 @@
public class ResultReporterTest extends TestCase {
private static final String ROOT_PROPERTY = "TESTS_ROOT";
- private static final String BUILD_ID = "2";
+ private static final String BUILD_NUMBER = "2";
private static final String SUITE_PLAN = "cts";
private static final String DYNAMIC_CONFIG_URL = "";
private static final String ROOT_DIR_NAME = "root";
@@ -65,10 +64,6 @@
"logo.png",
"newrule-green.png"};
- // Make sure the mock is in the ClassLoader
- @SuppressWarnings("unused")
- private MockConsole mMockConsole;
-
private ResultReporter mReporter;
private IFolderBuildInfo mBuildInfo;
private CompatibilityBuildHelper mBuildHelper;
@@ -79,7 +74,6 @@
@Override
public void setUp() throws Exception {
- mMockConsole = new MockConsole();
mReporter = new ResultReporter();
mRoot = FileUtil.createTempDir(ROOT_DIR_NAME);
mBase = new File(mRoot, BASE_DIR_NAME);
@@ -87,14 +81,13 @@
mTests = new File(mBase, TESTCASES);
mTests.mkdirs();
System.setProperty(ROOT_PROPERTY, mRoot.getAbsolutePath());
- mBuildInfo = new FolderBuildInfo(BUILD_ID, "", "");
+ mBuildInfo = new FolderBuildInfo(BUILD_NUMBER, "", "");
mBuildHelper = new CompatibilityBuildHelper(mBuildInfo);
mBuildHelper.init(SUITE_PLAN, DYNAMIC_CONFIG_URL);
}
@Override
public void tearDown() throws Exception {
- mMockConsole = null;
mReporter = null;
FileUtil.recursiveDelete(mRoot);
}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/tradefed/command/MockConsole.java b/common/host-side/tradefed/tests/src/com/android/compatibility/tradefed/command/MockConsole.java
deleted file mode 100644
index 20fab72..0000000
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/tradefed/command/MockConsole.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-package com.android.compatibility.tradefed.command;
-
-/**
- * This console is not used for any purpose other than creating the package name space from which
- * the suite-specific values in the MANIFEST.mf can be read; replicating what a test suite.
- */
-public class MockConsole {
-
-}
diff --git a/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java b/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java
new file mode 100644
index 0000000..8cf1e3f
--- /dev/null
+++ b/common/host-side/util/tests/src/com/android/compatibility/common/util/HostUnitTests.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+package com.android.compatibility.common.util;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * A test suite for all host util unit tests.
+ * <p/>
+ * All tests listed here should be self-contained, and do not require any external dependencies.
+ */
+public class HostUnitTests extends TestSuite {
+
+ public HostUnitTests() {
+ super();
+ addTestSuite(DynamicConfigHandlerTest.class);
+ addTestSuite(MetricsStoreTest.class);
+ }
+
+ public static Test suite() {
+ return new HostUnitTests();
+ }
+}
\ No newline at end of file
diff --git a/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java b/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
new file mode 100644
index 0000000..1d367fe
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+package com.android.compatibility.common.util;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * A test suite for all util unit tests.
+ * <p/>
+ * All tests listed here should be self-contained, and do not require any external dependencies.
+ */
+public class UnitTests extends TestSuite {
+
+ public UnitTests() {
+ super();
+ addTestSuite(AbiUtilsTest.class);
+ addTestSuite(CaseResultTest.class);
+ addTestSuite(DynamicConfigTest.class);
+ addTestSuite(MetricsXmlSerializerTest.class);
+ addTestSuite(ModuleResultTest.class);
+ addTestSuite(MultipartFormTest.class);
+ addTestSuite(ReportLogTest.class);
+ addTestSuite(StatTest.class);
+ addTestSuite(TestFilterTest.class);
+ addTestSuite(TestResultTest.class);
+ addTestSuite(XmlResultHandlerTest.class);
+ }
+
+ public static Test suite() {
+ return new UnitTests();
+ }
+}
\ No newline at end of file
diff --git a/hostsidetests/sample/Android.mk b/hostsidetests/sample/Android.mk
index 644621d..8a76a8b 100644
--- a/hostsidetests/sample/Android.mk
+++ b/hostsidetests/sample/Android.mk
@@ -25,7 +25,7 @@
LOCAL_MODULE := CtsSampleHostTestCases
-LOCAL_JAVA_LIBRARIES := compatibility-host-util compatibility-tradefed tradefed-prebuilt
+LOCAL_JAVA_LIBRARIES := compatibility-host-util cts-tradefed_v2 tradefed-prebuilt
include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/run_unit_tests.sh b/run_unit_tests.sh
index d4b210e..b3dab1e 100755
--- a/run_unit_tests.sh
+++ b/run_unit_tests.sh
@@ -36,20 +36,13 @@
fi;
fi;
+############### Run the device side tests ###############
JAR_DIR=${ANDROID_HOST_OUT}/framework
JARS="
- compatibility-common-util-hostsidelib\
- compatibility-common-util-tests\
- compatibility-host-util\
- compatibility-host-util-tests\
- compatibility-tradefed-tests\
- compatibility-tradefed\
- cts-tradefed-tests_v2\
- cts-tradefed_v2\
ddmlib-prebuilt\
hosttestlib\
tradefed-prebuilt"
-
+JAR_PATH=
for JAR in $JARS; do
checkFile ${JAR_DIR}/${JAR}.jar
JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
@@ -65,25 +58,48 @@
java $RDBG_FLAG -cp ${JAR_PATH} ${TF_CONSOLE} run singleCommand instrument --package ${COMMON_PACKAGE} --runner ${RUNNER}
adb uninstall ${COMMON_PACKAGE}
+############### Run the host side tests ###############
+JARS="
+ compatibility-common-util-hostsidelib\
+ compatibility-common-util-tests\
+ compatibility-host-util\
+ compatibility-host-util-tests\
+ compatibility-mock-tradefed\
+ compatibility-tradefed-tests\
+ ddmlib-prebuilt\
+ hosttestlib\
+ tradefed-prebuilt"
+JAR_PATH=
+for JAR in $JARS; do
+ checkFile ${JAR_DIR}/${JAR}.jar
+ JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
+done
+
TEST_CLASSES="
- com.android.compatibility.common.tradefed.build.CompatibilityBuildHelperTest\
- com.android.compatibility.common.tradefed.command.CompatibilityConsoleTest\
- com.android.compatibility.common.tradefed.result.ResultReporterTest\
- com.android.compatibility.common.tradefed.testtype.CompatibilityTestTest\
- com.android.compatibility.common.tradefed.testtype.ModuleDefTest\
- com.android.compatibility.common.tradefed.testtype.ModuleRepoTest\
- com.android.compatibility.common.util.AbiUtilsTest\
- com.android.compatibility.common.util.CaseResultTest\
- com.android.compatibility.common.util.DynamicConfigTest\
- com.android.compatibility.common.util.MetricsStoreTest\
- com.android.compatibility.common.util.MetricsXmlSerializerTest\
- com.android.compatibility.common.util.ModuleResultTest\
- com.android.compatibility.common.util.MultipartFormTest\
- com.android.compatibility.common.util.ReportLogTest\
- com.android.compatibility.common.util.StatTest\
- com.android.compatibility.common.util.TestFilterTest\
- com.android.compatibility.common.util.TestResultTest\
- com.android.compatibility.common.util.XmlResultHandlerTest\
+ com.android.compatibility.common.tradefed.UnitTests\
+ com.android.compatibility.common.util.HostUnitTests\
+ com.android.compatibility.common.util.UnitTests"
+
+for CLASS in ${TEST_CLASSES}; do
+ java $RDBG_FLAG -cp ${JAR_PATH} ${TF_CONSOLE} run singleCommand host -n --class ${CLASS} "$@"
+done
+
+############### Run the cts tests ###############
+JARS="
+ compatibility-common-util-hostsidelib\
+ compatibility-host-util\
+ cts-tradefed-tests_v2\
+ cts-tradefed_v2\
+ ddmlib-prebuilt\
+ hosttestlib\
+ tradefed-prebuilt"
+JAR_PATH=
+for JAR in $JARS; do
+ checkFile ${JAR_DIR}/${JAR}.jar
+ JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
+done
+
+TEST_CLASSES="
com.android.compatibility.tradefed.CtsTradefedTest"
for CLASS in ${TEST_CLASSES}; do
diff --git a/tools/cts-tradefed/Android.mk b/tools/cts-tradefed/Android.mk
index 1cf7599..ee54b65 100644
--- a/tools/cts-tradefed/Android.mk
+++ b/tools/cts-tradefed/Android.mk
@@ -17,18 +17,19 @@
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_SRC_FILES += $(call all-java-files-under, ../../common/host-side/tradefed/src)
LOCAL_JAVA_RESOURCE_DIRS := res
+LOCAL_JAVA_RESOURCE_DIRS += ../../common/host-side/tradefed/res
-LOCAL_JAR_MANIFEST := MANIFEST.mf
+LOCAL_SUITE_BUILD_NUMBER := $(BUILD_NUMBER)
+LOCAL_SUITE_NAME := CTS_V2
+LOCAL_SUITE_FULLNAME := "Compatibility Test Suite"
+LOCAL_SUITE_VERSION := 5.0
LOCAL_MODULE := cts-tradefed_v2
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib compatibility-tradefed
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-include $(BUILD_HOST_JAVA_LIBRARY)
+include $(BUILD_COMPATIBILITY_SUITE)
# Build all sub-directories
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/cts-tradefed/MANIFEST.mf b/tools/cts-tradefed/MANIFEST.mf
deleted file mode 100644
index 5bac62a..0000000
--- a/tools/cts-tradefed/MANIFEST.mf
+++ /dev/null
@@ -1,6 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.compatibility.tradefed.command.CtsConsole
-Specification-Title: Compatibility Test Suite
-Specification-Vendor: CTS_V2
-Specification-Version: 5.0_r1.91
-Implementation-Version: %BUILD_NUMBER%
diff --git a/tools/cts-tradefed/etc/cts-tradefed_v2 b/tools/cts-tradefed/etc/cts-tradefed_v2
index cccd4b9..e501e7f 100755
--- a/tools/cts-tradefed/etc/cts-tradefed_v2
+++ b/tools/cts-tradefed/etc/cts-tradefed_v2
@@ -82,7 +82,6 @@
JARS="tradefed-prebuilt
hosttestlib
compatibility-host-util
- compatibility-tradefed
cts-tradefed_v2"
for JAR in $JARS; do
@@ -105,5 +104,5 @@
CLASS_PATH=${JAR_PATH}:${HOST_TEST_JAR_PATH}
-java $RDBG_FLAG -cp ${CLASS_PATH} -DCTS_V2_ROOT=${CTS_V2_ROOT} com.android.compatibility.tradefed.command.CtsConsole "$@"
+java $RDBG_FLAG -cp ${CLASS_PATH} -DCTS_V2_ROOT=${CTS_V2_ROOT} com.android.compatibility.common.tradefed.command.CompatibilityConsole "$@"
diff --git a/tools/cts-tradefed/src/com/android/compatibility/tradefed/command/CtsConsole.java b/tools/cts-tradefed/src/com/android/compatibility/tradefed/command/CtsConsole.java
deleted file mode 100644
index fcd9f94..0000000
--- a/tools/cts-tradefed/src/com/android/compatibility/tradefed/command/CtsConsole.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-package com.android.compatibility.tradefed.command;
-
-import com.android.compatibility.common.tradefed.command.CompatibilityConsole;
-import com.android.tradefed.command.Console;
-import com.android.tradefed.config.ConfigurationException;
-
-/**
- * An extension of {@link CompatibilityConsole} for running CTS tests.
- *
- * This file mainly exists to provide package name space from which the suite-specific values in the
- * MANIFEST.mf can be read.
- */
-public class CtsConsole extends CompatibilityConsole {
-
- public static void main(String[] args) throws InterruptedException, ConfigurationException {
- Console console = new CtsConsole();
- Console.startConsole(console, args);
- }
-}
diff --git a/tools/cts-tradefed/tests/Android.mk b/tools/cts-tradefed/tests/Android.mk
index 454c9d6..7314fdb 100644
--- a/tools/cts-tradefed/tests/Android.mk
+++ b/tools/cts-tradefed/tests/Android.mk
@@ -16,11 +16,10 @@
include $(CLEAR_VARS)
-# Only compile source java files in this lib.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_MODULE := cts-tradefed-tests_v2
LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt cts-tradefed_v2 compatibility-tradefed
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt cts-tradefed_v2
include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java b/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java
index db5d42f..2dcf1c9 100644
--- a/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java
+++ b/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java
@@ -17,7 +17,6 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
-import com.android.compatibility.tradefed.command.CtsConsole;
import com.android.tradefed.build.IFolderBuildInfo;
import com.android.tradefed.util.FileUtil;
@@ -36,7 +35,7 @@
private static final String SUITE_PLAN = "cts";
private static final String DYNAMIC_CONFIG_URL = "";
- public void testManifest() throws Exception {
+ public void testSuiteInfoLoad() throws Exception {
// Test the values in the manifest can be loaded
File root = FileUtil.createTempDir("root");
System.setProperty(PROPERTY_NAME, root.getAbsolutePath());
@@ -44,7 +43,6 @@
base.mkdirs();
File tests = new File(base, "testcases");
tests.mkdirs();
- CtsConsole c = new CtsConsole();
CompatibilityBuildProvider provider = new CompatibilityBuildProvider();
IFolderBuildInfo info = (IFolderBuildInfo) provider.getBuild();
CompatibilityBuildHelper helper = new CompatibilityBuildHelper(info);