From c11acce7e2786ab8105c02318592713e51e7991c Mon Sep 17 00:00:00 2001 From: Jakub Filak Date: Sat, 18 Jan 2014 00:06:47 +0100 Subject: [PATCH 33/39] Add test for analysis tool Related to #29 Related to rhbz#1054737 --- test/CMakeLists.txt | 8 ++++++++ test/analysis_testdriver | 19 +++++++++++++++++++ .../backtrace_not_reportable_1remote_class.log.in | 5 +++++ .../backtrace_not_reportable_3remote_classes.log.in | 5 +++++ test/outputs/not_reportable_1remote_class.log.in | 1 + test/outputs/not_reportable_3remote_classes.log.in | 1 + 6 files changed, 39 insertions(+) create mode 100644 test/analysis_testdriver create mode 100644 test/outputs/backtrace_not_reportable_1remote_class.log.in create mode 100644 test/outputs/backtrace_not_reportable_3remote_classes.log.in create mode 100644 test/outputs/not_reportable_1remote_class.log.in create mode 100644 test/outputs/not_reportable_3remote_classes.log.in diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1a851e6..0439294 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,5 @@ +project(test) + set(HTTP_DIR "/var/www/html") set(SERVER_URL "http://localhost") @@ -114,6 +116,10 @@ function(_add_test target_name expected_exit_code) add_test(test_${target_name} /bin/sh ${CMAKE_CURRENT_SOURCE_DIR}/testdriver ${target_name} ${expected_exit_code} ${CMAKE_CURRENT_BINARY_DIR}/outputs/${target_name}.log ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.log ${ARGN}) endfunction() +function(_add_analyze_test target_name) + add_test(test_${target_name} /bin/sh ${CMAKE_CURRENT_SOURCE_DIR}/analysis_testdriver ${CMAKE_BINARY_DIR}/utils ${test_BINARY_DIR}/outputs/backtrace_${target_name}.log ${test_BINARY_DIR}/${target_name}.log ${test_BINARY_DIR}/outputs/${target_name}.log) +endfunction() + _add_test_target( run SimpleTest @@ -308,6 +314,8 @@ _add_test_target( ) _add_test(run_remote_thread 0) +_add_analyze_test(not_reportable_1remote_class) +_add_analyze_test(not_reportable_3remote_classes) get_directory_property(all_run_targets ALL_RUN_TARGETS) add_custom_target(run_all DEPENDS ${all_run_targets}) diff --git a/test/analysis_testdriver b/test/analysis_testdriver new file mode 100644 index 0000000..3888b6c --- /dev/null +++ b/test/analysis_testdriver @@ -0,0 +1,19 @@ +#!/bin/sh +# Help: +# $1 - path to analysis tool +# $2 - path to input file +# $3 - path to output log file +# $4 - path to expected output log file +# + +$1/abrt-action-analyze-java -f $2 -o > $3 || exit 1 + +diff -u $4 $3 +EC=$? + +if [ 0 -ne $EC ]; then + echo "Expected $4 differs from result $3" + exit 1 +fi + +exit 0 diff --git a/test/outputs/backtrace_not_reportable_1remote_class.log.in b/test/outputs/backtrace_not_reportable_1remote_class.log.in new file mode 100644 index 0000000..5555da5 --- /dev/null +++ b/test/outputs/backtrace_not_reportable_1remote_class.log.in @@ -0,0 +1,5 @@ +Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: 42 +>---at SimpleTest.throwIndexOutOfBoundsException(SimpleTest.java:24) [jar:http://localhost:54321/JarTest.jar!/SimpleTest.class] +>---at SimpleTest.catchIndexOutOfBoundsException(SimpleTest.java:47) [jar:http://localhost:54321/JarTest.jar!/SimpleTest.class] +>---at SimpleTest.throwAndCatchAllExceptions(SimpleTest.java:61) [jar:http://localhost:54321/JarTest.jar!/SimpleTest.class] +>---at ThreadCaughtException.run(ThreadCaughtException.java:7) [jar:http://localhost:54321/JarTest.jar!/ThreadCaughtException.class] diff --git a/test/outputs/backtrace_not_reportable_3remote_classes.log.in b/test/outputs/backtrace_not_reportable_3remote_classes.log.in new file mode 100644 index 0000000..77fb989 --- /dev/null +++ b/test/outputs/backtrace_not_reportable_3remote_classes.log.in @@ -0,0 +1,5 @@ +Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBoundsException: 42 +>---at SimpleTest.throwIndexOutOfBoundsException(SimpleTest.java:24) [jar:http://localhost:54321/JarTest.jar!/SimpleTest.class] +>---at SimpleTest.catchIndexOutOfBoundsException(SimpleTest.java:47) [jar:http://localhost:321/JarTest.jar!/SimpleTest.class] +>---at SimpleTest.throwAndCatchAllExceptions(SimpleTest.java:61) [jar:http://localhost:4321/JarTest.jar!/SimpleTest.class] +>---at ThreadCaughtException.run(ThreadCaughtException.java:7) [jar:http://localhost:54321/JarTest.jar!/ThreadCaughtException.class] diff --git a/test/outputs/not_reportable_1remote_class.log.in b/test/outputs/not_reportable_1remote_class.log.in new file mode 100644 index 0000000..282933a --- /dev/null +++ b/test/outputs/not_reportable_1remote_class.log.in @@ -0,0 +1 @@ +This problem can be caused by a 3rd party code from the jar/class at http://localhost:54321/JarTest.jar. In order to provide valuable problem reports, ABRT will not allow you to submit this problem. If you still want to participate in solving this problem, please contact the developers directly. diff --git a/test/outputs/not_reportable_3remote_classes.log.in b/test/outputs/not_reportable_3remote_classes.log.in new file mode 100644 index 0000000..7489f74 --- /dev/null +++ b/test/outputs/not_reportable_3remote_classes.log.in @@ -0,0 +1 @@ +This problem can be caused by a 3rd party code from the jar/class at http://localhost:54321/JarTest.jar, http://localhost:321/JarTest.jar, http://localhost:4321/JarTest.jar. In order to provide valuable problem reports, ABRT will not allow you to submit this problem. If you still want to participate in solving this problem, please contact the developers directly. -- 1.8.3.1