Merge "Add verification stress test."
diff --git a/test/303-verification-stress/build b/test/303-verification-stress/build
new file mode 100644
index 0000000..2ef9bea
--- /dev/null
+++ b/test/303-verification-stress/build
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 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.
+
+# Stop if something fails.
+set -e
+
+# Write out a bunch of source files.
+gcc -o classes-gen classes-gen.c
+./classes-gen
+
+mkdir classes
+${JAVAC} -d classes src/*.java
+
+${DX} --debug --dex --dump-to=classes.lst --output=classes.dex classes
+zip $TEST_NAME.jar classes.dex
diff --git a/test/303-verification-stress/classes-gen.c b/test/303-verification-stress/classes-gen.c
new file mode 100644
index 0000000..be6cfa7
--- /dev/null
+++ b/test/303-verification-stress/classes-gen.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Generate a big pile of classes with big <clinit>.
+ */
+#include <stdio.h>
+
+/*
+ * Create N files.
+ */
+static int createFiles(int count, int array_size)
+{
+ FILE* fp;
+ int i;
+ int k;
+
+ for (i = 0; i < count; i++) {
+ char nameBuf[32];
+
+ snprintf(nameBuf, sizeof(nameBuf), "src/Test%03d.java", i);
+ fp = fopen(nameBuf, "w");
+ if (fp == NULL) {
+ fprintf(stderr, "ERROR: unable to open %s\n", nameBuf);
+ return -1;
+ }
+
+ fprintf(fp, "public class Test%03d {\n", i);
+ fprintf(fp, " static String[] array = new String[%d];\n", array_size);
+ fprintf(fp, " static {\n", array_size);
+ for (k = 0; k < array_size; k++) {
+ fprintf(fp, " array[%d] = \"string_%04d\";\n", k, k);
+ }
+ fprintf(fp, " }\n", array_size);
+ fprintf(fp, "}\n");
+ fclose(fp);
+ }
+
+ // Create test class.
+ fp = fopen("src/MainTest.java", "w");
+ if (fp == NULL) {
+ fprintf(stderr, "ERROR: unable to open src/MainTest.java\n");
+ return -1;
+ }
+ fprintf(fp, "public class MainTest {\n");
+ fprintf(fp, " public static void run() {\n");
+ for (i = 0; i < count; i++) {
+ fprintf(fp, " System.out.println(\"Create new Test%03d\");\n", i);
+ fprintf(fp, " new Test%03d();\n", i);
+ }
+ fprintf(fp, " }\n");
+ fprintf(fp, "}\n");
+ fclose(fp);
+
+ return 0;
+}
+
+int main()
+{
+ int result;
+
+ result = createFiles(40, 2000);
+
+ return (result != 0);
+}
diff --git a/test/303-verification-stress/expected.txt b/test/303-verification-stress/expected.txt
new file mode 100644
index 0000000..cdfd6cb
--- /dev/null
+++ b/test/303-verification-stress/expected.txt
@@ -0,0 +1,12 @@
+Starting test
+Create new Test000
+Create new Test001
+Create new Test002
+Create new Test003
+Create new Test004
+Create new Test005
+Create new Test006
+Create new Test007
+Create new Test008
+Create new Test009
+Done
diff --git a/test/303-verification-stress/info.txt b/test/303-verification-stress/info.txt
new file mode 100644
index 0000000..131682c
--- /dev/null
+++ b/test/303-verification-stress/info.txt
@@ -0,0 +1,7 @@
+This is more a benchmark for the verifier than a real test. We create many
+classes, each one initializing a big array of string in its class initializer.
+This generates big <clinit> methods in these classes. The goal is to stress the
+verifier on such method.
+
+Note: these classes are generated automatically. The number of classes and the
+size of string array can be modified in the script.
diff --git a/test/303-verification-stress/src/Main.java b/test/303-verification-stress/src/Main.java
new file mode 100644
index 0000000..d906bae
--- /dev/null
+++ b/test/303-verification-stress/src/Main.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+public class Main {
+
+ public static void main(String args[]) {
+ System.out.println("Starting test");
+
+ // MainTest class is generated automatically.
+ MainTest.run();
+
+ System.out.println("Done");
+ }
+}