Skip to content

Commit

Permalink
add tests with pytest
Browse files Browse the repository at this point in the history
Signed-off-by: Unai Martinez-Corral <[email protected]>
  • Loading branch information
umarcor committed Mar 20, 2022
1 parent 3cb6780 commit ae789de
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 42 deletions.
91 changes: 51 additions & 40 deletions .github/workflows/Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ jobs:
git push -u origin +HEAD:gh-pages
PYTHONPATH:
runs-on: ubuntu-latest
name: '🐍 PYTHONPATH'
env:
F4PGA_INSTALL_DIR: /opt/f4pga
strategy:
fail-fast: false

steps:

- name: '🧰 Checkout'
uses: actions/checkout@v2

- name: '🚧 Test pyF4PGA (PYTHONPATH)'
run: |
PYTHONPATH=$(pwd) python3 f4pga/__init__.py
PYTHONPATH=$(pwd) python3 f4pga/__init__.py -h
pyF4PGA:
runs-on: ubuntu-latest
name: '🐍 pyF4PGA'
Expand All @@ -75,46 +94,6 @@ jobs:
pip install --use-feature=in-tree-build .
cd ..
- name: '🚧 Test pyF4PGA (PYTHONPATH)'
run: |
PYTHONPATH=$(pwd) python3 f4pga/__init__.py
PYTHONPATH=$(pwd) python3 f4pga/__init__.py -h
- name: '🚦 Test Python wrappers'
run: |
. ./.github/scripts/activate.sh
for tool in place route synth write-fasm; do
echo "::group::Test f4pga-$tool"
"f4pga-$tool" || echo "Failing?"
echo "::endgroup::"
done;
- name: '🚦 Test shell wrappers with Python entrypoints'
run: |
. ./.github/scripts/activate.sh
for tool in \
symbiflow_generate_constraints \
symbiflow_pack \
symbiflow_place \
symbiflow_route \
symbiflow_synth \
symbiflow_write_bitstream \
symbiflow_write_fasm \
symbiflow_write_xml_rr_graph \
vpr_common \
symbiflow_analysis \
symbiflow_repack \
symbiflow_generate_bitstream \
symbiflow_generate_libfile \
ql_symbiflow \
; do
echo "::group::Test $tool"
"$tool" || echo "Failing?"
echo "::endgroup::"
done;
- name: '🚧 Test f4pga build'
run: |
. ./.github/scripts/activate.sh
Expand All @@ -127,3 +106,35 @@ jobs:
with:
name: arty_35-Bitstream
path: f4pga-examples/build/arty_35/top.bit


Wrappers:
runs-on: ubuntu-latest
name: '🐍 Python wrapper entrypoints'
env:
F4PGA_INSTALL_DIR: /opt/f4pga
strategy:
fail-fast: false

steps:

- name: '🧰 Checkout'
uses: actions/checkout@v2

- name: '🔧 Prepare environment'
run: ./.github/scripts/prepare_environment.sh

- name: '🐍 Install f4pga (pip)'
run: |
. ./.github/scripts/activate.sh
cd f4pga
pip install --use-feature=in-tree-build .
cd ..
- name: '🚧 Test Python wrapper entrypoints'
run: |
. ./.github/scripts/activate.sh
pip3 install -r ./test/requirements.txt
pytest -vsrA --color=yes test/wrappers.py
77 changes: 77 additions & 0 deletions f4pga/wrappers/sh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,120 @@
# Python entrypoint for the shell wrappers moved from arch-defs

from sys import stdout, stderr
from pathlib import Path
from subprocess import check_call


ROOT = Path(__file__).resolve().parent


def generate_constraints():
print("F4PGA (old) generate constraints")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/generate_constraints.f4pga.sh"
check_call(str(wrapper))


def pack():
print("F4PGA (old) pack")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/pack.f4pga.sh"
check_call(str(wrapper))


def place():
print("F4PGA (old) place")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/place.f4pga.sh"
check_call(str(wrapper))


