Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kestrel Collaboration
Kestrel LiteX
migen
Commits
71915c5a
Commit
71915c5a
authored
7 years ago
by
William D. Jones
Browse files
Options
Download
Email Patches
Plain Diff
test: Add Platform-specific tests.
parent
71a48446
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
migen/test/test_platform.py
migen/test/test_platform.py
+49
-0
No files found.
migen/test/test_platform.py
0 → 100644
View file @
71915c5a
import
unittest
import
importlib
import
pkgutil
import
shutil
from
migen
import
*
from
migen.genlib.cdc
import
MultiReg
import
migen.build.platforms
def
_make_platform_test_method
(
mod
,
name
):
def
platform_test_method
(
self
):
plat
=
importlib
.
import_module
(
mod
).
Platform
()
m
=
TestModulePlatform
(
plat
)
plat
.
build
(
m
,
run
=
False
,
build_name
=
name
,
build_dir
=
name
)
shutil
.
rmtree
(
name
)
return
platform_test_method
def
_find_platforms
(
mod_root
):
def
mk_name
(
mod
,
child
):
return
"."
.
join
([
mod
.
__name__
,
child
])
imports
=
[]
for
_
,
name
,
is_mod
in
pkgutil
.
walk_packages
(
mod_root
.
__path__
):
if
is_mod
:
new_root
=
importlib
.
import_module
(
mk_name
(
mod_root
,
name
))
imports
.
extend
(
_find_platforms
(
new_root
))
else
:
imports
.
append
((
mk_name
(
mod_root
,
name
),
name
))
return
imports
class
TestModulePlatform
(
Module
):
def
__init__
(
self
,
plat
):
# FIXME: Somehow incorporate plat.request() into this.
inp
=
Signal
()
out
=
Signal
()
self
.
specials
+=
MultiReg
(
inp
,
out
)
class
TestExamplesPlatform
(
unittest
.
TestCase
):
pass
for
mod
,
name
in
_find_platforms
(
migen
.
build
.
platforms
):
setattr
(
TestExamplesPlatform
,
"test_"
+
name
,
_make_platform_test_method
(
mod
,
name
))
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment