Merge "fix broken ColorBufferTest" into jb-mr1-dev
diff --git a/suite/pts/PtsBuild.mk b/suite/pts/PtsBuild.mk
index 4c3d4b2..3c4df8b 100644
--- a/suite/pts/PtsBuild.mk
+++ b/suite/pts/PtsBuild.mk
@@ -19,7 +19,7 @@
 LOCAL_PATH:= $(call my-dir)
 
 # New packages should be added here
-PTS_TEST_PACKAGES = \
+PTS_TEST_PACKAGES := \
     PtsDeviceFilePerf \
     PtsDeviceUi \
     PtsDeviceDram
@@ -27,7 +27,14 @@
 PTS_SUPPORT_PACKAGES := \
 	TestDeviceSetup
 
+PTS_HOST_CASES := \
+    PtsHostBootup
+
+PTS_HOST_LIBS := \
+    $(HOST_OUT_JAVA_LIBRARIES)/ptscommonutilhost.jar
+
 BUILD_PTS_PACKAGE := cts/suite/pts/build/test_package.mk
+BUILD_PTS_HOST_JAVA_LIBRARY := cts/suite/pts/build/test_host_java_library.mk
 
 PTS_JAVA_TEST_SCANNER := $(HOST_OUT_EXECUTABLES)/cts-java-scanner
 PTS_JAVA_TEST_SCANNER_DOCLET := $(HOST_OUT_JAVA_LIBRARIES)/cts-java-scanner-doclet.jar
@@ -48,13 +55,20 @@
 	$(foreach name,$(1),$(PTS_TESTCASES_OUT)/$(name).xml)
 endef
 
+define pts-get-lib-paths
+	$(foreach lib,$(1),$(HOST_OUT_JAVA_LIBRARIES)/$(lib).jar)
+endef
+
 PTS_TEST_CASE_LIST := \
 	$(PTS_SUPPORT_PACKAGES)
 
 PTS_TEST_CASES := \
-		$(call pts-get-package-paths,$(PTS_TEST_PACKAGES))
+		$(call pts-get-package-paths,$(PTS_TEST_PACKAGES)) \
+		$(call pts-get-lib-paths,$(PTS_HOST_CASES))
 
-PTS_TEST_XMLS := $(call pts-get-test-xmls,$(PTS_TEST_PACKAGES))
+PTS_TEST_XMLS := \
+    $(call pts-get-test-xmls,$(PTS_TEST_PACKAGES)) \
+    $(call pts-get-test-xmls,$(PTS_HOST_CASES))
 
 pts_dir := $(HOST_OUT)/pts
 pts_tools_src_dir := cts/tools
@@ -74,7 +88,7 @@
 
 $(pts_dir)/all_pts_files_stamp: PRIVATE_JUNIT_HOST_JAR := $(junit_host_jar)
 
-$(pts_dir)/all_pts_files_stamp: $(PTS_TEST_CASES) $(PTS_TEST_CASE_LIST) $(junit_host_jar) $(HOSTTESTLIB_JAR) $(PTS_HOST_LIBRARY_JARS) $(TF_JAR) $(VMTESTSTF_JAR) $(PTS_TF_JAR) $(PTS_TF_EXEC) $(PTS_TF_README) $(ACP)
+$(pts_dir)/all_pts_files_stamp: $(PTS_TEST_CASES) $(PTS_TEST_CASE_LIST) $(junit_host_jar) $(HOSTTESTLIB_JAR) $(PTS_HOST_LIBRARY_JARS) $(TF_JAR) $(VMTESTSTF_JAR) $(PTS_TF_JAR) $(PTS_TF_EXEC) $(PTS_TF_README) $(ACP) $(PTS_HOST_LIBS)
 # Make necessary directory for PTS
 	$(hide) rm -rf $(PRIVATE_PTS_DIR)
 	$(hide) mkdir -p $(TMP_DIR)
