mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-06 21:25:02 +00:00
test(ldgen): add test for placements of symbols in prebuilt libraries
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Check placements in this test app for main
|
||||
@@ -8,13 +8,13 @@
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
from pyparsing import alphanums
|
||||
from pyparsing import hexnums
|
||||
from pyparsing import LineEnd
|
||||
from pyparsing import LineStart
|
||||
from pyparsing import Literal
|
||||
from pyparsing import Optional
|
||||
from pyparsing import Word
|
||||
from pyparsing import alphanums
|
||||
from pyparsing import hexnums
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
|
||||
@@ -29,13 +29,16 @@ contents = subprocess.check_output([args.objdump, '-t', args.elf]).decode()
|
||||
|
||||
|
||||
def check_location(symbol, expected):
|
||||
pattern = (LineStart() + Word(hexnums).setResultsName('address')
|
||||
+ Optional(Word(alphanums, exact=1))
|
||||
+ Optional(Word(alphanums,exact=1))
|
||||
+ Word(alphanums + '._*').setResultsName('actual')
|
||||
+ Word(hexnums)
|
||||
+ Literal(symbol)
|
||||
+ LineEnd())
|
||||
pattern = (
|
||||
LineStart()
|
||||
+ Word(hexnums).setResultsName('address')
|
||||
+ Optional(Word(alphanums, exact=1))
|
||||
+ Optional(Word(alphanums, exact=1))
|
||||
+ Word(alphanums + '._*').setResultsName('actual')
|
||||
+ Word(hexnums)
|
||||
+ Literal(symbol)
|
||||
+ LineEnd()
|
||||
)
|
||||
|
||||
try:
|
||||
results = pattern.searchString(contents)[0]
|
||||
@@ -43,7 +46,9 @@ def check_location(symbol, expected):
|
||||
raise Exception("check placement fail: '%s' was not found" % (symbol))
|
||||
|
||||
if results.actual != expected:
|
||||
raise Exception("check placement fail: '%s' was placed in '%s', not in '%s'" % (symbol, results.actual, expected))
|
||||
raise Exception(
|
||||
"check placement fail: '%s' was placed in '%s', not in '%s'" % (symbol, results.actual, expected)
|
||||
)
|
||||
|
||||
print("check placement pass: '%s' was successfully placed in '%s'" % (symbol, results.actual))
|
||||
return int(results.address, 16)
|
||||
@@ -82,3 +87,5 @@ check_location('func3', '.flash.text')
|
||||
check_location('func4', '.iram0.text')
|
||||
|
||||
check_location('const_array', '.dram0.data')
|
||||
|
||||
check_location('prebuilt_func', '.iram0.text')
|
||||
|
Reference in New Issue
Block a user