Back to index

apport  2.4
Public Member Functions | Public Attributes | Private Member Functions
test_java_crashes.T Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_crash_class
def test_crash_jar

Public Attributes

 srcdir
 orig_report_dir
 crash_jar_path
 apport_jar_path

Private Member Functions

def _check_crash_report

Detailed Description

Definition at line 15 of file test_java_crashes.py.


Member Function Documentation

def test_java_crashes.T._check_crash_report (   self,
  main_file 
) [private]
Check that we have one crash report, and verify its contents

Definition at line 62 of file test_java_crashes.py.

00062 
00063     def _check_crash_report(self, main_file):
00064         '''Check that we have one crash report, and verify its contents'''
00065 
00066         reports = apport.fileutils.get_new_reports()
00067         self.assertEqual(len(reports), 1, 'did not create a crash report')
00068         r = apport.Report()
00069         with open(reports[0], 'rb') as f:
00070             r.load(f)
00071         self.assertEqual(r['ProblemType'], 'Crash')
00072         self.assertTrue(r['ProcCmdline'].startswith('java -classpath'), r)
00073         self.assertTrue(r['StackTrace'].startswith(
00074             "java.lang.RuntimeException: Can't catch this"))
00075         if '.jar!' in main_file:
00076             self.assertEqual(r['MainClassUrl'], 'jar:file:' + main_file)
00077         else:
00078             self.assertEqual(r['MainClassUrl'], 'file:' + main_file)
00079         self.assertTrue('DistroRelease' in r)
00080         self.assertTrue('ProcCwd' in r)
00081 
00082 #
00083 # main
00084 #
00085 
try:

Here is the call graph for this function:

Here is the caller graph for this function:

def test_java_crashes.T.setUp (   self)

Definition at line 16 of file test_java_crashes.py.

00016 
00017     def setUp(self):
00018         mydir = os.path.dirname(os.path.realpath(sys.argv[0]))
00019         datadir = os.environ.get('APPORT_DATA_DIR', '/usr/share/apport')
00020         self.srcdir = os.path.dirname(mydir)
00021         self.orig_report_dir = apport.fileutils.report_dir
00022         apport.fileutils.report_dir = tempfile.mkdtemp()
00023         os.environ['APPORT_REPORT_DIR'] = apport.fileutils.report_dir
00024         os.environ['APPORT_JAVA_EXCEPTION_HANDLER'] = os.path.join(
00025             datadir, 'java_uncaught_exception')
00026         if os.environ.get('APPORT_TEST_LOCAL'):
00027             self.crash_jar_path = os.path.join(self.srcdir, 'java', 'crash.jar')
00028             self.apport_jar_path = os.path.join(self.srcdir, 'java', 'apport.jar')
00029         else:
00030             self.crash_jar_path = os.path.join(mydir, 'crash.jar')
00031             self.apport_jar_path = os.path.join(datadir, 'apport.jar')

Definition at line 32 of file test_java_crashes.py.

00032 
00033     def tearDown(self):
00034         shutil.rmtree(apport.fileutils.report_dir)
00035         apport.fileutils.report_dir = self.orig_report_dir

Crash in a .class file

Definition at line 36 of file test_java_crashes.py.

00036 
00037     def test_crash_class(self):
00038         '''Crash in a .class file'''
00039 
00040         p = subprocess.Popen(['java', '-classpath',
00041                               self.apport_jar_path + ':' + os.path.dirname(self.crash_jar_path), 'crash'],
00042                              stdout=subprocess.PIPE, stderr=subprocess.PIPE)
00043         (out, err) = p.communicate()
00044         self.assertNotEqual(p.returncode, 0, 'crash must exit with nonzero code')
00045         self.assertTrue(b"Can't catch this" in err,
00046                         'crash handler must print original exception:\n' + err.decode())
00047 
00048         self._check_crash_report(os.path.dirname(self.crash_jar_path) + '/crash.class')

Here is the call graph for this function:

Crash in a .jar file

Definition at line 49 of file test_java_crashes.py.

00049 
00050     def test_crash_jar(self):
00051         '''Crash in a .jar file'''
00052 
00053         p = subprocess.Popen(['java', '-classpath',
00054                               self.apport_jar_path + ':' + self.crash_jar_path, 'crash'],
00055                              stdout=subprocess.PIPE, stderr=subprocess.PIPE)
00056         (out, err) = p.communicate()
00057         self.assertNotEqual(p.returncode, 0, 'crash must exit with nonzero code')
00058         self.assertTrue(b"Can't catch this" in err,
00059                         'crash handler must print original exception:\n' + err.decode())
00060 
00061         self._check_crash_report(self.crash_jar_path + '!/crash.class')

Here is the call graph for this function:


Member Data Documentation

Definition at line 27 of file test_java_crashes.py.

Definition at line 26 of file test_java_crashes.py.

Definition at line 20 of file test_java_crashes.py.

Definition at line 19 of file test_java_crashes.py.


The documentation for this class was generated from the following file: