Merge "Fix CTS use of bind"
diff --git a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java
index cbfa34a..284ac83 100644
--- a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java
@@ -406,6 +406,8 @@
final PublicKey pubKey = pair.getPublic();
assertNotNull("The PublicKey for the KeyPair should be not null", pubKey);
assertEquals(keyType, pubKey.getAlgorithm());
+ assertEquals("Public keys should be in X.509 format", "X.509", pubKey.getFormat());
+ assertNotNull("Public keys should be encodable", pubKey.getEncoded());
if ("DSA".equalsIgnoreCase(keyType)) {
DSAPublicKey dsaPubKey = (DSAPublicKey) pubKey;
@@ -434,6 +436,8 @@
final PrivateKey privKey = pair.getPrivate();
assertNotNull("The PrivateKey for the KeyPair should be not null", privKey);
assertEquals(keyType, privKey.getAlgorithm());
+ assertNull("getFormat() should return null", privKey.getFormat());
+ assertNull("getEncoded() should return null", privKey.getEncoded());
KeyStore.Entry entry = mKeyStore.getEntry(alias, null);
assertNotNull("Entry should exist", entry);
@@ -471,6 +475,9 @@
chain.length);
assertUsableInSSLConnection(privKey, x509userCert);
+
+ assertEquals("Retrieved key and generated key should be equal", privKey,
+ privEntry.getPrivateKey());
}
private static void assertUsableInSSLConnection(final PrivateKey privKey,
diff --git a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
index 4f8715e..2c926a8 100644
--- a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
@@ -1468,20 +1468,29 @@
private void assertPrivateKeyEntryEquals(PrivateKeyEntry keyEntry, PrivateKey expectedKey,
Certificate expectedCert, Collection<Certificate> expectedChain) throws Exception {
+ final PrivateKey privKey = keyEntry.getPrivateKey();
+ final PublicKey pubKey = keyEntry.getCertificate().getPublicKey();
+
if (expectedKey instanceof DSAPrivateKey) {
assertEquals("Returned PrivateKey should be what we inserted",
((DSAPrivateKey) expectedKey).getParams(),
- ((DSAPublicKey) keyEntry.getCertificate().getPublicKey()).getParams());
+ ((DSAPublicKey) pubKey).getParams());
} else if (expectedKey instanceof ECPrivateKey) {
assertEquals("Returned PrivateKey should be what we inserted",
((ECPrivateKey) expectedKey).getParams().getCurve(),
- ((ECPublicKey) keyEntry.getCertificate().getPublicKey()).getParams().getCurve());
+ ((ECPublicKey) pubKey).getParams().getCurve());
} else if (expectedKey instanceof RSAPrivateKey) {
assertEquals("Returned PrivateKey should be what we inserted",
((RSAPrivateKey) expectedKey).getModulus(),
- ((RSAPrivateKey) keyEntry.getPrivateKey()).getModulus());
+ ((RSAPrivateKey) privKey).getModulus());
}
+ assertNull("getFormat() should return null", privKey.getFormat());
+ assertNull("getEncoded() should return null", privKey.getEncoded());
+
+ assertEquals("Public keys should be in X.509 format", "X.509", pubKey.getFormat());
+ assertNotNull("Public keys should be encodable", pubKey.getEncoded());
+
assertEquals("Returned Certificate should be what we inserted", expectedCert,
keyEntry.getCertificate());
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 2c8aaef..acf474f 100644
--- a/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
+++ b/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
@@ -105,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);
@@ -150,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);