@@ -83,7 +97,7 @@
 	$(hide) mkdir -p $(PRIVATE_DIR)/repository/testcases
 	$(hide) mkdir -p $(PRIVATE_DIR)/repository/plans
 # Copy executable and JARs to PTS directory
-	$(hide) $(ACP) -fp $(DDMLIB_JAR) $(PRIVATE_JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(PTS_HOST_LIBRARY_JARS) $(TF_JAR) $(PTS_TF_JAR) $(PTS_TF_EXEC) $(PTS_TF_README) $(PRIVATE_DIR)/tools
+	$(hide) $(ACP) -fp $(DDMLIB_JAR) $(PRIVATE_JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(PTS_HOST_LIBRARY_JARS) $(TF_JAR) $(PTS_TF_JAR) $(PTS_TF_EXEC) $(PTS_TF_README) $(PTS_HOST_LIBS) $(PRIVATE_DIR)/tools
 # Change mode of the executables
 	$(foreach apk,$(PTS_TEST_CASE_LIST),$(call copy-testcase-apk,$(apk)))
 	$(foreach testcase,$(PTS_TEST_CASES),$(call copy-testcase,$(testcase)))
diff --git a/suite/pts/build/test_host_java_library.mk b/suite/pts/build/test_host_java_library.mk
new file mode 100644
index 0000000..3f410d1
--- /dev/null
+++ b/suite/pts/build/test_host_java_library.mk
@@ -0,0 +1,38 @@
+# Copyright (C) 2012 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 host library and defines a rule to generate the associated test
+# package XML needed by PTS.
+#
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+pts_library_xml := $(PTS_TESTCASES_OUT)/$(LOCAL_MODULE).xml
+
+$(pts_library_xml): PRIVATE_PATH := $(LOCAL_PATH)/src
+$(pts_library_xml): PRIVATE_TEST_PACKAGE := $(LOCAL_PTS_TEST_PACKAGE)
+$(pts_library_xml): PRIVATE_LIBRARY := $(LOCAL_MODULE)
+$(pts_library_xml): PRIVATE_JAR_PATH := $(LOCAL_MODULE).jar
+$(pts_library_xml): $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_MODULE).jar $(PTS_EXPECTATIONS) $(PTS_JAVA_TEST_SCANNER_DOCLET) $(PTS_JAVA_TEST_SCANNER) $(PTS_XML_GENERATOR)
+	$(hide) echo Generating test description for host library $(PRIVATE_LIBRARY)
+	$(hide) mkdir -p $(PTS_TESTCASES_OUT)
+	$(hide) $(PTS_JAVA_TEST_SCANNER) -s $(PRIVATE_PATH) \
+						-d $(PTS_JAVA_TEST_SCANNER_DOCLET) | \
+			$(PTS_XML_GENERATOR) -t hostSideOnly \
+						-j $(PRIVATE_JAR_PATH) \
+						-n $(PRIVATE_LIBRARY) \
+						-p $(PRIVATE_TEST_PACKAGE) \
+						-e $(PTS_EXPECTATIONS) \
+						-o $@
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/AlmostFullTest.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/AlmostFullTest.java
index 1735ea3..89c2f7c 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/AlmostFullTest.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/AlmostFullTest.java
@@ -93,7 +93,7 @@
     }
 
     @TimeoutReq(minutes = 30)
