Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fisch
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EBRAINS RI
Tech Hub
Apps
BrainScaleS
fisch
Commits
75ca79bb
Commit
75ca79bb
authored
2 years ago
by
Eric Müller
Committed by
Christian Mauch
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove v1-related files
Change-Id: I4eaa46fc063823b7795fda84068244a0b8ae843c
parent
ceb27cb9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyfisch/tests/sw/fisch-v1-python_bindings.py
+0
-122
0 additions, 122 deletions
pyfisch/tests/sw/fisch-v1-python_bindings.py
pyfisch/tests/sw/fisch-v1-str_conversion.py
+0
-20
0 additions, 20 deletions
pyfisch/tests/sw/fisch-v1-str_conversion.py
with
0 additions
and
142 deletions
pyfisch/tests/sw/fisch-v1-python_bindings.py
deleted
100644 → 0
+
0
−
122
View file @
ceb27cb9
import
unittest
import
inspect
import
tempfile
import
re
import
pyfisch_vx_v1
as
pyfisch_vx
import
random
# This is on module level as many unittest frameworks will ignore main
random
.
seed
(
1234
)
def
get_all_classes
(
m
):
ret
=
dict
()
for
name
,
obj
in
inspect
.
getmembers
(
m
):
if
(
inspect
.
isclass
(
obj
)
and
not
name
.
startswith
(
"
_
"
)
and
str
(
obj
.
__class__
)
==
"
<class
'
pybind11_builtins.pybind11_type
'
>
"
):
ret
[
name
]
=
obj
get_all_classes
(
obj
)
return
ret
classes
=
get_all_classes
(
pyfisch_vx
)
ignored_classes
=
[
pyfisch_vx
.
ReinitStackEntry
]
class
PyBindings
(
unittest
.
TestCase
):
def
instantiate_with_guessed_constructor
(
self
,
obj
):
"""
Instantiate an object of class `obj`. If it has no default
constructor, try to guess meaningful arguments.
"""
try
:
return
obj
()
except
TypeError
as
error
:
# Extract the missing arguments
arg_strs
=
self
.
parse_constructor_exception
(
error
.
message
)
# Try to construct them and instantiate the test object
arguments
=
[
eval
(
arg_type
)()
for
arg_type
in
arg_strs
]
return
obj
(
*
arguments
)
@staticmethod
def
parse_constructor_exception
(
error_string
):
"""
Parse an
"
Incompatible Constructor
"
exception and extract the
correct argument types.
Such an exception might look like this:
```
TypeError: __init__(): incompatible constructor arguments.
The following argument types are supported:
1. _pydls.Trigger_mode(arg0: int)
```
:param error_string: Exception message
:type error_string: str
:return: List of the expected argument types
:rtype: list of str
"""
regex
=
r
"
(?<=arg\d: ).*?(?=\,|\))
"
return
re
.
findall
(
regex
,
error_string
)
def
construct_base_checks
():
for
name
,
obj
in
classes
.
items
():
def
generate_test_function
(
test_obj
):
"""
Generate an
"
is-constructible
"
test for a given class.
"""
@unittest.skipIf
(
obj
in
ignored_classes
,
"
Ignored
"
)
def
test_function
(
self
):
original
=
self
.
instantiate_with_guessed_constructor
(
test_obj
)
return
test_function
func
=
generate_test_function
(
obj
)
func
.
__name__
=
'
test_base_constructible_%s
'
%
name
setattr
(
PyBindings
,
func
.
__name__
,
func
)
def
construct_derived_checks
():
for
name
,
obj
in
classes
.
items
():
def
generate_test_function
(
test_obj
):
"""
Generate an
"
is-constructible
"
test for an arbitrary derived class of `test_obj`.
"""
@unittest.skipIf
(
obj
in
ignored_classes
,
"
Ignored
"
)
def
test_function
(
self
):
class
Derived
(
test_obj
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Derived
,
self
).
__init__
(
*
args
,
**
kwargs
)
# Add new attribute, ensure it hasn't been there before
new_name
=
"
x%d
"
%
random
.
randint
(
0
,
int
(
2
**
32
-
1
))
while
hasattr
(
self
,
new_name
):
new_name
=
"
x%d
"
%
random
.
randint
(
0
,
int
(
2
**
32
-
1
))
new_value
=
0xdeadbeef
setattr
(
self
,
new_name
,
new_value
)
Derived
.
__name__
=
"
derived_%s
"
%
name
# pickle needs it in global namespace
globals
()[
Derived
.
__name__
]
=
Derived
# Test it
original
=
self
.
instantiate_with_guessed_constructor
(
Derived
)
return
test_function
func
=
generate_test_function
(
obj
)
func
.
__name__
=
'
test_derived_constructible_%s
'
%
name
setattr
(
PyBindings
,
func
.
__name__
,
func
)
# Register tests: has to be done on module level and must not contain "test"
construct_base_checks
()
construct_derived_checks
()
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
pyfisch/tests/sw/fisch-v1-str_conversion.py
deleted
100644 → 0
+
0
−
20
View file @
ceb27cb9
import
unittest
import
pyfisch_vx_v1
as
fisch
class
StrConversion
(
unittest
.
TestCase
):
def
test_str_conversion
(
self
):
self
.
assertEqual
(
str
(
fisch
.
JTAGIdCode
()),
"
JTAGIdCode(0x0)
"
)
self
.
assertEqual
(
str
(
fisch
.
JTAGClockScaler
(
3
)),
"
JTAGClockScaler(3)
"
)
self
.
assertEqual
(
str
(
fisch
.
ResetJTAGTap
()),
"
ResetJTAGTap()
"
)
self
.
assertEqual
(
str
(
fisch
.
OmnibusChipOverJTAG
(
12
)),
"
OmnibusChipOverJTAG(0d12 0xc 0b00000000000000000000000000001100)
"
)
self
.
assertEqual
(
str
(
fisch
.
Omnibus
(
fisch
.
Omnibus
.
Value
(
12
,
[
True
,
True
,
False
,
True
]))),
"
Omnibus(0d12 0xc 0b00000000000000000000000000001100, byte_enables: 1101)
"
)
self
.
assertEqual
(
str
(
fisch
.
JTAGPLLRegister
(
12
)),
"
JTAGPLLRegister(0d12 0xc 0b00000000000000000000000000001100)
"
)
self
.
assertEqual
(
str
(
fisch
.
ResetChip
(
True
)),
"
ResetChip(true)
"
)
self
.
assertEqual
(
str
(
fisch
.
Timer
()),
"
Timer()
"
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment