Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EtherBone Core
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Projects
EtherBone Core
Commits
c4436e18
Commit
c4436e18
authored
13 years ago
by
Wesley W. Terpstra
Browse files
Options
Downloads
Patches
Plain Diff
Two new test features:
test for memory leaks test tcp or udp
parent
8995c3ca
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/test/loopback.cpp
+31
-4
31 additions, 4 deletions
api/test/loopback.cpp
with
31 additions
and
4 deletions
api/test/loopback.cpp
+
31
−
4
View file @
c4436e18
...
...
@@ -28,6 +28,9 @@
#define __STDC_FORMAT_MACROS
#define EB_MEMORY_HACK 1
#define EB_TEST_TCP 1
#include
<stdio.h>
#include
<stdlib.h>
...
...
@@ -37,6 +40,11 @@
#include
"../etherbone.h"
#ifdef EB_MEMORY_HACK
extern
uint16_t
eb_memory_used
;
// A hack to read directly the memory consumption of EB
extern
uint32_t
eb_memory_array_size
;
#endif
using
namespace
etherbone
;
using
namespace
std
;
...
...
@@ -96,6 +104,7 @@ Record::Record(width_t width_) {
if
(
type
==
READ_CFG
)
data
=
0
;
data
&=
(
data_t
)(
~
0
)
>>
((
sizeof
(
data
)
-
dataw
)
*
8
);
if
(
type
==
READ_CFG
||
type
==
WRITE_CFG
)
{
/* Config space is narrower */
address
&=
0x7FFF
;
...
...
@@ -105,7 +114,6 @@ Record::Record(width_t width_) {
error
=
0
;
}
else
{
/* Trim the request to fit the addr/data widths */
data
&=
(
data_t
)(
~
0
)
>>
((
sizeof
(
data
)
-
dataw
)
*
8
);
address
&=
(
address_t
)(
~
0
)
>>
((
sizeof
(
address
)
-
addrw
)
*
8
);
error
=
(
address
&
3
)
==
1
;
}
...
...
@@ -181,12 +189,14 @@ public:
};
void
TestCycle
::
complete
(
Operation
op
,
status_t
status
)
{
#ifndef EB_TEST_TCP
if
(
status
==
EB_OVERFLOW
)
{
if
(
loud
)
printf
(
"Skipping overflow cycle
\n
"
);
++*
success
;
expect
.
erase
(
first
,
++
last
);
return
;
}
#endif
if
(
status
!=
EB_OK
)
die
(
"cycle failed"
,
status
);
...
...
@@ -262,7 +272,7 @@ void test_query(Device device, int len, int requests) {
++
serial
;
#if 0
if (serial ==
90
9) {
if (serial ==
19708
9) {
printf("Enabling debug\n");
loud = true;
}
...
...
@@ -304,12 +314,22 @@ void test_width(Socket socket, width_t width) {
Device
device
;
status_t
err
;
#ifdef EB_TEST_TCP
if
((
err
=
device
.
open
(
socket
,
"tcp/127.0.0.1/60368"
,
width
))
!=
EB_OK
)
die
(
"device.open"
,
err
);
#else
if
((
err
=
device
.
open
(
socket
,
"udp/127.0.0.1/60368"
,
width
))
!=
EB_OK
)
die
(
"device.open"
,
err
);
#endif
for
(
int
len
=
0
;
len
<
4000
;
++
len
)
for
(
int
len
=
0
;
len
<
4000
;
++
len
)
{
#ifdef EB_MEMORY_HACK
printf
(
"
\r
Length: %d ==> %d/%d cells used... "
,
len
,
eb_memory_used
,
eb_memory_array_size
);
fflush
(
stdout
);
#endif
for
(
int
requests
=
1
;
requests
<=
9
;
++
requests
)
for
(
int
repetitions
=
0
;
repetitions
<
100
;
++
repetitions
)
test_query
(
device
,
len
,
requests
);
}
if
((
err
=
device
.
close
())
!=
EB_OK
)
die
(
"device.close"
,
err
);
}
...
...
@@ -318,12 +338,19 @@ int main() {
status_t
err
;
Socket
socket
;
if
((
err
=
socket
.
open
(
"60368"
,
EB_DATA6
4
|
EB_ADDR32
))
!=
EB_OK
)
die
(
"socket.open"
,
err
);
if
((
err
=
socket
.
open
(
"60368"
,
EB_DATA
1
6
|
EB_ADDR32
))
!=
EB_OK
)
die
(
"socket.open"
,
err
);
Echo
echo
;
if
((
err
=
socket
.
attach
(
0
,
~
0
,
&
echo
))
!=
EB_OK
)
die
(
"socket.attach"
,
err
);
/* for widths */
test_width
(
socket
,
EB_DATAX
|
EB_ADDRX
);
if
((
err
=
socket
.
close
())
!=
EB_OK
)
die
(
"socket.close"
,
err
);
#ifdef EB_MEMORY_HACK
printf
(
"
\n
Final memory consumption: %d/%d
\n
"
,
eb_memory_used
,
eb_memory_array_size
);
#endif
return
0
;
}
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