-    public void testSequentialUpdate() throws IOException {
+    public void testSequentialUpdate() throws Exception {
         // now about freeSpaceToLeave should be left
         // and try updating exceeding the free space size
         final long FILE_SIZE = 400L * 1024L * 1024L;
@@ -109,7 +109,7 @@
     //TODO: file size too small and caching will give wrong better result.
     //      needs to flush cache by reading big files per each read.
     @TimeoutReq(minutes = 60)
-    public void testRandomRead() throws IOException {
+    public void testRandomRead() throws Exception {
         final int BUFFER_SIZE = 4 * 1024;
         final long fileSize = 400L * 1024L * 1024L;
         FileUtil.doRandomReadTest(getContext(), DIR_RANDOM_RD, getReportLog(), fileSize,
@@ -117,7 +117,7 @@
     }
 
     @TimeoutReq(minutes = 60)
-    public void testRandomUpdate() throws IOException {
+    public void testRandomUpdate() throws Exception {
         final int BUFFER_SIZE = 4 * 1024;
         final long fileSize = 400L * 1024L * 1024L;
         FileUtil.doRandomWriteTest(getContext(), DIR_RANDOM_WR, getReportLog(), fileSize,
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
index 3399a5b..57f868a 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
@@ -182,7 +182,7 @@
      * @throws IOException
      */
     public static double[] measureIO(int count, double[] readAmount, double[] writeAmount,
-            MeasureRun run)  throws IOException {
+            MeasureRun run)  throws Exception {
         double[] result = new double[count];
         File procIo = new File("/proc/self/io");
         boolean measureIo = procIo.exists();
@@ -260,7 +260,7 @@
      * @throws IOException
      */
     public static void doRandomReadTest(Context context, String dirName, ReportLog report,
-            long fileSize, int bufferSize) throws IOException {
+            long fileSize, int bufferSize) throws Exception {
         File file = FileUtil.createNewFilledFile(context,
                 dirName, fileSize);
 
@@ -313,7 +313,7 @@
      * @throws IOException
      */
     public static void doRandomWriteTest(Context context, String dirName, ReportLog report,
-            long fileSize, int bufferSize) throws IOException {
+            long fileSize, int bufferSize) throws Exception {
         File file = FileUtil.createNewFilledFile(context,
                 dirName, fileSize);
         final byte[] data = FileUtil.generateRandomData(bufferSize);
@@ -365,7 +365,7 @@
      * @throws IOException
      */
     public static void doSequentialUpdateTest(Context context, String dirName, ReportLog report,
-            long fileSize, int bufferSize, int numberRepetition) throws IOException {
+            long fileSize, int bufferSize, int numberRepetition) throws Exception {
         File file = FileUtil.createNewFilledFile(context,
                 dirName, fileSize);
         final byte[] data = FileUtil.generateRandomData(bufferSize);
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java
index e9eb25b..537d900 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/RandomRWTest.java
@@ -41,7 +41,7 @@
     }
 
     @TimeoutReq(minutes = 60)
-    public void testRandomRead() throws IOException {
+    public void testRandomRead() throws Exception {
         final int READ_BUFFER_SIZE = 4 * 1024;
         final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), READ_BUFFER_SIZE);
         FileUtil.doRandomReadTest(getContext(), DIR_RANDOM_RD, getReportLog(), fileSize,
@@ -50,7 +50,7 @@
 
     // It is taking too long in tuna, and thus cannot run multiple times
     @TimeoutReq(minutes = 60)
-    public void testRandomUpdate() throws IOException {
+    public void testRandomUpdate() throws Exception {
         final int WRITE_BUFFER_SIZE = 4 * 1024;
         final long fileSize = 512 * 1024 * 1024;
         FileUtil.doRandomWriteTest(getContext(), DIR_RANDOM_WR, getReportLog(), fileSize,
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
index a68ac4e..eb66da2 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
@@ -44,7 +44,7 @@
     }
 
     @TimeoutReq(minutes = 30)
-    public void testSingleSequentialWrite() throws IOException {
+    public void testSingleSequentialWrite() throws Exception {
         final int numberOfFiles =(int)(FileUtil.getFileSizeExceedingMemory(
                 getContext(), BUFFER_SIZE) / BUFFER_SIZE);
         getReportLog().printValue("files", numberOfFiles);
@@ -69,7 +69,7 @@
     }
 
     @TimeoutReq(minutes = 60)
-    public void testSingleSequentialUpdate() throws IOException {
+    public void testSingleSequentialUpdate() throws Exception {
         final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), BUFFER_SIZE);
         final int NUMBER_REPETITION = 6;
         FileUtil.doSequentialUpdateTest(getContext(), DIR_SEQ_UPD, getReportLog(), fileSize,
@@ -77,7 +77,7 @@
     }
 
     @TimeoutReq(minutes = 30)
-    public void testSingleSequentialRead() throws IOException {
+    public void testSingleSequentialRead() throws Exception {
         final long fileSize = FileUtil.getFileSizeExceedingMemory(getContext(), BUFFER_SIZE);
         long start = System.currentTimeMillis();
         final File file = FileUtil.createNewFilledFile(getContext(),
diff --git a/suite/pts/deviceTests/ptsutil/Android.mk b/suite/pts/deviceTests/ptsutil/Android.mk
index d097036..d488442 100644
--- a/suite/pts/deviceTests/ptsutil/Android.mk
+++ b/suite/pts/deviceTests/ptsutil/Android.mk
@@ -24,6 +24,8 @@
 
 LOCAL_MODULE := ptsutil
 
+LOCAL_STATIC_JAVA_LIBRARIES := ptscommonutil
+
 LOCAL_SDK_VERSION := 16
 
 include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureRun.java b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DeviceReportLog.java
similarity index 71%
copy from suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureRun.java
copy to suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DeviceReportLog.java
index 1f6f6ed..9747ca5 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureRun.java
+++ b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/DeviceReportLog.java
@@ -16,12 +16,17 @@
 
 package com.android.pts.util;
 
-import java.io.IOException;
+import android.util.Log;
 
-/**
- * interface for measuring time for each run.
- */
-public interface MeasureRun {
+public class DeviceReportLog extends ReportLog {
+    private static final String TAG = "PtsReport";
 
-    abstract public void run(int i) throws IOException;
+    DeviceReportLog() {
+        mDepth = 4;
+    }
+
+    @Override
+    protected void printLog(String msg) {
+        Log.i(TAG, msg);
+    }
 }
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java
index 84c1718..0c9cdfa 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java
+++ b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsActivityInstrumentationTestCase2.java
@@ -24,7 +24,7 @@
 public class PtsActivityInstrumentationTestCase2<T extends Activity> extends
         ActivityInstrumentationTestCase2<T> {
 
-    private ReportLog mReportLog = new ReportLog();
+    private ReportLog mReportLog = new DeviceReportLog();
 
     public PtsActivityInstrumentationTestCase2(Class<T> activityClass) {
         super(activityClass);
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java
index bf17956..b847df7 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java
+++ b/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsAndroidTestCase.java
@@ -21,7 +21,7 @@
 
 public class PtsAndroidTestCase extends AndroidTestCase {
 
-    private ReportLog mReportLog = new ReportLog();
+    private ReportLog mReportLog = new DeviceReportLog();
 
     public ReportLog getReportLog() {
         return mReportLog;
diff --git a/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java b/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java
index c19055c..7491f8a 100644
--- a/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java
+++ b/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java
@@ -54,7 +54,7 @@
     }
 
     @TimeoutReq(minutes = 30)
-    public void testFullScrolling() throws IOException {
+    public void testFullScrolling() throws Exception {
         final int NUMBER_REPEAT = 10;
         final ScrollingActivity activity = mActivity;
         double[] results = MeasureTime.measure(NUMBER_REPEAT, new MeasureRun() {
diff --git a/suite/pts/hostTests/Android.mk b/suite/pts/hostTests/Android.mk
new file mode 100644
index 0000000..c141484
--- /dev/null
+++ b/suite/pts/hostTests/Android.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2012 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.
+#
+
+include $(call all-subdir-makefiles)
diff --git a/suite/pts/hostTests/bootup/Android.mk b/suite/pts/hostTests/bootup/Android.mk
new file mode 100644
index 0000000..b0226c3
--- /dev/null
+++ b/suite/pts/hostTests/bootup/Android.mk
@@ -0,0 +1,31 @@
+# Copyright (C) 2012 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_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE := PtsHostBootup
+
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt ddmlib-prebuilt junit ptscommonutilhost
+
+LOCAL_PTS_TEST_PACKAGE := com.android.pts.bootup
+
+include $(BUILD_PTS_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java b/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
new file mode 100644
index 0000000..97d9dc8
--- /dev/null
+++ b/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2012 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.pts.bootup;
+
+import android.cts.util.TimeoutReq;
+import com.android.pts.util.MeasureRun;
+import com.android.pts.util.MeasureTime;
+import com.android.pts.util.ReportLog;
+import com.android.pts.util.Stat;
+import com.android.pts.util.Stat.StatResult;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.TestDeviceOptions;
+import com.android.tradefed.testtype.DeviceTestCase;
+
+
+public class BootupTimeTest extends DeviceTestCase {
+
+    private ReportLog mReport = null;
+
+    @Override
+    protected void setUp() throws Exception {
+        mReport = new ReportLog();
+        super.setUp();
+    }
+
+
+    @Override
+    protected void tearDown() throws Exception {
+        mReport.throwReportToHost();
+        super.tearDown();
+    }
+
+    @TimeoutReq(minutes = 30)
+    public void testBootupTime() throws Exception {
+        final int NUMBER_REPEAT = 5;
+        double[] result = MeasureTime.measure(NUMBER_REPEAT, new MeasureRun() {
+            @Override
+            public void prepare(int i) throws Exception {
+                if (i == 0) {
+                    return;
+                }
+                final long SLEEP_TIME = 2 * 60 * 1000L;
+                Thread.sleep(SLEEP_TIME);
+            }
+            @Override
+            public void run(int i) throws Exception {
+                rebootDevice();
+            }
+        });
+        mReport.printArray("time in ms", result, false);
+        StatResult stat = Stat.getStat(result);
+        mReport.printSummary("time in ms", stat.mMax, stat.mAverage);
+    }
+
+    private void rebootDevice() throws DeviceNotAvailableException {
+        final int TIMEOUT_MS = 10 * 60 * 1000;
+        TestDeviceOptions options = getDevice().getOptions();
+        // store default value and increase time-out for reboot
+        int rebootTimeout = options.getRebootTimeout();
+        long onlineTimeout = options.getOnlineTimeout();
+        options.setRebootTimeout(TIMEOUT_MS);
+        options.setOnlineTimeout(TIMEOUT_MS);
+        getDevice().setOptions(options);
+        getDevice().reboot();
+        // restore default values
+        options.setRebootTimeout(rebootTimeout);
+        options.setOnlineTimeout(onlineTimeout);
+        getDevice().setOptions(options);
+    }
+}
diff --git a/suite/pts/lib/Android.mk b/suite/pts/lib/Android.mk
new file mode 100644
index 0000000..c141484
--- /dev/null
+++ b/suite/pts/lib/Android.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2012 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.
+#
+
+include $(call all-subdir-makefiles)
diff --git a/suite/pts/lib/commonutil/Android.mk b/suite/pts/lib/commonutil/Android.mk
new file mode 100644
index 0000000..fc108ef
--- /dev/null
+++ b/suite/pts/lib/commonutil/Android.mk
@@ -0,0 +1,40 @@
+# Copyright (C) 2012 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_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE := ptscommonutil
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+################################################################
+
+include $(CLEAR_VARS)
+
+# only TmeoutReq annotation used fro, the libs/util, so add it here
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under, src) \
+    ../../../../libs/util/src/android/cts/util/TimeoutReq.java
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE := ptscommonutilhost
+
+include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureRun.java b/suite/pts/lib/commonutil/src/com/android/pts/util/MeasureRun.java
similarity index 72%
rename from suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureRun.java
rename to suite/pts/lib/commonutil/src/com/android/pts/util/MeasureRun.java
index 1f6f6ed..3add474 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureRun.java
+++ b/suite/pts/lib/commonutil/src/com/android/pts/util/MeasureRun.java
@@ -16,12 +16,16 @@
 
 package com.android.pts.util;
 
-import java.io.IOException;
-
 /**
  * interface for measuring time for each run.
  */
-public interface MeasureRun {
+public abstract class MeasureRun {
+    /**
+     *  called before each run. not included to time measurement.
+     */
+    public void prepare(int i) throws Exception {
+        // default empty implementation
+    };
 
-    abstract public void run(int i) throws IOException;
+    abstract public void run(int i) throws Exception;
 }
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureTime.java b/suite/pts/lib/commonutil/src/com/android/pts/util/MeasureTime.java
similarity index 83%
rename from suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureTime.java
rename to suite/pts/lib/commonutil/src/com/android/pts/util/MeasureTime.java
index 337a472..595e6a5 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/MeasureTime.java
+++ b/suite/pts/lib/commonutil/src/com/android/pts/util/MeasureTime.java
@@ -16,7 +16,6 @@
 
 package com.android.pts.util;
 
-import java.io.IOException;
 
 public class MeasureTime {
     /**
@@ -26,14 +25,15 @@
      * @return array of time taken in each run in msec.
      * @throws IOException
      */
-    public static double[] measure(int count, MeasureRun run)  throws IOException {
+    public static double[] measure(int count, MeasureRun run)  throws Exception {
         double[] result = new double[count];
-        long prev = System.currentTimeMillis();
+
         for (int i = 0; i < count; i++) {
+            run.prepare(i);
+            long start = System.currentTimeMillis();
             run.run(i);
-            long current =  System.currentTimeMillis();
-            result[i] = current - prev;
-            prev = current;
+            long end =  System.currentTimeMillis();
+            result[i] = end - start;
         }
         return result;
     }
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsException.java b/suite/pts/lib/commonutil/src/com/android/pts/util/PtsException.java
similarity index 100%
rename from suite/pts/deviceTests/ptsutil/src/com/android/pts/util/PtsException.java
rename to suite/pts/lib/commonutil/src/com/android/pts/util/PtsException.java
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/ReportLog.java b/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
similarity index 90%
rename from suite/pts/deviceTests/ptsutil/src/com/android/pts/util/ReportLog.java
rename to suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
index 531d2f5..1fe3c59 100644
--- a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/ReportLog.java
+++ b/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
@@ -16,8 +16,6 @@
 
 package com.android.pts.util;
 
-import android.util.Log;
-
 import java.util.LinkedList;
 import java.util.List;
 
@@ -34,23 +32,23 @@
  *                     average average_value min|max value stddev value
  */
 public class ReportLog {
-    private static final String TAG = "PtsReport";
     private static final String LOG_SEPARATOR = "+++";
     private static final String SUMMARY_SEPARATOR = "++++";
     private static final String LOG_ELEM_SEPARATOR = "|";
 
     private List<String> mMessages = new LinkedList<String> ();
     private String mSummary = null;
+    protected static int mDepth = 3;
     /**
      * print given value to the report
      * @param header string to explain the contents. It can be unit for the value.
      * @param val
      */
     public void printValue(String header, double val) {
-        String message = getClassMethodNames(4, true) + LOG_ELEM_SEPARATOR + header +
+        String message = getClassMethodNames(mDepth, true) + LOG_ELEM_SEPARATOR + header +
                 LOG_ELEM_SEPARATOR + "d" + LOG_ELEM_SEPARATOR + val;
         mMessages.add(message);
-        Log.i(TAG, message);
+        printLog(message);
     }
 
     /**
@@ -61,7 +59,7 @@
      */
     public void printArray(String header, double[] val, boolean addMin) {
         StringBuilder builder = new StringBuilder();
-        builder.append(getClassMethodNames(4, true) + LOG_ELEM_SEPARATOR + header +
+        builder.append(getClassMethodNames(mDepth, true) + LOG_ELEM_SEPARATOR + header +
                 LOG_ELEM_SEPARATOR + "da" + LOG_ELEM_SEPARATOR);
         for (double v : val) {
             builder.append(v);
@@ -71,7 +69,7 @@
         builder.append(LOG_ELEM_SEPARATOR + "average " + stat.mAverage +
                 (addMin ? (" min " + stat.mMin) : (" max " + stat.mMax)) + " stddev " + stat.mStddev);
         mMessages.add(builder.toString());
-        Log.i(TAG, builder.toString());
+        printLog(builder.toString());
     }
 
     public void printSummary(String header, double worst, double average) {
@@ -94,6 +92,8 @@
         if (builder.length() >= LOG_SEPARATOR.length()) {
             builder.delete(builder.length() - LOG_SEPARATOR.length(), builder.length());
         }
+        mSummary = null;
+        mMessages.clear();
         throw new PtsException(builder.toString());
     }
 
@@ -137,7 +137,7 @@
      * @return
      */
     public static String getClassMethodNames() {
-        return getClassMethodNames(4, false);
+        return getClassMethodNames(mDepth, false);
     }
 
     private static String getClassMethodNames(int depth, boolean addLineNumber) {
@@ -146,4 +146,12 @@
                 (addLineNumber ? ":" + elements[depth].getLineNumber() : "");
         return names;
     }
+
+    /**
+     * to be overridden by child to print message to be passed
+     * @param msg
+     */
+    protected void printLog(String msg) {
+
+    }
 }
diff --git a/suite/pts/deviceTests/ptsutil/src/com/android/pts/util/Stat.java b/suite/pts/lib/commonutil/src/com/android/pts/util/Stat.java
similarity index 100%
rename from suite/pts/deviceTests/ptsutil/src/com/android/pts/util/Stat.java
rename to suite/pts/lib/commonutil/src/com/android/pts/util/Stat.java
diff --git a/suite/pts/tools/tradefed/pts-tradefed b/suite/pts/tools/tradefed/pts-tradefed
index fedbfaf..d1eaa8b 100755
--- a/suite/pts/tools/tradefed/pts-tradefed
+++ b/suite/pts/tools/tradefed/pts-tradefed
@@ -74,7 +74,7 @@
 fi;
 
 JAR_DIR=${PTS_ROOT}/android-pts/tools
-JARS="ddmlib-prebuilt.jar tradefed-prebuilt.jar hosttestlib.jar cts-tradefed.jar"
+JARS="ddmlib-prebuilt.jar tradefed-prebuilt.jar hosttestlib.jar cts-tradefed.jar ptscommonutilhost.jar"
 
 for JAR in $JARS; do
     checkFile ${JAR_DIR}/${JAR}
diff --git a/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java b/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java
index 62ca1f9..d1f5d05 100644
--- a/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java
+++ b/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java
@@ -139,10 +139,4 @@
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_NO_ERROR, error);
     }
-
-    public void test_glAttachShaders_successfulcompile_attach_invalid_handle_frag() throws Throwable {
-        mActivity = getShaderActivity(Constants.SHADER, 12);
-        int error = mActivity.glGetError();
-        assertTrue(GLES20.GL_NO_ERROR != error);
-    }
 }
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
index 06f940a..ffbb930 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
@@ -200,6 +200,10 @@
         if (HOST_SIDE_ONLY_TEST.equals(mTestType)) {
             CLog.d("Creating host test for %s", mName);
             JarHostTest hostTest = new JarHostTest();
+            if (mTimeoutInMins >= 0) {
+                CLog.d("Setting new timeout to " + mTimeoutInMins + " mins");
+                hostTest.setTimeout(mTimeoutInMins * 60 * 1000);
+            }
             hostTest.setRunName(getUri());
             hostTest.setJarFileName(mJarPath);
             hostTest.setTests(mTests);