am d4ea0825: am b1a9e89c: am c0206763: am ae8cc846: am 4f8604a2: am ff760448: am a3a37fd2: am 7a4c8877: am b1a8a3b7: am 589787a2: am 6d2d5623: am e9ea138a: Merge "Revert "Use real screen width/height to calculate aspect ratio"" into jb-dev
* commit 'd4ea082508742355a8a3e4c2dc7256d370a76781':
Revert "Use real screen width/height to calculate aspect ratio"
diff --git a/tests/tests/net/src/android/net/ipv6/cts/PingTest.java b/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
index 41eb03d..acf474f 100644
--- a/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
+++ b/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
@@ -34,6 +34,21 @@
import java.util.Arrays;
import java.util.Random;
+/**
+ * Checks that the device has kernel support for the IPv6 ping socket. This allows ping6 to work
+ * without root privileges. The necessary kernel code is in Linux 3.11 or above, or the
+ * <code>common/android-3.x</code> kernel trees. If you are not running one of these kernels, the
+ * functionality can be obtained by cherry-picking the following patches from David Miller's
+ * <code>net-next</code> tree:
+ * <ul>
+ * <li>6d0bfe2 net: ipv6: Add IPv6 support to the ping socket.
+ * <li>c26d6b4 ping: always initialize ->sin6_scope_id and ->sin6_flowinfo
+ * <li>fbfe80c net: ipv6: fix wrong ping_v6_sendmsg return value
+ * <li>a1bdc45 net: ipv6: add missing lock in ping_v6_sendmsg
+ * <li>cf970c0 ping: prevent NULL pointer dereference on write to msg_name
+ * </ul>
+ * or the equivalent backports to the <code>common/android-3.x</code> trees.
+ */
public class PingTest extends AndroidTestCase {
/** Maximum size of the packets we're using to test. */
private static final int MAX_SIZE = 4096;
@@ -90,19 +105,25 @@
/**
* Checks that a socket has received a response appropriate to the specified packet.
*/
- private void checkResponse(FileDescriptor s,
- InetAddress dest, byte[] sent) throws ErrnoException, IOException {
- // Receive the response.
- InetSocketAddress from = new InetSocketAddress();
+ private void checkResponse(FileDescriptor s, InetAddress dest,
+ byte[] sent, boolean useRecvfrom) throws ErrnoException, IOException {
ByteBuffer responseBuffer = ByteBuffer.allocate(MAX_SIZE);
- int bytesRead = Libcore.os.recvfrom(s, responseBuffer, 0, from);
+ int bytesRead;
- // Check the source address and scope ID.
- assertTrue(from.getAddress() instanceof Inet6Address);
- Inet6Address fromAddress = (Inet6Address) from.getAddress();
- assertEquals(0, fromAddress.getScopeId());
- assertNull(fromAddress.getScopedInterface());
- assertEquals(dest.getHostAddress(), fromAddress.getHostAddress());
+ // Receive the response.
+ if (useRecvfrom) {
+ InetSocketAddress from = new InetSocketAddress();
+ bytesRead = Libcore.os.recvfrom(s, responseBuffer, 0, from);
+
+ // Check the source address and scope ID.
+ assertTrue(from.getAddress() instanceof Inet6Address);
+ Inet6Address fromAddress = (Inet6Address) from.getAddress();
+ assertEquals(0, fromAddress.getScopeId());
+ assertNull(fromAddress.getScopedInterface());
+ assertEquals(dest.getHostAddress(), fromAddress.getHostAddress());
+ } else {
+ bytesRead = Libcore.os.read(s, responseBuffer);
+ }
// Check the packet length.
assertEquals(sent.length, bytesRead);
@@ -135,8 +156,11 @@
for (int i = 0; i < NUM_PACKETS; i++) {
byte[] packet = pingPacket((int) (Math.random() * MAX_SIZE));
FileDescriptor s = createPingSocket();
+ // Use both recvfrom and read().
sendPing(s, ipv6Loopback, packet);
- checkResponse(s, ipv6Loopback, packet);
+ checkResponse(s, ipv6Loopback, packet, true);
+ sendPing(s, ipv6Loopback, packet);
+ checkResponse(s, ipv6Loopback, packet, false);
// Check closing the socket doesn't raise an exception.
Libcore.os.close(s);
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java b/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java
index ad3d078..967e52b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java
@@ -88,8 +88,8 @@
}
@Override
- protected void fillRandomFloats(long seed, int fact, int offset, float[] inArray) {
- RSUtils.genRandomFloats(seed, 32, -16, inArray);
+ protected void fillRandomFloats(long seed, float min, float max, float[] inArray) {
+ RSUtils.genRandomFloats(seed, -16.0f, 16.0f, inArray);
}
public void testPowF32() {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java b/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java
index 32308ce..6a47d8f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java
@@ -82,7 +82,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, -16, n);
+ RSUtils.genRandomInts(0x12345678, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n1(nAlloc);
@@ -93,7 +93,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, -16, n);
+ RSUtils.genRandomInts(0x12345678, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n1(nAlloc);
@@ -104,7 +104,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, -16, n);
+ RSUtils.genRandomInts(0xacdef1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n2(nAlloc);
@@ -115,7 +115,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, -16, n);
+ RSUtils.genRandomInts(0xacdef1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n2(nAlloc);
@@ -126,7 +126,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, -16, n);
+ RSUtils.genRandomInts(0xa123f1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n3(nAlloc);
@@ -137,7 +137,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, -16, n);
+ RSUtils.genRandomInts(0xa123f1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n3(nAlloc);
@@ -148,7 +148,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, -16, n);
+ RSUtils.genRandomInts(0x4323ca, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n4(nAlloc);
@@ -159,7 +159,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, -16, n);
+ RSUtils.genRandomInts(0x4323ca, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n4(nAlloc);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java b/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java
index cebbe24..a957418 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java
@@ -88,8 +88,8 @@
}
@Override
- protected void fillRandomFloats(long seed, int fact, int offset, float[] inArray) {
- RSUtils.genRandomFloats(seed, 64, 0, inArray);
+ protected void fillRandomFloats(long seed, float min, float max, float[] inArray) {
+ RSUtils.genRandomFloats(seed, 0.0f, 64.0f, inArray);
}
public void testPowrF32() {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
index d7759f1..f2554c4 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
@@ -85,11 +85,11 @@
}
}
- private void baseTestHelper(int testid, Element inElement, Element outElement, long seed, int fact,
- int offset, int rStride, int rSkip, int refStride, int outStride,
+ private void baseTestHelper(int testid, Element inElement, Element outElement, long seed, float min,
+ float max, int rStride, int rSkip, int refStride, int outStride,
int inStride, int skip, int ulp) {
float[] inArray = makeInArray(INPUTSIZE * inStride);
- fillRandomFloats(seed, fact, offset, inArray);
+ fillRandomFloats(seed, min, max, inArray);
float[] refArray = getRefArray(inArray, INPUTSIZE, inStride, skip);
Allocation mAllocationIn = setInAlloc(inElement);
@@ -108,39 +108,39 @@
}
public void baseTest(int testid, long seed, int refStride, int outStride, int inStride, int skip, int ulp) {
- baseTestHelper(testid, null, null, seed, 1, 0, 1, 0, refStride, outStride, inStride, skip, ulp);
+ baseTestHelper(testid, null, null, seed, 0.0f, 1.0f, 1, 0, refStride, outStride, inStride, skip, ulp);
}
public void doF32(long seed, int ulp) {
- baseTestHelper(TEST_F32, Element.F32(mRS), Element.F32(mRS), seed, 1, 0, 1, 0, 1, 1, 1, 0, ulp);
+ baseTestHelper(TEST_F32, Element.F32(mRS), Element.F32(mRS), seed, 0.0f, 1.0f, 1, 0, 1, 1, 1, 0, ulp);
}
public void doF32_2(long seed, int ulp) {
- baseTestHelper(TEST_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 1, 0, 1, 0, 2, 2, 2, 0, ulp);
+ baseTestHelper(TEST_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 0.0f, 1.0f, 1, 0, 2, 2, 2, 0, ulp);
}
public void doF32_3(long seed, int ulp) {
- baseTestHelper(TEST_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 1, 0, 4, 1, 3, 4, 4, 1, ulp);
+ baseTestHelper(TEST_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 0.0f, 1.0f, 4, 1, 3, 4, 4, 1, ulp);
}
public void doF32_4(long seed, int ulp) {
- baseTestHelper(TEST_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 1, 0, 1, 0, 4, 4, 4, 0, ulp);
+ baseTestHelper(TEST_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 0.0f, 1.0f, 1, 0, 4, 4, 4, 0, ulp);
}
public void doF32_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32, Element.F32(mRS), Element.F32(mRS), seed, 1, 0, 1, 0, 1, 1, 1, 0, ulp);
+ baseTestHelper(TEST_RELAXED_F32, Element.F32(mRS), Element.F32(mRS), seed, 0.0f, 1.0f, 1, 0, 1, 1, 1, 0, ulp);
}
public void doF32_2_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 1, 0, 1, 0, 2, 2, 2, 0, ulp);
+ baseTestHelper(TEST_RELAXED_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 0.0f, 1.0f, 1, 0, 2, 2, 2, 0, ulp);
}
public void doF32_3_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 1, 0, 4, 1, 3, 4, 4, 1, ulp);
+ baseTestHelper(TEST_RELAXED_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 0.0f, 1.0f, 4, 1, 3, 4, 4, 1, ulp);
}
public void doF32_4_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 1, 0, 1, 0, 4, 4, 4, 0, ulp);
+ baseTestHelper(TEST_RELAXED_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 0.0f, 1.0f, 1, 0, 4, 4, 4, 0, ulp);
}
@@ -173,8 +173,8 @@
return new float[size];
}
- protected void fillRandomFloats(long seed, int fact, int offset, float[] inArray) {
- RSUtils.genRandomFloats(seed, fact, offset, inArray);
+ protected void fillRandomFloats(long seed, float min, float max, float[] inArray) {
+ RSUtils.genRandomFloats(seed, min, max, inArray);
}
protected void fillInAlloc(Allocation mIn, float[] inArray) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java b/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java
index d3fb5d0..9165bdb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java
@@ -28,22 +28,24 @@
public class RSUtils {
/**
- * Fills the array with random floats. Values will be: offset + number between 0 and max.
+ * Fills the array with random floats. Values will be between min (inclusive) and
+ * max (inclusive).
*/
- public static void genRandomFloats(long seed, int max, int offset, float array[]) {
+ public static void genRandomFloats(long seed, float min, float max, float array[]) {
Random r = new Random(seed);
for (int i = 0; i < array.length; i++) {
- array[i] = r.nextFloat() * max + offset;
+ array[i] = min + r.nextFloat() * (max - min);
}
}
/**
- * Fills the array with random ints. Values will be: offset + number between 0 and max (exclusive).
+ * Fills the array with random floats. Values will be between min (inclusive) and
+ * max (inclusive).
*/
- public static void genRandomInts(long seed, int max, int offset, int array[]) {
+ public static void genRandomInts(long seed, int min, int max, int array[]) {
Random r = new Random(seed);
for (int i = 0; i < array.length; i++) {
- array[i] = (r.nextInt(max) + offset);
+ array[i] = min + r.nextInt(max - min + 1);
}
}
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java b/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java
index 2c447bb..a253669 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java
@@ -80,7 +80,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, 1, n);
+ RSUtils.genRandomInts(0x12345678, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n1(nAlloc);
@@ -91,7 +91,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, 1, n);
+ RSUtils.genRandomInts(0x12345678, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n1(nAlloc);
@@ -103,7 +103,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, 1, n);
+ RSUtils.genRandomInts(0xacdef1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n2(nAlloc);
@@ -114,7 +114,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, 1, n);
+ RSUtils.genRandomInts(0xacdef1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n2(nAlloc);
@@ -126,7 +126,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, 1, n);
+ RSUtils.genRandomInts(0xa123f1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n3(nAlloc);
@@ -137,7 +137,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, 1, n);
+ RSUtils.genRandomInts(0xa123f1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n3(nAlloc);
@@ -148,7 +148,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, 1, n);
+ RSUtils.genRandomInts(0x4323ca, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n4(nAlloc);
@@ -159,7 +159,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, 1, n);
+ RSUtils.genRandomInts(0x4323ca, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n4(nAlloc);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java b/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
index edff5b9..328160a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
@@ -72,7 +72,7 @@
float[] inArray = new float[INPUTSIZE * 4];
byte[] outArray = new byte[INPUTSIZE * 4];
byte[] refArray = new byte[INPUTSIZE * 4];
- RSUtils.genRandomFloats(seed, 1, 0, inArray);
+ RSUtils.genRandomFloats(seed, 0.0f, 1.0f, inArray);
mAllocationIn.copy1DRangeFrom(0, INPUTSIZE, inArray);
try {
forEach(testId, mAllocationIn, mAllocationOut);
@@ -99,7 +99,7 @@
float[] inArray = new float[INPUTSIZE * 4];
byte[] outArray = new byte[INPUTSIZE * 4];
byte[] refArray = new byte[INPUTSIZE * 4];
- RSUtils.genRandomFloats(seed, 1, 0, inArray);
+ RSUtils.genRandomFloats(seed, 0.0f, 1.0f, inArray);
mAllocationIn.copy1DRangeFrom(0, INPUTSIZE, inArray);
try {
forEach(testId, mAllocationIn, mAllocationOut);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
index e972640..0ebdeea 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
@@ -33,6 +33,7 @@
public class VMHostTest extends JarHostTest {
private static final String VM_TEST_TEMP_DIR = "/data/local/tmp/vm-tests";
+ private static final String EMULATOR_TEMP_DIR = "/data/local/tmp";
/**
* {@inheritDoc}
@@ -66,7 +67,7 @@
CLog.d("Creating device temp directory, including dalvik-cache.");
createRemoteDir(device, VM_TEST_TEMP_DIR + "/dalvik-cache" );
try {
- File localTmpDir = FileUtil.createTempDir("cts-vm", new File("/tmp/"));
+ File localTmpDir = FileUtil.createTempDir("cts-vm", new File(System.getProperty("java.io.tmpdir")));
CLog.d("Creating host temp dir %s", localTmpDir.getPath());
File jarFile = new File(ctsBuild.getTestCasesDir(), getJarFileName());
if (!jarFile.exists()) {
@@ -119,11 +120,10 @@
if (device.doesFileExist(remoteFilePath)) {
return;
}
- File f = new File(remoteFilePath);
- String parentPath = f.getParent();
- if (parentPath != null) {
- createRemoteDir(device, parentPath);
+ if (!(device.doesFileExist(EMULATOR_TEMP_DIR))) {
+ CLog.e("Error: Can not found the /data/local/tmp directory!!!");
}
+ device.executeShellCommand(String.format("mkdir %s", VM_TEST_TEMP_DIR));
device.executeShellCommand(String.format("mkdir %s", remoteFilePath));
}
}