- Add Sensor tests to know failure list.
- Sensor test fixes for robustness.
b/11352697
Change-Id: I5701c14c9376a39e4e4a9e708b991efa9c38fd61
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index ae6a093..99dfad4 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -19,5 +19,10 @@
name: "com.android.pts.opengl.primitive.GLPrimitiveBenchmark#testFullPipelineOffscreen",
name: "com.android.pts.opengl.primitive.GLPrimitiveBenchmark#testPixelOutputOffscreen",
bug: 11238219
+},
+{
+ name: "android.hardware.cts.SensorIntegrationTests#testSensorsWithSeveralClients",
+ name: "android.hardware.cts.SensorIntegrationTests#testSensorsMovingRates",
+ bug: 11352697
}
]
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorEventOrderingTests.java b/tests/tests/hardware/src/android/hardware/cts/SensorEventOrderingTests.java
index 9efa71d..55c2637 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorEventOrderingTests.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorEventOrderingTests.java
@@ -60,9 +60,7 @@
{ Sensor.TYPE_ACCELEROMETER, SensorManager.SENSOR_DELAY_FASTEST, 0 },
{ Sensor.TYPE_GYROSCOPE, SensorManager.SENSOR_DELAY_FASTEST, 0 },
{ Sensor.TYPE_MAGNETIC_FIELD, SensorManager.SENSOR_DELAY_FASTEST, 0 },
- { Sensor.TYPE_LIGHT, SensorManager.SENSOR_DELAY_FASTEST, 0 },
{ Sensor.TYPE_PRESSURE, SensorManager.SENSOR_DELAY_FASTEST, 0 },
- { Sensor.TYPE_PROXIMITY, SensorManager.SENSOR_DELAY_FASTEST, 0 },
{ Sensor.TYPE_GRAVITY, SensorManager.SENSOR_DELAY_FASTEST, 0 },
{ Sensor.TYPE_LINEAR_ACCELERATION, SensorManager.SENSOR_DELAY_FASTEST, 0 },
{ Sensor.TYPE_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST, 0 },
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java b/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
index 0612c03..f96c885 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
@@ -92,21 +92,22 @@
Sensor.TYPE_MAGNETIC_FIELD,
Sensor.TYPE_GYROSCOPE };
- ParallelCompositeSensorTestOperation operation = new ParallelCompositeSensorTestOperation();
+ ParallelCompositeSensorTestOperation operation =
+ new ParallelCompositeSensorTestOperation(this);
for(int sensorType : sensorTypes) {
SensorTestOperation continuousOperation = new VerifyEventOrderingOperation(
this,
sensorType,
SensorManager.SENSOR_DELAY_NORMAL,
0 /* reportLatencyInUs */);
- operation.add(new RepeatingSensorTestOperation(continuousOperation, ITERATIONS));
+ operation.add(new RepeatingSensorTestOperation(this, continuousOperation, ITERATIONS));
SensorTestOperation batchingOperation = new VerifyEventOrderingOperation(
this,
sensorType,
SensorTestInformation.getMaxSamplingRateInUs(this, sensorType),
SensorCtsHelper.getSecondsAsMicroSeconds(BATCHING_RATE_IN_SECONDS));
- operation.add(new RepeatingSensorTestOperation(batchingOperation, ITERATIONS));
+ operation.add(new RepeatingSensorTestOperation(this, batchingOperation, ITERATIONS));
}
operation.execute();
}
@@ -137,7 +138,8 @@
final int INSTANCES_TO_USE = 5;
final int ITERATIONS_TO_EXECUTE = 100;
- ParallelCompositeSensorTestOperation operation = new ParallelCompositeSensorTestOperation();
+ ParallelCompositeSensorTestOperation operation =
+ new ParallelCompositeSensorTestOperation(this);
int sensorTypes[] = {
Sensor.TYPE_ACCELEROMETER,
Sensor.TYPE_MAGNETIC_FIELD,
@@ -146,7 +148,7 @@
for(int sensorType : sensorTypes) {
for(int instance = 0; instance < INSTANCES_TO_USE; ++instance) {
SequentialCompositeSensorTestOperation sequentialOperation =
- new SequentialCompositeSensorTestOperation();
+ new SequentialCompositeSensorTestOperation(this);
for(int iteration = 0; iteration < ITERATIONS_TO_EXECUTE; ++iteration) {
VerifyEventOrderingOperation sensorOperation = new VerifyEventOrderingOperation(
this,
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
index 47b3973..ce859d2 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
@@ -146,7 +146,7 @@
* . android.permission.READ_LOGS
* . android.permission.DUMP
*/
- public static void collectBugreport(String collectorId)
+ public static String collectBugreport(String collectorId)
throws IOException, InterruptedException {
String commands[] = new String[] {
"dumpstate",
@@ -158,8 +158,8 @@
SimpleDateFormat dateFormat = new SimpleDateFormat("M-d-y_H:m:s.S");
String outputFile = String.format(
"%s/%s_%s",
- collectorId,
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
+ collectorId,
dateFormat.format(new Date()));
DataOutputStream processOutput = null;
@@ -182,6 +182,8 @@
} catch(IOException e) {}
}
}
+
+ return outputFile;
}
public static Sensor getSensor(AndroidTestCase testCase, int sensorType) {
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorManagerTestVerifier.java b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorManagerTestVerifier.java
index f7f55c9..dd29cb1 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorManagerTestVerifier.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorManagerTestVerifier.java
@@ -146,17 +146,6 @@
}
/**
- * Support methods for clients of this class.
- */
- public Assert verifier() {
- return mAssert;
- }
-
- public int getUnderlyingType() {
- return mSensorUnderTest.getType();
- }
-
- /**
* Definition of support test classes.
*/
private class TestSensorListener implements SensorEventListener2 {
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorTestOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorTestOperation.java
index 11b113f..e87b289 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorTestOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorTestOperation.java
@@ -16,6 +16,10 @@
package android.hardware.cts.helpers;
+import junit.framework.Assert;
+
+import java.util.concurrent.TimeUnit;
+
/**
* Base test class that supports a basic test operation performed in a sensor.
* The class follows a command patter as a base for its work.
@@ -28,12 +32,19 @@
private final SensorTestExceptionHandler mExceptionHandler = new SensorTestExceptionHandler();
protected final String LOG_TAG = "TestRunner";
- protected final int WAIT_TIMEOUT_IN_MILLISECONDS = 30 * 1000;
+ protected final long WAIT_TIMEOUT_IN_MILLISECONDS =
+ TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES);
+
+ protected final Assert mAssert;
private Thread mThread;
protected int mIterationCount;
+ protected SensorTestOperation(Assert assertionObject) {
+ mAssert = assertionObject;
+ }
+
/**
* Public API definition.
*/
@@ -65,6 +76,16 @@
return;
}
mThread.join(WAIT_TIMEOUT_IN_MILLISECONDS);
+ if(mThread.isAlive()) {
+ // the test is hung so collect the state of the system and fail
+ String operationName = this.getClass().getSimpleName();
+ String message = String.format(
+ "%s hung. %s. BugReport collected at: %s",
+ operationName,
+ this.toString(),
+ SensorCtsHelper.collectBugreport(operationName));
+ mAssert.fail(message);
+ }
mThread = null;
mExceptionHandler.rethrow();
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/ParallelCompositeSensorTestOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/ParallelCompositeSensorTestOperation.java
index 3730f4b..11fb81f 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/ParallelCompositeSensorTestOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/ParallelCompositeSensorTestOperation.java
@@ -16,6 +16,8 @@
package android.hardware.cts.helpers.sensorTestOperations;
+import junit.framework.Assert;
+
import android.hardware.cts.helpers.SensorTestOperation;
import java.util.ArrayList;
@@ -28,6 +30,10 @@
public class ParallelCompositeSensorTestOperation extends SensorTestOperation {
private final ArrayList<SensorTestOperation> mOperations = new ArrayList<SensorTestOperation>();
+ public ParallelCompositeSensorTestOperation(Assert assertionObject) {
+ super(assertionObject);
+ }
+
/**
* There is no synchronization
* @param operations
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/RepeatingSensorTestOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/RepeatingSensorTestOperation.java
index 7a3c450..35782c1 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/RepeatingSensorTestOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/RepeatingSensorTestOperation.java
@@ -16,6 +16,8 @@
package android.hardware.cts.helpers.sensorTestOperations;
+import junit.framework.Assert;
+
import android.hardware.cts.helpers.SensorTestOperation;
/**
@@ -25,7 +27,11 @@
private final SensorTestOperation mSensorTestOperation;
private final int mRepetitionCount;
- public RepeatingSensorTestOperation(SensorTestOperation operation, int repetitionCount) {
+ public RepeatingSensorTestOperation(
+ Assert assertionObject,
+ SensorTestOperation operation,
+ int repetitionCount) {
+ super(assertionObject);
mSensorTestOperation = operation;
mRepetitionCount = repetitionCount;
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/SequentialCompositeSensorTestOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/SequentialCompositeSensorTestOperation.java
index 4b921680..cd879f5 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/SequentialCompositeSensorTestOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/SequentialCompositeSensorTestOperation.java
@@ -16,6 +16,8 @@
package android.hardware.cts.helpers.sensorTestOperations;
+import junit.framework.Assert;
+
import android.hardware.cts.helpers.SensorTestOperation;
import java.util.ArrayList;
@@ -28,6 +30,10 @@
public class SequentialCompositeSensorTestOperation extends SensorTestOperation {
private final ArrayList<SensorTestOperation> mOperations = new ArrayList<SensorTestOperation>();
+ public SequentialCompositeSensorTestOperation(Assert assertionObject) {
+ super(assertionObject);
+ }
+
/**
* There is no synchronization
* @param operations
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyEventOrderingOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyEventOrderingOperation.java
index a4e5642..90824b2 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyEventOrderingOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyEventOrderingOperation.java
@@ -34,6 +34,7 @@
int sensorType,
int samplingRateInUs,
int reportLatencyInUs) {
+ super(testCase);
mSensor = new SensorManagerTestVerifier(
testCase,
sensorType,
@@ -55,7 +56,9 @@
i,
previousTimestamp,
timestamp);
- mSensor.verifier().assertTrue(message, previousTimestamp < timestamp);
+ // allow two identical timestamps to be considered in order, in case the resolution of
+ // the timestamp is not granular enough
+ mAssert.assertTrue(message, previousTimestamp <= timestamp);
}
}
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyJitteringOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyJitteringOperation.java
index 79b835c..5aac8af 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyJitteringOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyJitteringOperation.java
@@ -48,6 +48,7 @@
int sensorType,
int reportLatencyInUs,
int thresholdPercentageOfNs) throws InvalidParameterException {
+ super(testCase);
if(thresholdPercentageOfNs < 0) {
throw new InvalidParameterException("thresholdPercentageOfNs needs to be >= 0");
}
@@ -87,7 +88,7 @@
mThresholdPercentage,
percentile95InNs,
actualPercentValue);
- mSensor.verifier().fail(message);
+ mAssert.fail(message);
}
}
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyMaximumFrequencyOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyMaximumFrequencyOperation.java
index 1ff8cde..94fef60 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyMaximumFrequencyOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyMaximumFrequencyOperation.java
@@ -49,6 +49,7 @@
int sensorType,
int reportLatencyInUs,
int thresholdPercentageOfNs) throws InvalidParameterException {
+ super(testCase);
if(thresholdPercentageOfNs < 0) {
throw new InvalidParameterException("thresholdPercentageOfNs needs to be >= 0");
}
@@ -90,7 +91,7 @@
SensorCtsHelper.getFrequencyInHz(frequencyMeanInUs),
mThresholdInNs,
mThresholdPercentage);
- mSensor.verifier().fail(message);
+ mAssert.fail(message);
}
}
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyNormOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyNormOperation.java
index 75998db..e3b64e7 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyNormOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyNormOperation.java
@@ -40,13 +40,14 @@
int samplingRateInUs,
float referenceValue,
float threshold) {
+ super(testCase);
mSensor = new SensorManagerTestVerifier(
testCase,
sensorType,
samplingRateInUs,
0 /*reportLatencyInUs*/);
// set expectations
- mAxisCount = SensorTestInformation.getAxisCount(mSensor.getUnderlyingType());
+ mAxisCount = SensorTestInformation.getAxisCount(mSensor.getUnderlyingSensor().getType());
mReferenceValue = referenceValue;
mThreshold = threshold;
}
@@ -75,6 +76,6 @@
mThreshold,
norm,
valuesBuilder.toString());
- mSensor.verifier().assertTrue(message, Math.abs(mReferenceValue - norm) <= mThreshold);
+ mAssert.assertTrue(message, Math.abs(mReferenceValue - norm) <= mThreshold);
}
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyStandardDeviationOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyStandardDeviationOperation.java
index dd4df72..bc0a498 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyStandardDeviationOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorTestOperations/VerifyStandardDeviationOperation.java
@@ -42,13 +42,14 @@
int samplingRateInUs,
int reportLatencyInUs,
float expectedStandardDeviation) {
+ super(testCase);
mSensor = new SensorManagerTestVerifier(
testCase,
sensorType,
samplingRateInUs,
reportLatencyInUs);
// set expectations
- mAxisCount = SensorTestInformation.getAxisCount(mSensor.getUnderlyingType());
+ mAxisCount = SensorTestInformation.getAxisCount(mSensor.getUnderlyingSensor().getType());
mExpectedStandardDeviation = expectedStandardDeviation;
}
@@ -74,7 +75,7 @@
i,
mExpectedStandardDeviation,
standardDeviation);
- mSensor.verifier().fail(message);
+ mAssert.fail(message);
}
}
}