b35d98
From 888f4a58a82e2d265fc95907492a24c95978e605 Mon Sep 17 00:00:00 2001
b35d98
From: Jakub Filak <jfilak@redhat.com>
b35d98
Date: Fri, 17 Jan 2014 14:20:51 +0100
b35d98
Subject: [PATCH 25/39] Update the missing class test
b35d98
b35d98
The ClassNotFound exception which is thrown in case of a not existing
b35d98
main class file is caught by Java Native Interface and java process
b35d98
exits gracefully with an error message:
b35d98
b35d98
Error: Could not find or load main class MissingClassTest
b35d98
b35d98
It doesn't make sense to report such exceptions because this exception
b35d98
would be reported every time when someone run "java foo" where 'foo'
b35d98
does not exist.
b35d98
b35d98
Just for the record, ABRT doesn't detect the similar problem in python.
b35d98
b35d98
$ python foo
b35d98
python: can't open file 'foo': [Errno 2] No such file or directory
b35d98
b35d98
Related to rhbz#1051198
b35d98
---
b35d98
 test/CMakeLists.txt                        | 20 ++++++++++++++------
b35d98
 test/outputs/run_missing_class_test.log.in | 10 ----------
b35d98
 2 files changed, 14 insertions(+), 16 deletions(-)
b35d98
 delete mode 100644 test/outputs/run_missing_class_test.log.in
b35d98
b35d98
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
b35d98
index 5267e7b..1a851e6 100644
b35d98
--- a/test/CMakeLists.txt
b35d98
+++ b/test/CMakeLists.txt
b35d98
@@ -171,14 +171,22 @@ _add_test_target(
b35d98
 )
b35d98
 _add_test(run_bad_class 2)
b35d98
 
b35d98
-_add_test_target(
b35d98
+# Disabled because JVM catches the ClassNotFoundException in a native method and exits gracefully
b35d98
+#_add_test_target(
b35d98
+#    run_missing_class_test
b35d98
+#    MissingClassTest
b35d98
+#    PRE rm -f MissingClassTest.class
b35d98
+#    DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
b35d98
+#    AGENT_OPTIONS executable=threadclass
b35d98
+#)
b35d98
+#_add_test(run_missing_class_test 2)
b35d98
+add_custom_target(
b35d98
     run_missing_class_test
b35d98
-    MissingClassTest
b35d98
-    PRE rm -f MissingClassTest.class
b35d98
-    DEPENDS ${TEST_JAVA_TARGETS} ${JAR_TEST_PATH}
b35d98
-    AGENT_OPTIONS executable=threadclass
b35d98
+    COMMAND rm -f MissingClassTest.class && LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src ${Java_JAVA_EXECUTABLE} -agentlib:${AGENT_NAME}=output=run_missing_class.log MissingClassTest || test ! -e run_missing_class.log
b35d98
+    DEPENDS AbrtChecker ${TEST_JAVA_TARGETS}
b35d98
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
b35d98
 )
b35d98
-_add_test(run_missing_class_test 2)
b35d98
+add_test(test_run_missing_class_test make run_missing_class_test)
b35d98
 
b35d98
 _add_test_target(
b35d98
     run_try_finally
b35d98
diff --git a/test/outputs/run_missing_class_test.log.in b/test/outputs/run_missing_class_test.log.in
b35d98
deleted file mode 100644
b35d98
index ea3dc25..0000000
b35d98
--- a/test/outputs/run_missing_class_test.log.in
b35d98
+++ /dev/null
b35d98
@@ -1,10 +0,0 @@
b35d98
-Uncaught exception java.lang.ClassNotFoundException in method java.lang.ClassLoader.loadClass()
b35d98
-Exception in thread "main" java.lang.ClassNotFoundException: MissingClassTest
b35d98
-	at java.net.URLClassLoader$1.run(URLClassLoader.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/net/URLClassLoader$1.class]
b35d98
-	at java.net.URLClassLoader$1.run(URLClassLoader.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/net/URLClassLoader$1.class]
b35d98
-	at java.security.AccessController.doPrivileged(Native Method) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/security/AccessController.class]
b35d98
-	at java.net.URLClassLoader.findClass(URLClassLoader.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/net/URLClassLoader.class]
b35d98
-	at java.lang.ClassLoader.loadClass(ClassLoader.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/lang/ClassLoader.class]
b35d98
-	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/sun/misc/Launcher$AppClassLoader.class]
b35d98
-	at java.lang.ClassLoader.loadClass(ClassLoader.java:LINENO) [jar:file:JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar!/java/lang/ClassLoader.class]
b35d98
-executable: JAVA_AND_SYSTEM_SPECIFIC_PATH/rt.jar
b35d98
-- 
b35d98
1.8.3.1
b35d98