Merge "Add gnustl EH tests"
diff --git a/tests/device/test-gnustl_shared-exception/jni/Android.mk b/tests/device/test-gnustl_shared-exception/jni/Android.mk
new file mode 100644
index 0000000..44cda6d
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/Android.mk
@@ -0,0 +1,87 @@
+LOCAL_PATH := $(call my-dir)
+
+# Test -1: Throw in exec, catch in exec covered elsewhere
+
+# Test 0: Throw in lib, catch in lib
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test0_foo
+LOCAL_SRC_FILES := test0_foo.cpp
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Lib_catching_lib_throwing
+LOCAL_SRC_FILES := test0_main.cpp
+LOCAL_SHARED_LIBRARIES := test0_foo
+include $(BUILD_EXECUTABLE)
+
+# Test 1: Throw in lib, catch in exec
+include $(CLEAR_VARS)
+LOCAL_MODULE := test1_foo
+LOCAL_SRC_FILES := test1_foo.cpp
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := exec_catching_lib_throwing
+LOCAL_SRC_FILES := test1_main.cpp
+LOCAL_SHARED_LIBRARIES := test1_foo
+include $(BUILD_EXECUTABLE)
+
+# Test 2: Throw in exec, catch in lib
+# Note: Symbol lookup from lib at exec fixed in bionic after android-14
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test2_foo
+LOCAL_SRC_FILES := test2_foo.cpp
+# This is required to rely on dynamic loader to resolve foo defined in exec
+LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := exec_throwing_lib_catching
+LOCAL_SRC_FILES := test2_main.cpp
+LOCAL_SHARED_LIBRARIES := test2_foo
+include $(BUILD_EXECUTABLE)
+
+#
+# 3 libs cases
+#
+
+# Test 3: Throw in lib2, catch in exec
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test3_bar
+LOCAL_SRC_FILES := test3_bar.cpp
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test3_foo
+LOCAL_SRC_FILES := test3_foo.cpp
+LOCAL_SHARED_LIBRARIES := test3_bar
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := exec_catching_lib2_throwing
+LOCAL_SRC_FILES := test3_main.cpp
+LOCAL_SHARED_LIBRARIES := test3_foo test3_bar
+include $(BUILD_EXECUTABLE)
+
+# Test 4: Throw in lib2, catch in lib1
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test4_bar
+LOCAL_SRC_FILES := test4_bar.cpp
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test4_foo
+LOCAL_SRC_FILES := test4_foo.cpp
+LOCAL_SHARED_LIBRARIES := test4_bar
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Lib1_catching_lib2_throwing
+LOCAL_SRC_FILES := test4_main.cpp
+LOCAL_SHARED_LIBRARIES := test4_foo test4_bar
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/device/test-gnustl_shared-exception/jni/Application.mk b/tests/device/test-gnustl_shared-exception/jni/Application.mk
new file mode 100644
index 0000000..4d46e05
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/Application.mk
@@ -0,0 +1,3 @@
+APP_ABI := all
+APP_STL := gnustl_shared
+APP_CPPFLAGS := -fexceptions
diff --git a/tests/device/test-gnustl_shared-exception/jni/test0_foo.cpp b/tests/device/test-gnustl_shared-exception/jni/test0_foo.cpp
new file mode 100644
index 0000000..7c7b83a
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test0_foo.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+int foo(void)
+{
+    try {
+        throw std::runtime_error("OK: Throw in lib, catch in lib!");
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test0_main.cpp b/tests/device/test-gnustl_shared-exception/jni/test0_main.cpp
new file mode 100644
index 0000000..8f31137
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test0_main.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int foo();
+
+int main(void)
+{
+    return foo();
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test1_foo.cpp b/tests/device/test-gnustl_shared-exception/jni/test1_foo.cpp
new file mode 100644
index 0000000..a1966bb
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test1_foo.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+void foo(void)
+{
+    throw std::runtime_error("OK: Throw in lib, catch in exec!");
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test1_main.cpp b/tests/device/test-gnustl_shared-exception/jni/test1_main.cpp
new file mode 100644
index 0000000..1b9df17
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test1_main.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void foo();
+
+int main(void)
+{
+    try {
+        foo();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test2_foo.cpp b/tests/device/test-gnustl_shared-exception/jni/test2_foo.cpp
new file mode 100644
index 0000000..913adaf
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test2_foo.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void foo();
+
+extern int bar(void)
+{
+    try {
+        foo();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test2_main.cpp b/tests/device/test-gnustl_shared-exception/jni/test2_main.cpp
new file mode 100644
index 0000000..4eebbe7
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test2_main.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int bar();
+
+void foo(void)
+{
+    throw std::runtime_error("OK: Throw in main, catch in lib!");
+}
+
+int main(void)
+{
+    return bar();
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test3_bar.cpp b/tests/device/test-gnustl_shared-exception/jni/test3_bar.cpp
new file mode 100644
index 0000000..8494697
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test3_bar.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+void bar(void)
+{
+    throw std::runtime_error("OK: Throw in lib2, catch in exec!");
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test3_foo.cpp b/tests/device/test-gnustl_shared-exception/jni/test3_foo.cpp
new file mode 100644
index 0000000..f074f80
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test3_foo.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void bar(void);
+
+void foo(void)
+{
+   bar();
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test3_main.cpp b/tests/device/test-gnustl_shared-exception/jni/test3_main.cpp
new file mode 100644
index 0000000..1b9df17
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test3_main.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void foo();
+
+int main(void)
+{
+    try {
+        foo();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test4_bar.cpp b/tests/device/test-gnustl_shared-exception/jni/test4_bar.cpp
new file mode 100644
index 0000000..a93fe8b
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test4_bar.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+void bar(void)
+{
+    throw std::runtime_error("OK: Throw in lib2, catch in lib1!");
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test4_foo.cpp b/tests/device/test-gnustl_shared-exception/jni/test4_foo.cpp
new file mode 100644
index 0000000..f9a80e7
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test4_foo.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int bar(void);
+
+int foo(void)
+{
+    try {
+        bar();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_shared-exception/jni/test4_main.cpp b/tests/device/test-gnustl_shared-exception/jni/test4_main.cpp
new file mode 100644
index 0000000..8f31137
--- /dev/null
+++ b/tests/device/test-gnustl_shared-exception/jni/test4_main.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int foo();
+
+int main(void)
+{
+    return foo();
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/Android.mk b/tests/device/test-gnustl_static-exception/jni/Android.mk
new file mode 100644
index 0000000..4bc3a7b
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/Android.mk
@@ -0,0 +1,87 @@
+LOCAL_PATH := $(call my-dir)
+
+# Test -1: Throw in exec, catch in exec covered elsewhere
+
+# Test 0: Throw in lib, catch in lib
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test0_foo
+LOCAL_SRC_FILES := test0_foo.cpp
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Lib_catching_lib_throwing
+LOCAL_SRC_FILES := test0_main.cpp
+LOCAL_STATIC_LIBRARIES := test0_foo
+include $(BUILD_EXECUTABLE)
+
+# Test 1: Throw in lib, catch in exec
+include $(CLEAR_VARS)
+LOCAL_MODULE := test1_foo
+LOCAL_SRC_FILES := test1_foo.cpp
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := exec_catching_lib_throwing
+LOCAL_SRC_FILES := test1_main.cpp
+LOCAL_STATIC_LIBRARIES := test1_foo
+include $(BUILD_EXECUTABLE)
+
+# Test 2: Throw in exec, catch in lib
+# Note: Symbol lookup from lib at exec fixed in bionic after android-14
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test2_foo
+LOCAL_SRC_FILES := test2_foo.cpp
+# This is required to rely on dynamic loader to resolve foo defined in exec
+LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := exec_throwing_lib_catching
+LOCAL_SRC_FILES := test2_main.cpp
+LOCAL_STATIC_LIBRARIES := test2_foo
+include $(BUILD_EXECUTABLE)
+
+#
+# 3 libs cases
+#
+
+# Test 3: Throw in lib2, catch in exec
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test3_bar
+LOCAL_SRC_FILES := test3_bar.cpp
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test3_foo
+LOCAL_SRC_FILES := test3_foo.cpp
+LOCAL_STATIC_LIBRARIES := test3_bar
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := exec_catching_lib2_throwing
+LOCAL_SRC_FILES := test3_main.cpp
+LOCAL_STATIC_LIBRARIES := test3_foo test3_bar
+include $(BUILD_EXECUTABLE)
+
+# Test 4: Throw in lib2, catch in lib1
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test4_bar
+LOCAL_SRC_FILES := test4_bar.cpp
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := test4_foo
+LOCAL_SRC_FILES := test4_foo.cpp
+LOCAL_STATIC_LIBRARIES := test4_bar
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := Lib1_catching_lib2_throwing
+LOCAL_SRC_FILES := test4_main.cpp
+LOCAL_STATIC_LIBRARIES := test4_foo test4_bar
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/device/test-gnustl_static-exception/jni/Application.mk b/tests/device/test-gnustl_static-exception/jni/Application.mk
new file mode 100644
index 0000000..367ac00
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/Application.mk
@@ -0,0 +1,3 @@
+APP_ABI := all
+APP_STL := gnustl_static
+APP_CPPFLAGS := -fexceptions
diff --git a/tests/device/test-gnustl_static-exception/jni/test0_foo.cpp b/tests/device/test-gnustl_static-exception/jni/test0_foo.cpp
new file mode 100644
index 0000000..7c7b83a
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test0_foo.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+int foo(void)
+{
+    try {
+        throw std::runtime_error("OK: Throw in lib, catch in lib!");
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test0_main.cpp b/tests/device/test-gnustl_static-exception/jni/test0_main.cpp
new file mode 100644
index 0000000..8f31137
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test0_main.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int foo();
+
+int main(void)
+{
+    return foo();
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test1_foo.cpp b/tests/device/test-gnustl_static-exception/jni/test1_foo.cpp
new file mode 100644
index 0000000..a1966bb
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test1_foo.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+void foo(void)
+{
+    throw std::runtime_error("OK: Throw in lib, catch in exec!");
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test1_main.cpp b/tests/device/test-gnustl_static-exception/jni/test1_main.cpp
new file mode 100644
index 0000000..1b9df17
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test1_main.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void foo();
+
+int main(void)
+{
+    try {
+        foo();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test2_foo.cpp b/tests/device/test-gnustl_static-exception/jni/test2_foo.cpp
new file mode 100644
index 0000000..913adaf
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test2_foo.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void foo();
+
+extern int bar(void)
+{
+    try {
+        foo();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test2_main.cpp b/tests/device/test-gnustl_static-exception/jni/test2_main.cpp
new file mode 100644
index 0000000..4eebbe7
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test2_main.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int bar();
+
+void foo(void)
+{
+    throw std::runtime_error("OK: Throw in main, catch in lib!");
+}
+
+int main(void)
+{
+    return bar();
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test3_bar.cpp b/tests/device/test-gnustl_static-exception/jni/test3_bar.cpp
new file mode 100644
index 0000000..8494697
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test3_bar.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+void bar(void)
+{
+    throw std::runtime_error("OK: Throw in lib2, catch in exec!");
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test3_foo.cpp b/tests/device/test-gnustl_static-exception/jni/test3_foo.cpp
new file mode 100644
index 0000000..f074f80
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test3_foo.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void bar(void);
+
+void foo(void)
+{
+   bar();
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test3_main.cpp b/tests/device/test-gnustl_static-exception/jni/test3_main.cpp
new file mode 100644
index 0000000..1b9df17
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test3_main.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern void foo();
+
+int main(void)
+{
+    try {
+        foo();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test4_bar.cpp b/tests/device/test-gnustl_static-exception/jni/test4_bar.cpp
new file mode 100644
index 0000000..a93fe8b
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test4_bar.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+void bar(void)
+{
+    throw std::runtime_error("OK: Throw in lib2, catch in lib1!");
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test4_foo.cpp b/tests/device/test-gnustl_static-exception/jni/test4_foo.cpp
new file mode 100644
index 0000000..f9a80e7
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test4_foo.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int bar(void);
+
+int foo(void)
+{
+    try {
+        bar();
+        std::printf("KO: Exception was not thrown!\n");
+        return 1;
+    }
+    catch (std::exception &ex)
+    {
+        std::printf("%s\n", ex.what());
+    }
+    return 0;
+}
diff --git a/tests/device/test-gnustl_static-exception/jni/test4_main.cpp b/tests/device/test-gnustl_static-exception/jni/test4_main.cpp
new file mode 100644
index 0000000..8f31137
--- /dev/null
+++ b/tests/device/test-gnustl_static-exception/jni/test4_main.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+#include <stdexcept>
+#include <cstdlib>
+#include <cstdio>
+
+extern int foo();
+
+int main(void)
+{
+    return foo();
+}