def route():
print("F4PGA (old) route")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/route.f4pga.sh"
check_call(str(wrapper))


def synth():
print("F4PGA (old) synth")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/synth.f4pga.sh"
check_call(str(wrapper))


def write_bitstream():
print("F4PGA (old) write bitstream")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/write_bitstream.f4pga.sh"
check_call(str(wrapper))


def write_fasm():
print("F4PGA (old) write fasm")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/write_fasm.f4pga.sh"
check_call(str(wrapper))


def write_xml_rr_graph():
print("F4PGA (old) write xlm rr graph")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/write_xml_rr_graph.f4pga.sh"
check_call(str(wrapper))


def vpr_common():
print("F4PGA (old) vpr common")
stdout.flush()
stderr.flush()
wrapper = ROOT / "xc7/vpr_common.f4pga.sh"
check_call(str(wrapper))


def analysis():
print("F4PGA (old) analysis")
stdout.flush()
stderr.flush()
wrapper = ROOT / "quicklogic/analysis.f4pga.sh"
check_call(str(wrapper))


def repack():
print("F4PGA (old) repack")
stdout.flush()
stderr.flush()
wrapper = ROOT / "quicklogic/repack.f4pga.sh"
check_call(str(wrapper))


def generate_bitstream():
print("F4PGA (old) generate_bitstream")
stdout.flush()
stderr.flush()
wrapper = ROOT / "quicklogic/generate_bitstream.f4pga.sh"
check_call(str(wrapper))


def generate_libfile():
print("F4PGA (old) generate_libfile")
stdout.flush()
stderr.flush()
wrapper = ROOT / "quicklogic/generate_libfile.f4pga.sh"
check_call(str(wrapper))


def ql():
print("F4PGA (old) ql")
stdout.flush()
stderr.flush()
wrapper = ROOT / "quicklogic/ql.f4pga.sh"
check_call(str(wrapper))
4 changes: 2 additions & 2 deletions f4pga/wrappers/sh/xc7/generate_constraints.f4pga.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

MYPATH=`realpath $0`
Expand Down Expand Up @@ -27,4 +28,3 @@ IOPLACE_FILE="${PROJECT%.*}.ioplace"

python3 ${IOGEN} --blif $EBLIF --map $PINMAP --net $NET $PCF_OPTS > ${IOPLACE_FILE}
python3 ${CONSTR_GEN} --net $NET --arch ${ARCH_DEF} --blif $EBLIF --vpr_grid_map ${VPR_GRID_MAP} --input ${IOPLACE_FILE} --db_root $DATABASE_DIR --part $PART > constraints.place

1 change: 1 addition & 0 deletions test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest
46 changes: 46 additions & 0 deletions test/wrappers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from pytest import mark
from sys import stdout, stderr

from subprocess import check_call


@mark.xfail
@mark.parametrize("wrapper", ['place', 'route', 'synth', 'write-fasm'])
def test_wrappers(wrapper):
print(f"\n::group::Test {wrapper}")
stdout.flush()
stderr.flush()
try:
check_call(f"f4pga-{wrapper}")
finally:
print("\n::endgroup::")


@mark.xfail
@mark.parametrize(
"wrapper",
[
'symbiflow_generate_constraints',
'symbiflow_pack',
'symbiflow_place',
'symbiflow_route',
'symbiflow_synth',
'symbiflow_write_bitstream',
'symbiflow_write_fasm',
'symbiflow_write_xml_rr_graph',
'vpr_common',
'symbiflow_analysis',
'symbiflow_repack',
'symbiflow_generate_bitstream',
'symbiflow_generate_libfile',
'ql_symbiflow'
]
)
def test_shell_wrapper(wrapper):
print(f"\n::group::Test {wrapper}")
stdout.flush()
stderr.flush()
try:
check_call(f"{wrapper}")
finally:
print("\n::endgroup::")

0 comments on commit ae789de

Please sign in to comment.