Browse Source
More tests, who likes debugging regexps by hand/eye? Signed-off-by: Karl Palsson <karlp@tweak.au>pull/1526/head
Karl Palsson
10 months ago
3 changed files with 196 additions and 0 deletions
@ -0,0 +1,51 @@ |
|||
#!/usr/bin/env python3 |
|||
""" |
|||
Runs the linker script generator portion against a csv of "correct" device properties to check for regexp madness. |
|||
""" |
|||
|
|||
import argparse |
|||
import csv |
|||
import dataclasses |
|||
|
|||
import genlink |
|||
|
|||
|
|||
@dataclasses.dataclass |
|||
class InputDevice: |
|||
name: str |
|||
ram: str |
|||
flash: str |
|||
|
|||
|
|||
def domain(opts): |
|||
fi = csv.DictReader(filter(lambda row: row[0]!='#', opts.input)) |
|||
idevs = [InputDevice(name=row['name'], ram=row['ram'], flash=row['flash']) for row in fi] |
|||
good_count = 0 |
|||
for idev in idevs: |
|||
print(f"checking: {idev.name}") |
|||
x = genlink.get_device_data(opts.devices_data, idev.name, exit_on_fail=False) |
|||
if not x: |
|||
print(f"Failed to match: {idev.name}") |
|||
continue |
|||
xram: str = [lol for lol in x["defs"] if lol[0] == "RAM"][0][1] |
|||
xrom: str = [lol for lol in x["defs"] if lol[0] == "ROM"][0][1] |
|||
assert(xram.lower() == idev.ram.lower()) |
|||
assert(xrom.lower() == idev.flash.lower()) |
|||
good_count += 1 |
|||
print(f"Validated {idev.name} with flash: {idev.flash} and ram: {idev.name}") |
|||
|
|||
assert(good_count == len(idevs)) |
|||
|
|||
|
|||
def get_parser(): |
|||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
|||
parser.add_argument("-d", "--devices_data", help="devices.data file to check against", required=True) |
|||
parser.add_argument("-i", "--input", help="csv input file to check against", type=argparse.FileType('r'), required=True) |
|||
return parser |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
p = get_parser() |
|||
opts = p.parse_args() |
|||
domain(opts) |
|||
|
@ -0,0 +1,37 @@ |
|||
#!/usr/bin/env python3 |
|||
""" |
|||
Generates a sample data csv file that can be used to test regexps for the `compare-real-csv.py` script |
|||
""" |
|||
|
|||
|
|||
def stm32g01(): |
|||
""" |
|||
Typed in by inspection of the chart on https://www.st.com/en/microcontrollers-microprocessors/stm32g0x1.html |
|||
on 2024-01-17 |
|||
""" |
|||
for package in ['j', 'f', 'g', 'k', 'c']: |
|||
print(f"stm32g031{package}4,16k,8k") |
|||
print(f"stm32g031{package}6,32k,8k") |
|||
print(f"stm32g041{package}6,32k,8k") |
|||
for package in ['f', 'g', 'k', 'c']: |
|||
print(f"stm32g051{package}6,32k,18k") |
|||
print(f"stm32g061{package}6,32k,18k") |
|||
for package in ['f', 'g', 'k', 'c', 'y']: |
|||
print(f"stm32g031{package}8,64k,8k") |
|||
print(f"stm32g041{package}8,64k,8k") |
|||
print(f"stm32g051{package}8,64k,18k") |
|||
print(f"stm32g061{package}8,64k,18k") |
|||
for package in ['g', 'k', 'c', 'r']: |
|||
print(f"stm32g071{package}8,64k,36k") |
|||
for package in ['g', 'k', 'c', 'r', 'e']: |
|||
print(f"stm32g071{package}b,128k,36k") |
|||
print(f"stm32g081{package}b,128k,36k") |
|||
for package in ['k', 'c', 'r', 'm', 'v']: |
|||
print(f"stm32g0b1{package}b,128k,144k") |
|||
print(f"stm32g0b1{package}c,256k,144k") |
|||
print(f"stm32g0c1{package}c,256k,144k") |
|||
for package in ['k', 'c', 'r', 'm', 'v', 'n']: |
|||
print(f"stm32g0b1{package}e,512k,144k") |
|||
print(f"stm32g0c1{package}e,512k,144k") |
|||
|
|||
stm32g01() |
Can't render this file because it has a wrong number of fields in line 4.
|
Loading…
Reference in new issue