Skip to content

Commit 0318d13

Browse files
committed
Add mock-ups and improve regression
1 parent 0d79f78 commit 0318d13

File tree

7 files changed

+50
-13
lines changed

7 files changed

+50
-13
lines changed

examples/projects/regress.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
#
4+
# Copyright (C) 2024-2025 PyFPGA Project
5+
#
6+
# SPDX-License-Identifier: GPL-3.0-or-later
7+
#
8+
39
set -e
410

511
declare -A TOOLS
@@ -44,9 +50,9 @@ for TOOL in "${!TOOLS[@]}"; do
4450
fi
4551
echo "> $TOOL - $BOARD - $SOURCE"
4652
if [[ "$NOTOOL" == true ]]; then
47-
python3 $TOOL.py --board $BOARD --source $SOURCE --notool
53+
python3 $TOOL.py --board $BOARD --source $SOURCE --action all --notool
4854
else
49-
python3 $TOOL.py --board $BOARD --source $SOURCE
55+
python3 $TOOL.py --board $BOARD --source $SOURCE --action all
5056
fi
5157
done
5258
done

pyfpga/templates/diamond-prog.jinja

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
{#
2-
# Copyright (C) 2024 PyFPGA Project
2+
# Copyright (C) 2024-2025 PyFPGA Project
33
#
44
# SPDX-License-Identifier: GPL-3.0-or-later
55
#
66
#}
77

88
if [ "$DIAMOND_XCF" == "" ]; then
9-
DIAMOND_XCF=impl1/impl1.xcf
9+
DIAMOND_XCF=impl1/impl1.xcf
1010
fi
1111

1212
if [ -f "$DIAMOND_XCF" ]; then
13-
pgrcmd -infile $DIAMOND_XCF
13+
pgrcmd -infile $DIAMOND_XCF
1414
else
15-
echo "ERROR: Automatic programming with Diamond is not yet supported."
16-
echo " Please create the `realpath $DIAMOND_XCF` file manually and rerun the prog command."
17-
echo " Hint: You can change the location of the XCF file by setting the DIAMOND_XCF environment variable."
18-
exit 1
15+
echo "Automatic programming with Diamond is not yet supported."
16+
echo "Please create the `realpath $DIAMOND_XCF` file manually and rerun the prog command."
17+
echo "Hint: You can change the location of the XCF file by setting the DIAMOND_XCF environment variable."
1918
fi

pyfpga/templates/quartus-prog.jinja

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{#
22
#
3-
# Copyright (C) 2015-2024 PyFPGA Project
3+
# Copyright (C) 2015-2025 PyFPGA Project
44
#
55
# SPDX-License-Identifier: GPL-3.0-or-later
66
#
@@ -9,7 +9,6 @@
99
RESULT=$(jtagconfig)
1010
echo "$RESULT"
1111

12-
# cable = re.match(r"1\) (.*) \[", result).groups()[0]
1312
CABLE=$(echo "$RESULT" | awk -F '1\\) | \\[' '/1\)/ {print $2}')
1413

1514
quartus_pgm -c $CABLE --mode jtag -o "p;{{ bitstream }}@{{ position }}"

tests/mocks/diamondc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env python3
22

33
#
4-
# Copyright (C) 2024 PyFPGA Project
4+
# Copyright (C) 2024-2025 PyFPGA Project
55
#
66
# SPDX-License-Identifier: GPL-3.0-or-later
77
#
88

99
import argparse
10+
import re
1011
import subprocess
1112

1213

@@ -34,4 +35,12 @@ subprocess.run(
3435
universal_newlines=True
3536
)
3637

38+
pattern = r'prj_project\s+new\s+-name\s+(\S+)\s'
39+
with open(args.source, 'r', encoding='utf-8') as file:
40+
match = re.search(pattern, file.read())
41+
if match:
42+
project = match.group(1)
43+
with open(f'{project}.bit', 'w', encoding='utf-8') as file:
44+
pass
45+
3746
print(f'INFO:the {tool.upper()} mock has been executed')

tests/mocks/docker

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
3+
#
4+
# Copyright (C) 2025 PyFPGA Project
5+
#
6+
# SPDX-License-Identifier: GPL-3.0-or-later
7+
#
8+
9+
with open('openflow.bit', 'w', encoding='utf-8') as file:
10+
pass
11+
with open('openflow.svf', 'w', encoding='utf-8') as file:
12+
pass
13+
14+
print('INFO:the DOCKER mock has been executed')

tests/mocks/jtagconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python3
2+
3+
#
4+
# Copyright (C) 2025 PyFPGA Project
5+
#
6+
# SPDX-License-Identifier: GPL-3.0-or-later
7+
#
8+
9+
print('1) USB-Blaster [USB-0]')
10+
print(' 02D120DD EP4CE22')

tests/mocks/source-me.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
MDIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
44

5-
export PATH=$PATH:$MDIR
5+
export PATH=$MDIR:$PATH

0 commit comments

Comments
 (0)