Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ebpfCAT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Teichmann
ebpfCAT
Commits
4f83d5ec
Commit
4f83d5ec
authored
2 years ago
by
Martin Teichmann
Browse files
Options
Downloads
Patches
Plain Diff
modify test for address at end
parent
75e9e63c
No related branches found
No related tags found
1 merge request
!8
Draft: move the index field to the end of packet
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ebpfcat/ethercat_test.py
+29
-23
29 additions, 23 deletions
ebpfcat/ethercat_test.py
with
29 additions
and
23 deletions
ebpfcat/ethercat_test.py
+
29
−
23
View file @
4f83d5ec
...
...
@@ -46,7 +46,10 @@ class MockEtherCat:
return
self
.
results
.
pop
(
0
)
def
send_packet
(
self
,
data
):
self
.
test
.
assertEqual
(
data
,
self
.
expected
.
pop
(
0
),
data
.
hex
())
expected
=
self
.
expected
.
pop
(
0
)
if
len
(
expected
)
<
46
:
expected
+=
b
"
\0
"
*
(
46
-
len
(
expected
))
self
.
test
.
assertEqual
(
data
,
expected
,
data
.
hex
())
async
def
receive_index
(
self
,
index
):
self
.
test
.
assertEqual
(
index
,
self
.
expected
.
pop
(
0
))
...
...
@@ -54,7 +57,10 @@ class MockEtherCat:
self
.
test
.
future
.
cancel
()
for
i
in
range
(
10
):
await
sleep
(
0
)
return
self
.
results
.
pop
(
0
)
expected
=
self
.
results
.
pop
(
0
)
if
len
(
expected
)
<
46
:
expected
+=
b
"
\0
"
*
(
46
-
len
(
expected
))
return
expected
def
register_sync_group
(
self
,
sg
,
packet
):
self
.
rsg
=
sg
...
...
@@ -127,26 +133,26 @@ class Tests(TestCase):
sg
=
SyncGroup
(
ec
,
[
ai
])
self
.
task
=
sg
.
start
()
ec
.
expected
=
[
H
(
"
2a10
"
# EtherCAT Header, length & type
"
0000e8030000008000000000
"
# ID datagram
H
(
"
2810
"
# EtherCAT Header, length & type
# in datagram
"
04000400801110000000000000000000000000000000000000000000
"
),
"
04000400801110800000000000000000000000000000000000000000
"
"
0000e8030000000000000000
"
),
# ID datagram
1000
,
# == 0x3e8, see ID datagram
H
(
"
2a10
"
# EtherCAT Header, length & type
"
0000e8030000008000000000
"
# ID datagram
H
(
"
2810
"
# EtherCAT Header, length & type
# in datagram
"
04000400801110000000123456780000000000000000000000000000
"
),
"
04000400801110800000123456780000000000000000000000000000
"
"
0000e8030000000000000000
"
),
# ID datagram
1000
,
]
ec
.
results
=
[
H
(
"
2a10
"
# EtherCAT Header, length & type
"
0000e8030000008000000000
"
# ID datagram
H
(
"
2810
"
# EtherCAT Header, length & type
"
04000400801110800000123456780000000000000000000000000000
"
"
0000e8030000000000000000
"
),
# ID datagram
# in datagram
"
04000400801110000000123456780000000000000000000000000000
"
),
H
(
"
2a10
"
# EtherCAT Header, length & type
"
0000e8030000008000000000
"
# ID datagram
H
(
"
2810
"
# EtherCAT Header, length & type
# in datagram
"
04000400801110000000123456780000000000000000000000000000
"
),
"
04000400801110800000123456780000000000000000000000000000
"
),
"
0000e8030000000000000000
"
# ID datagram
]
self
.
future
=
Future
()
with
self
.
assertRaises
(
CancelledError
):
...
...
@@ -173,9 +179,9 @@ class Tests(TestCase):
sg
=
SyncGroup
(
ec
,
[
ao
])
self
.
task
=
sg
.
start
()
ec
.
expected
=
[
H
(
"
2
2
10
"
# EtherCAT Header, length & type
"
0000
e
80
3
000000
8
000000000
"
# ID
datagram
"
0
5
000
7000011080000000000
0000000000000000
"
),
#
out
datagram
H
(
"
2
0
10
"
# EtherCAT Header, length & type
"
0
5
000
700001108
80000000
0
000000000
00000000
"
# out
datagram
"
0000
e803
0000000000000000
"
),
#
ID
datagram
1000
,
# == 0x3e8, see ID datagram
]
ec
.
results
=
[
...
...
@@ -186,15 +192,15 @@ class Tests(TestCase):
with
self
.
assertRaises
(
CancelledError
):
await
gather
(
self
.
future
,
self
.
task
)
ec
.
expected
=
[
H
(
"
2
2
10
"
# EtherCAT Header, length & type
"
0000
e8030000008
000000000
"
#
ID
datagram
"
0
5
000
7000011080000007698
0000000000000000
"
),
#
out
datagram
H
(
"
2
0
10
"
# EtherCAT Header, length & type
"
0
5
000
7000011088000007698000000
000000000
0
"
#
out
datagram
"
0000
e803
0000000000000000
"
),
#
ID
datagram
1000
,
]
ec
.
results
=
[
H
(
"
2
2
10
"
# EtherCAT Header, length & type
"
0000
e8030000008
000000000
"
#
ID
datagram
"
0
5
000
7000011080000007698
0000000000000000
"
),
#
out
datagram
H
(
"
2
0
10
"
# EtherCAT Header, length & type
"
0
5
000
7000011088000007698000000
000000000
0
"
#
out
datagram
"
0000
e803
0000000000000000
"
),
#
ID
datagram
]
self
.
future
=
Future
()
with
self
.
assertRaises
(
CancelledError
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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