def _build_fixtures(cls, target_name):
        target = cls.targets[target_name]

        cls.expected_dir = os.path.join(EXPECTED_DIR, target_name)
        cls.test_dir = os.path.join(cls.test_dir_base, target_name)

        makedirs(cls.test_dir, exist_ok=True)

        # Compile main.o.
        src_file = os.path.join(INPUT_DIR, 'main.c')
        obj_file = os.path.join(cls.test_dir, 'main.o')
        target.compile(obj_file, src_file, [])

        # Link main.out.
        out_file = os.path.join(cls.test_dir, 'main.out')
        target.link(out_file, [obj_file], ['-ldl', '-lc', '-lstdc++'])

        # Compile test.o.
        src_file = os.path.join(INPUT_DIR, 'test.c')
        obj_file = os.path.join(cls.test_dir, 'test.o')
        target.compile(obj_file, src_file, [])

        # Link libtest.so.
        out_file = os.path.join(cls.test_dir, 'libtest.so')
        target.link(out_file, [obj_file], ['-shared', '-lc'])

        # Link libtest-rpath.so.
        out_file = os.path.join(cls.test_dir, 'libtest-rpath.so')
        target.link(out_file, [obj_file], [
            '-shared', '-lc', '-Wl,-rpath,$ORIGIN/../lib',
            '-Wl,--disable-new-dtags'
        ])

        # Link libtest-rpath-multi.so.
        out_file = os.path.join(cls.test_dir, 'libtest-rpath-multi.so')
        target.link(out_file, [obj_file], [
            '-shared', '-lc', '-Wl,-rpath,/system/lib:/vendor/lib',
            '-Wl,--disable-new-dtags'
        ])

        # Link libtest-runpath.so.
        out_file = os.path.join(cls.test_dir, 'libtest-runpath.so')
        target.link(out_file, [obj_file], [
            '-shared', '-lc', '-Wl,-rpath,$ORIGIN/../lib',
            '-Wl,--enable-new-dtags'
        ])

        # Link libtest-runpath-multi.so.
        out_file = os.path.join(cls.test_dir, 'libtest-runpath-multi.so')
        target.link(out_file, [obj_file], [
            '-shared', '-lc', '-Wl,-rpath,/system/lib:/vendor/lib',
            '-Wl,--enable-new-dtags'
        ])
    def _build_fixtures(cls, target_name):
        target = cls.targets[target_name]

        cls.expected_dir = os.path.join(EXPECTED_DIR, target_name)
        cls.test_dir = os.path.join(cls.test_dir_base, target_name)

        makedirs(cls.test_dir, exist_ok=True)

        # Compile main.o.
        src_file = os.path.join(INPUT_DIR, 'main.c')
        obj_file = os.path.join(cls.test_dir, 'main.o')
        target.compile(obj_file, src_file, [])

        # Link main.out.
        out_file = os.path.join(cls.test_dir, 'main.out')
        target.link(out_file, [obj_file], ['-ldl', '-lc', '-lstdc++'])

        # Compile test.o.
        src_file = os.path.join(INPUT_DIR, 'test.c')
        obj_file = os.path.join(cls.test_dir, 'test.o')
        target.compile(obj_file, src_file, [])

        # Link libtest.so.
        out_file = os.path.join(cls.test_dir, 'libtest.so')
        target.link(out_file, [obj_file], ['-shared', '-lc'])

        # Link libtest-rpath.so.
        out_file = os.path.join(cls.test_dir, 'libtest-rpath.so')
        target.link(out_file, [obj_file],
                    ['-shared', '-lc', '-Wl,-rpath,$ORIGIN/../lib',
                     '-Wl,--disable-new-dtags'])

        # Link libtest-rpath-multi.so.
        out_file = os.path.join(cls.test_dir, 'libtest-rpath-multi.so')
        target.link(out_file, [obj_file],
                    ['-shared', '-lc', '-Wl,-rpath,/system/lib:/vendor/lib',
                     '-Wl,--disable-new-dtags'])

        # Link libtest-runpath.so.
        out_file = os.path.join(cls.test_dir, 'libtest-runpath.so')
        target.link(out_file, [obj_file],
                    ['-shared', '-lc', '-Wl,-rpath,$ORIGIN/../lib',
                     '-Wl,--enable-new-dtags'])

        # Link libtest-runpath-multi.so.
        out_file = os.path.join(cls.test_dir, 'libtest-runpath-multi.so')
        target.link(out_file, [obj_file],
                    ['-shared', '-lc', '-Wl,-rpath,/system/lib:/vendor/lib',
                     '-Wl,--enable-new-dtags'])
示例#3
0
 def _build_fixture(cls, path, content):
     makedirs(os.path.dirname(path), exist_ok=True)
     with open(path, 'w') as f:
         f.write(content)