aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/elf_test.py
blob: dca7bc59f9917dcf3ec8c697571769e0d06de016 (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
#
# Copyright (c) 2017 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
# SPDX-License-Identifier:      GPL-2.0+
#
# Test for the elf module

import os
import sys
import unittest

import elf

binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
fname = os.path.join(binman_dir, 'test', 'u_boot_ucode_ptr')

class TestElf(unittest.TestCase):
    def testAllSymbols(self):
        syms = elf.GetSymbols(fname, [])
        self.assertIn('.ucode', syms)

    def testRegexSymbols(self):
        syms = elf.GetSymbols(fname, ['ucode'])
        self.assertIn('.ucode', syms)
        syms = elf.GetSymbols(fname, ['missing'])
        self.assertNotIn('.ucode', syms)
        syms = elf.GetSymbols(fname, ['missing', 'ucode'])
        self.assertIn('.ucode', syms)

if __name__ == '__main__':
    unittest.main()