summaryrefslogtreecommitdiffstats
path: root/lib/oeqa/sdkmingw/cases/binutils.py
blob: fdd5a472a066f017f036de528e4005ec0594f491 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright 2018 by Garmin Ltd. or its subsidiaries
# Released under the MIT license (see COPYING.MIT)

import os
import unittest

from oeqa.sdkmingw.case import OESDKMinGWTestCase

class BinutilsTest(OESDKMinGWTestCase):
    td_vars = ['MACHINE']

    def setUp(self):
        super().setUp()

        self.copyTestFile(os.path.join(self.tc.files_dir, 'test.c'))

        machine = self.td.get("MACHINE")
        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
                self.tc.hasHostPackage("^gcc-", regex=True)):
            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain a cross-canadian toolchain")
        if not (self.tc.hasHostPackage("packagegroup-cross-canadian-%s" % machine) or
                self.tc.hasHostPackage('binutils-cross-canadian-%s' % machine)):
            raise unittest.SkipTest(self.__class__.__name__ + " class: SDK doesn't contain a binutils")

        self._run('%CC% -c -g test.c -o test.o')
        self._run('%CC% -o test test.o -lm')

    def test_strip(self):
        self._run('%STRIP% -s test')
        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))

    def test_ar(self):
        self._run('%AR% -rcs lib.a test.o')
        self._run('%CC% -o test lib.a -lm')
        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))

    def test_ranlib(self):
        self._run('%AR% -rc lib.a test.o')
        self._run('%RANLIB% lib.a')
        self._run('%CC% -o test lib.a -lm')
        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))

    def test_objcopy(self):
        self._run('%OBJCOPY% -g test.o test_no_debug.o')
        self.assertIsTargetElf(os.path.join(self.test_dir, 'test_no_debug.o'))
        self._run('%CC% -o test test_no_debug.o -lm')
        self.assertIsTargetElf(os.path.join(self.test_dir, 'test'))

    def test_objdump(self):
        self._run('%OBJDUMP% -S test.o')

    def test_nm(self):
        self._run('%NM% test.o')