Test versioned RS bitcode in CTS.

Note that these are checked in .bc files along with the reflected Java
classes. Most of the code is auto-generated by frameworks/compile/slang. To
add a new test, VersionTest.java still needs to be modified (along with an
initial commit of the corresponding .bc and .java files).

Change-Id: I6bfc117ae4e62192a68e034469c0acd54d75d3b2
diff --git a/tests/res/raw/set_target_api_11.bc b/tests/res/raw/set_target_api_11.bc
new file mode 100644
index 0000000..cd98c6a
--- /dev/null
+++ b/tests/res/raw/set_target_api_11.bc
Binary files differ
diff --git a/tests/res/raw/set_target_api_12.bc b/tests/res/raw/set_target_api_12.bc
new file mode 100644
index 0000000..20576d6
--- /dev/null
+++ b/tests/res/raw/set_target_api_12.bc
Binary files differ
diff --git a/tests/res/raw/set_target_api_13.bc b/tests/res/raw/set_target_api_13.bc
new file mode 100644
index 0000000..339876a
--- /dev/null
+++ b/tests/res/raw/set_target_api_13.bc
Binary files differ
diff --git a/tests/res/raw/set_target_api_14.bc b/tests/res/raw/set_target_api_14.bc
new file mode 100644
index 0000000..60fe08b
--- /dev/null
+++ b/tests/res/raw/set_target_api_14.bc
Binary files differ
diff --git a/tests/res/raw/set_target_api_15.bc b/tests/res/raw/set_target_api_15.bc
new file mode 100644
index 0000000..d3f1bef
--- /dev/null
+++ b/tests/res/raw/set_target_api_15.bc
Binary files differ
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
index 5418a80..dc21583 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
@@ -321,7 +321,7 @@
         assertTrue(initializeGlobals(t));
         t.invoke_test();
         waitForMessage();
-        assertEquals(result, RS_MSG_TEST_PASSED);
+        assertEquals(RS_MSG_TEST_PASSED, result);
     }
 
     /**
@@ -333,7 +333,7 @@
                                                       R.raw.utils);
         t.invoke_test();
         waitForMessage();
-        assertEquals(result, RS_MSG_TEST_PASSED);
+        assertEquals(RS_MSG_TEST_PASSED, result);
     }
 
     void setUpAllocation(Allocation a, int val) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_11.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_11.java
new file mode 100644
index 0000000..77d634f
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_11.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: set_target_api_11.rs
+ */
+package android.renderscript.cts;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptC_set_target_api_11 extends ScriptC {
+    // Constructor
+    public  ScriptC_set_target_api_11(RenderScript rs, Resources resources, int id) {
+        super(rs, resources, id);
+    }
+
+    private final static int mExportFuncIdx_check = 0;
+    public void invoke_check(int version) {
+        FieldPacker check_fp = new FieldPacker(4);
+        check_fp.addI32(version);
+        invoke(mExportFuncIdx_check, check_fp);
+    }
+
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_12.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_12.java
new file mode 100644
index 0000000..343d99d
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_12.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: set_target_api_12.rs
+ */
+package android.renderscript.cts;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptC_set_target_api_12 extends ScriptC {
+    // Constructor
+    public  ScriptC_set_target_api_12(RenderScript rs, Resources resources, int id) {
+        super(rs, resources, id);
+    }
+
+    private final static int mExportFuncIdx_check = 0;
+    public void invoke_check(int version) {
+        FieldPacker check_fp = new FieldPacker(4);
+        check_fp.addI32(version);
+        invoke(mExportFuncIdx_check, check_fp);
+    }
+
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_13.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_13.java
new file mode 100644
index 0000000..cf06a6b
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_13.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: set_target_api_13.rs
+ */
+package android.renderscript.cts;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptC_set_target_api_13 extends ScriptC {
+    // Constructor
+    public  ScriptC_set_target_api_13(RenderScript rs, Resources resources, int id) {
+        super(rs, resources, id);
+    }
+
+    private final static int mExportFuncIdx_check = 0;
+    public void invoke_check(int version) {
+        FieldPacker check_fp = new FieldPacker(4);
+        check_fp.addI32(version);
+        invoke(mExportFuncIdx_check, check_fp);
+    }
+
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_14.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_14.java
new file mode 100644
index 0000000..1b9b213
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_14.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: set_target_api_14.rs
+ */
+package android.renderscript.cts;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptC_set_target_api_14 extends ScriptC {
+    // Constructor
+    public  ScriptC_set_target_api_14(RenderScript rs, Resources resources, int id) {
+        super(rs, resources, id);
+    }
+
+    private final static int mExportFuncIdx_check = 0;
+    public void invoke_check(int version) {
+        FieldPacker check_fp = new FieldPacker(4);
+        check_fp.addI32(version);
+        invoke(mExportFuncIdx_check, check_fp);
+    }
+
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_15.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_15.java
new file mode 100644
index 0000000..4ed95b9
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptC_set_target_api_15.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: set_target_api_15.rs
+ */
+package android.renderscript.cts;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptC_set_target_api_15 extends ScriptC {
+    // Constructor
+    public  ScriptC_set_target_api_15(RenderScript rs, Resources resources, int id) {
+        super(rs, resources, id);
+    }
+
+    private final static int mExportFuncIdx_check = 0;
+    public void invoke_check(int version) {
+        FieldPacker check_fp = new FieldPacker(4);
+        check_fp.addI32(version);
+        invoke(mExportFuncIdx_check, check_fp);
+    }
+
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/VersionTest.java b/tests/tests/renderscript/src/android/renderscript/cts/VersionTest.java
new file mode 100644
index 0000000..32f884a
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/VersionTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package android.renderscript.cts;
+
+import android.renderscript.RenderScript.RSMessageHandler;
+import com.android.cts.stub.R;
+
+/**
+ * Test for appropriate handling of versioned bitcode.
+ */
+public class VersionTest extends RSBaseCompute {
+    public void testVersion11() {
+        ScriptC_set_target_api_11 test11 =
+                new ScriptC_set_target_api_11(mRS,
+                                              mRes,
+                                              R.raw.set_target_api_11);
+        test11.invoke_check(11);
+        waitForMessage();
+        assertEquals(RS_MSG_TEST_PASSED, result);
+    }
+
+    public void testVersion12() {
+        ScriptC_set_target_api_12 test12 =
+                new ScriptC_set_target_api_12(mRS,
+                                              mRes,
+                                              R.raw.set_target_api_12);
+        test12.invoke_check(12);
+        waitForMessage();
+        assertEquals(RS_MSG_TEST_PASSED, result);
+    }
+
+    public void testVersion13() {
+        ScriptC_set_target_api_13 test13 =
+                new ScriptC_set_target_api_13(mRS,
+                                              mRes,
+                                              R.raw.set_target_api_13);
+        test13.invoke_check(13);
+        waitForMessage();
+        assertEquals(RS_MSG_TEST_PASSED, result);
+    }
+
+    public void testVersion14() {
+        ScriptC_set_target_api_14 test14 =
+                new ScriptC_set_target_api_14(mRS,
+                                              mRes,
+                                              R.raw.set_target_api_14);
+        test14.invoke_check(14);
+        waitForMessage();
+        assertEquals(RS_MSG_TEST_PASSED, result);
+    }
+
+    public void testVersion15() {
+        ScriptC_set_target_api_15 test15 =
+                new ScriptC_set_target_api_15(mRS,
+                                              mRes,
+                                              R.raw.set_target_api_15);
+        test15.invoke_check(15);
+        waitForMessage();
+        assertEquals(RS_MSG_TEST_PASSED, result);
+    }
+}