summaryrefslogtreecommitdiff
path: root/bindings/python/llvm/tests/base.py
blob: 194f1a41192bfd5d09095e8745f5b8d622007a2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os.path
import unittest

POSSIBLE_TEST_BINARIES = [
    'libreadline.so.5',
    'libreadline.so.6',
]

POSSIBLE_TEST_BINARY_PATHS = [
    '/usr/lib/debug',
    '/lib',
    '/usr/lib',
    '/usr/local/lib',
    '/lib/i386-linux-gnu',
]

class TestBase(unittest.TestCase):
    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!')
    get_test_binary.__test__ = False

    def get_test_file(self):
        return os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_file")

    def get_test_bc(self):
        return os.path.join(os.path.dirname(os.path.abspath(__file__)), "test.bc")