2012-03-10 05:41:24 +01:00
|
|
|
import os.path
|
2019-01-03 15:11:41 +01:00
|
|
|
import sys
|
2012-03-10 05:41:24 +01:00
|
|
|
import unittest
|
|
|
|
|
2019-01-03 15:11:41 +01:00
|
|
|
|
2012-03-10 05:41:24 +01:00
|
|
|
POSSIBLE_TEST_BINARIES = [
|
|
|
|
'libreadline.so.5',
|
|
|
|
'libreadline.so.6',
|
|
|
|
]
|
|
|
|
|
|
|
|
POSSIBLE_TEST_BINARY_PATHS = [
|
2012-03-21 09:34:58 +01:00
|
|
|
'/usr/lib/debug',
|
2012-03-10 05:41:24 +01:00
|
|
|
'/lib',
|
|
|
|
'/usr/lib',
|
|
|
|
'/usr/local/lib',
|
2012-03-21 09:34:58 +01:00
|
|
|
'/lib/i386-linux-gnu',
|
2012-03-10 05:41:24 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
class TestBase(unittest.TestCase):
|
2019-01-03 15:11:41 +01:00
|
|
|
if sys.version_info.major == 2:
|
|
|
|
assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
|
|
|
2012-03-10 05:41:24 +01:00
|
|
|
def get_test_binary(self):
|
|
|
|
"""Helper to obtain a test binary for object file testing.
|
|
|
|
|
|
|
|
FIXME Support additional, highly-likely targets or create one
|
|
|
|
ourselves.
|
|
|
|
"""
|
|
|
|
for d in POSSIBLE_TEST_BINARY_PATHS:
|
|
|
|
for lib in POSSIBLE_TEST_BINARIES:
|
|
|
|
path = os.path.join(d, lib)
|
|
|
|
|
|
|
|
if os.path.exists(path):
|
|
|
|
return path
|
|
|
|
|
|
|
|
raise Exception('No suitable test binaries available!')
|
2012-03-21 09:18:19 +01:00
|
|
|
get_test_binary.__test__ = False
|
2013-09-10 08:57:57 +02:00
|
|
|
|
|
|
|
def get_test_file(self):
|
|
|
|
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_file")
|
2013-09-11 02:23:14 +02:00
|
|
|
|
|
|
|
def get_test_bc(self):
|
|
|
|
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "test.bc")
|