summaryrefslogtreecommitdiff
path: root/test/071-dexfile-get-static-size
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2018-01-19 14:19:59 +0000
committer David Brazdil <dbrazdil@google.com> 2018-01-19 14:41:23 +0000
commit7d2ec61d8ed54d520ea9def9224740c592461b9c (patch)
tree59679693bf507130113a17ccfa8513f1d1ee7546 /test/071-dexfile-get-static-size
parentf01528de9486c854b5e4da9994239b17b261084f (diff)
Copy 'res' folder to device for run-tests
Sometimes tests need to push resources to target for a run-test. The scripts currently do not have an option how to bundle additional files with the test. To this end, this patch tests for presence of folder named 'res' and if it exists, copies it into DEX_LOCATION on the device. Test 071 was converted to become the first test using this new feature. Test: art/test.py -b -r -t 071-dexfile-get-static Change-Id: I7eac4b15ca19fce6c616f5cc732b7ac65b8174b8
Diffstat (limited to 'test/071-dexfile-get-static-size')
-rwxr-xr-xtest/071-dexfile-get-static-size/build12
-rw-r--r--test/071-dexfile-get-static-size/res/test1.dex (renamed from test/071-dexfile-get-static-size/test1.dex)bin1864 -> 1864 bytes
-rw-r--r--test/071-dexfile-get-static-size/res/test2.dex (renamed from test/071-dexfile-get-static-size/test2.dex)bin1264 -> 1264 bytes
-rw-r--r--test/071-dexfile-get-static-size/src/Main.java20
4 files changed, 6 insertions, 26 deletions
diff --git a/test/071-dexfile-get-static-size/build b/test/071-dexfile-get-static-size/build
index 0bba66d065..412ee6dd46 100755
--- a/test/071-dexfile-get-static-size/build
+++ b/test/071-dexfile-get-static-size/build
@@ -16,15 +16,13 @@
./default-build "$@"
-# Create and add as resources to the test jar file:
+# Bundle with the test the following resources:
# 1. test1.dex
# 2. test2.dex
# 3. test-jar.jar, containing test1.dex as classes.dex
# 4. multi-jar.jar, containing test1.dex as classes.dex and test2.dex as classes2.dex
mkdir test-jar
-cp test1.dex test-jar/classes.dex
-cp test2.dex test-jar/classes2.dex
-zip -j test-jar.jar test-jar/classes.dex
-zip -j multi-jar.jar test-jar/classes.dex test-jar/classes2.dex
-jar uf ${TEST_NAME}.jar test1.dex test2.dex test-jar.jar multi-jar.jar
-
+cp res/test1.dex test-jar/classes.dex
+cp res/test2.dex test-jar/classes2.dex
+zip -j res/test-jar.jar test-jar/classes.dex
+zip -j res/multi-jar.jar test-jar/classes.dex test-jar/classes2.dex
diff --git a/test/071-dexfile-get-static-size/test1.dex b/test/071-dexfile-get-static-size/res/test1.dex
index 84602d03c2..84602d03c2 100644
--- a/test/071-dexfile-get-static-size/test1.dex
+++ b/test/071-dexfile-get-static-size/res/test1.dex
Binary files differ
diff --git a/test/071-dexfile-get-static-size/test2.dex b/test/071-dexfile-get-static-size/res/test2.dex
index a07c46ef59..a07c46ef59 100644
--- a/test/071-dexfile-get-static-size/test2.dex
+++ b/test/071-dexfile-get-static-size/res/test2.dex
Binary files differ
diff --git a/test/071-dexfile-get-static-size/src/Main.java b/test/071-dexfile-get-static-size/src/Main.java
index 4bf453801e..8dbbba56c3 100644
--- a/test/071-dexfile-get-static-size/src/Main.java
+++ b/test/071-dexfile-get-static-size/src/Main.java
@@ -14,26 +14,9 @@
* limitations under the License.
*/
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class Main {
- private static void extractResource(String resource, String filename) throws Exception {
- ClassLoader loader = Main.class.getClassLoader();
- InputStream is = loader.getResourceAsStream(resource);
- OutputStream os = new FileOutputStream(filename);
- int read;
- byte[] buf = new byte[4096];
- while ((read = is.read(buf)) >= 0) {
- os.write(buf, 0, read);
- }
- is.close();
- os.close();
- }
-
private static long getDexFileSize(String filename) throws Exception {
ClassLoader loader = Main.class.getClassLoader();
Class<?> DexFile = loader.loadClass("dalvik.system.DexFile");
@@ -47,8 +30,7 @@ public class Main {
}
private static void test(String resource) throws Exception {
- String filename = System.getenv("DEX_LOCATION") + "/" + resource;
- extractResource(resource, filename);
+ String filename = System.getenv("DEX_LOCATION") + "/res/" + resource;
long size = getDexFileSize(filename);
System.out.println("Size for " + resource + ": " + size);
}