Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Trigger Distribution
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Trigger Distribution
Commits
a1e53160
Commit
a1e53160
authored
Jan 30, 2019
by
Dimitris Lampridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: cleanup of obsolete sources
parent
5f6b23a1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
0 additions
and
3945 deletions
+0
-3945
Makefile
software/stresstests/Makefile
+0
-32
wrtd-freqmeter.c
software/stresstests/wrtd-freqmeter.c
+0
-445
wrtd-timetest.c
software/stresstests/wrtd-timetest.c
+0
-285
wrtd-in-config.c
software/tools/wrtd-in-config.c
+0
-376
wrtd-out-config.c
software/tools/wrtd-out-config.c
+0
-656
.gitignore
software/unittest/.gitignore
+0
-1
CuTest.c
software/unittest/CuTest.c
+0
-355
CuTest.h
software/unittest/CuTest.h
+0
-117
Makefile
software/unittest/Makefile
+0
-30
wrtd-ut-common.c
software/unittest/wrtd-ut-common.c
+0
-45
wrtd-ut-input.c
software/unittest/wrtd-ut-input.c
+0
-282
wrtd-ut-op.c
software/unittest/wrtd-ut-op.c
+0
-440
wrtd-ut-output.c
software/unittest/wrtd-ut-output.c
+0
-581
wrtd-ut.c
software/unittest/wrtd-ut.c
+0
-73
wrtd-ut.h
software/unittest/wrtd-ut.h
+0
-28
.gitignore
tests/firmware/.gitignore
+0
-7
Makefile
tests/firmware/Makefile
+0
-27
Kconfig
tests/firmware/rmq-udp/Kconfig
+0
-19
Makefile
tests/firmware/rmq-udp/Makefile
+0
-16
mt_defconfig
tests/firmware/rmq-udp/configs/mt_defconfig
+0
-30
rmq-udp.c
tests/firmware/rmq-udp/rmq-udp.c
+0
-100
No files found.
software/stresstests/Makefile
deleted
100644 → 0
View file @
5f6b23a1
# If it exists includes Makefile.specific. In this Makefile, you should put
# specific Makefile code that you want to run before this. For example,
# build a particular environment.
-include
Makefile.specific
# include parent_common.mk for buildsystem's defines
# It allows you to inherit an environment configuration from larger project
REPO_PARENT
?=
..
-include
$(REPO_PARENT)/parent_common.mk
WRTD_DEP_TRTL
?=
../../../dependencies/mock-turtle/
CFLAGS
+=
-Wall
-g
-O0
CFLAGS
+=
-I
.
-I
../include
-I
$(WRTD_DEP_TRTL)
/software/include
\
-I
$(WRTD_DEP_TRTL)
/software/lib
-I
../lib
CFLAGS
+=
$(EXTRACFLAGS)
LDLIBS
+=
../lib/libwrtd.a
$(WRTD_DEP_TRTL)
/software/lib/libmockturtle.a
PROGS
=
wrtd-timetest wrtd-freqmeter
all
:
$(PROGS)
wrtd-timetest
:
wrtd-timetest.c $(LDLIBS)
$(CC)
$(CFLAGS)
$(LDFLAGS)
$^
$(LDLIBS)
-o
$@
wrtd-freqmeter
:
wrtd-freqmeter.c $(LDLIBS)
$(CC)
$(CFLAGS)
$(LDFLAGS)
$^
$(LDLIBS)
-o
$@
.PHONY
:
all clean
clean
:
rm
-f
$(PROGS)
*
.o
*
~
software/stresstests/wrtd-freqmeter.c
deleted
100644 → 0
View file @
5f6b23a1
This diff is collapsed.
Click to expand it.
software/stresstests/wrtd-timetest.c
deleted
100644 → 0
View file @
5f6b23a1
/*
* Copyright (C) 2018 CERN (www.cern.ch)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @TODO software trigger test
*/
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <inttypes.h>
#include <libmockturtle.h>
#include <libwrtd.h>
#define AssertIntEquals(VAL, EXPR) do \
{ \
int val = (VAL); \
int expr = (EXPR); \
if (val != expr) { \
fprintf(stderr, \
"%s:%d: unexpected value (got %d, expect %d)\n", \
__FILE__, __LINE__, expr, val); \
exit (1); \
} \
} while (0)
#define AssertPtrNotNull(EXPR) do \
{ \
void *ptr = (EXPR); \
if (ptr == NULL) { \
fprintf(stderr, \
"%s:%d: unexpected null pointer\n", \
__FILE__, __LINE__); \
exit (1); \
} \
} while (0)
/* Clear counters. */
static
void
clear_counters
(
struct
wrtd_node
*
wrtd
)
{
AssertIntEquals
(
0
,
wrtd_out_global_counters_reset
(
wrtd
));
AssertIntEquals
(
0
,
wrtd_in_global_counters_reset
(
wrtd
));
AssertIntEquals
(
0
,
wrtd_out_counters_reset
(
wrtd
,
0
));
AssertIntEquals
(
0
,
wrtd_in_counters_reset
(
wrtd
,
0
));
AssertIntEquals
(
0
,
wrtd_out_counters_reset
(
wrtd
,
1
));
AssertIntEquals
(
0
,
wrtd_in_counters_reset
(
wrtd
,
1
));
}
/* Path:
* Lun0/Out2 ->
* Lun0/In1 -> tid1 -> Lun1/Out1 ->
* Lun0/In2
*/
static
struct
wrtd_node
*
wrtd_0
,
*
wrtd_1
;
static
struct
wrtd_trigger_handle
h_1
;
static
void
setup
(
int
delay_us
)
{
struct
wrtd_trig_id
tid_1
=
{
0
,
0
,
1
};
struct
wrtd_trig_id
tid_2
=
{
0
,
0
,
2
};
const
uint64_t
tdelay
=
delay_us
*
1000
*
1000
;
wrtd_0
=
wrtd_open
(
1
);
if
(
wrtd_0
==
NULL
)
{
fprintf
(
stderr
,
"cannot open wrtd 1: %m
\n
"
);
exit
(
2
);
}
wrtd_1
=
wrtd_open
(
2
);
if
(
wrtd_1
==
NULL
)
{
fprintf
(
stderr
,
"cannot open wrtd 2: %m
\n
"
);
exit
(
2
);
}
clear_counters
(
wrtd_0
);
clear_counters
(
wrtd_1
);
/* Assign trigger input */
AssertIntEquals
(
0
,
wrtd_in_trigger_assign
(
wrtd_0
,
0
,
&
tid_1
));
AssertIntEquals
(
0
,
wrtd_in_trigger_assign
(
wrtd_0
,
1
,
&
tid_2
));
AssertIntEquals
(
0
,
wrtd_in_trigger_mode_set
(
wrtd_0
,
0
,
WRTD_TRIGGER_MODE_AUTO
));
AssertIntEquals
(
0
,
wrtd_in_trigger_mode_set
(
wrtd_0
,
1
,
WRTD_TRIGGER_MODE_AUTO
));
/* Assign trigger output */
AssertIntEquals
(
0
,
wrtd_out_trig_assign
(
wrtd_1
,
0
,
&
h_1
,
&
tid_1
,
NULL
));
AssertIntEquals
(
0
,
wrtd_out_trig_delay_set
(
wrtd_1
,
&
h_1
,
tdelay
));
AssertIntEquals
(
0
,
wrtd_out_trigger_mode_set
(
wrtd_1
,
0
,
WRTD_TRIGGER_MODE_AUTO
));
AssertIntEquals
(
0
,
wrtd_in_dead_time_set
(
wrtd_0
,
0
,
80000000
));
AssertIntEquals
(
0
,
wrtd_in_dead_time_set
(
wrtd_0
,
1
,
80000000
));
/* Enable and Arm */
AssertIntEquals
(
0
,
wrtd_out_arm
(
wrtd_1
,
0
,
1
));
AssertIntEquals
(
0
,
wrtd_out_enable
(
wrtd_1
,
0
,
1
));
AssertIntEquals
(
0
,
wrtd_out_trig_enable
(
wrtd_1
,
&
h_1
,
1
));
AssertIntEquals
(
0
,
wrtd_in_arm
(
wrtd_0
,
0
,
1
));
AssertIntEquals
(
0
,
wrtd_in_arm
(
wrtd_0
,
1
,
1
));
AssertIntEquals
(
0
,
wrtd_in_enable
(
wrtd_0
,
0
,
1
));
AssertIntEquals
(
0
,
wrtd_in_enable
(
wrtd_0
,
1
,
1
));
}
static
void
test_timing
(
int
count
)
{
struct
wrtd_input_state
sti_l0c0
,
sti_l0c1
;
int
i
;
for
(
i
=
1
;
i
<=
count
;
i
++
)
{
/* Generate a pulse. */
AssertIntEquals
(
0
,
wrtd_out_trigger_sw_now
(
wrtd_0
,
1
));
usleep
(
500
);
/* Get stats. */
AssertIntEquals
(
0
,
wrtd_in_state_get
(
wrtd_0
,
0
,
&
sti_l0c0
));
AssertIntEquals
(
0
,
wrtd_in_state_get
(
wrtd_0
,
1
,
&
sti_l0c1
));
/* Check them. */
AssertIntEquals
(
i
,
sti_l0c0
.
sent_triggers
);
AssertIntEquals
(
i
,
sti_l0c1
.
sent_triggers
);
/* Check time. */
/* TODO. */
}
}
static
void
print_ts
(
struct
wr_timestamp
ts
)
{
uint64_t
ns
=
ts
.
ticks
*
8ULL
;
printf
(
"%llu:%03llu,%03llu,%03lluns"
,
(
long
long
)(
ts
.
seconds
),
(
ns
/
(
1000LL
*
1000
)),
(
ns
/
1000LL
)
%
1000
,
ns
%
1000ULL
);
}
static
void
disp_timing
(
int
count
,
int
delay_us
)
{
struct
wrtd_input_state
sti_l0c0
,
sti_l0c1
;
struct
wr_timestamp
d
;
int
i
;
uint64_t
pico
;
unsigned
int
d_ns
;
unsigned
int
min_ns
=
delay_us
*
990
;
/* - 1% */
unsigned
int
max_ns
=
delay_us
*
1010
;
/* + 1% */
int
ecount
;
for
(
i
=
1
,
ecount
=
0
;
i
<=
count
;
i
++
)
{
/* Generate a pulse. */
AssertIntEquals
(
0
,
wrtd_out_trigger_sw_now
(
wrtd_0
,
1
));
usleep
(
5000
);
/* Get stats. */
AssertIntEquals
(
0
,
wrtd_in_state_get
(
wrtd_0
,
0
,
&
sti_l0c0
));
AssertIntEquals
(
0
,
wrtd_in_state_get
(
wrtd_0
,
1
,
&
sti_l0c1
));
/* Check them. */
AssertIntEquals
(
i
,
sti_l0c0
.
sent_triggers
);
if
(
sti_l0c1
.
sent_triggers
==
ecount
+
1
)
{
/* Check time. */
AssertIntEquals
(
0
,
0
);
wrtd_ts_sub
(
&
d
,
&
sti_l0c1
.
last_pulse
,
&
sti_l0c0
.
last_pulse
);
wrtd_ts_to_pico
(
&
d
,
&
pico
);
printf
(
"Delay: %"
PRIu64
"ps ["
,
pico
);
print_ts
(
sti_l0c1
.
last_pulse
);
printf
(
" - "
);
print_ts
(
sti_l0c0
.
last_pulse
);
printf
(
"]
\n
"
);
ecount
++
;
d_ns
=
pico
/
1000
;
if
(
d_ns
<
min_ns
)
{
printf
(
"Below timing!
\n
"
);
break
;
}
else
if
(
d_ns
>
max_ns
)
{
printf
(
"Above timing
\n
"
);
break
;
}
}
else
{
printf
(
"Missing!
\n
"
);
}
}
printf
(
"%d/%d missing pulses
\n
"
,
i
-
ecount
,
i
);
}
static
void
teardown
(
void
)
{
/* Stop. */
AssertIntEquals
(
0
,
wrtd_in_enable
(
wrtd_0
,
0
,
0
));
AssertIntEquals
(
0
,
wrtd_in_enable
(
wrtd_0
,
1
,
0
));
AssertIntEquals
(
0
,
wrtd_out_enable
(
wrtd_0
,
0
,
0
));
AssertIntEquals
(
0
,
wrtd_out_enable
(
wrtd_1
,
0
,
0
));
#if 0
/* Last sent trigger is the last executed */
AssertIntEquals(sti_l1c0.last_sent.seq,
sto_l0c1.last_executed.seq);
AssertIntEquals(sti_l0c0.last_sent.seq,
sto_l1c0.last_executed.seq);
AssertIntEquals(sti_l0c1.last_sent.seq,
sto_l0c0.last_executed.seq);
AssertIntEquals(0, memcmp(&sti_l1c0.last_sent.id,
&sto_l0c1.last_executed.id,
sizeof(struct wrtd_trig_id)));
AssertIntEquals(0, memcmp(&sti_l0c0.last_sent.id,
&sto_l1c0.last_executed.id,
sizeof(struct wrtd_trig_id)));
AssertIntEquals(0, memcmp(&sti_l0c1.last_sent.id,
&sto_l0c0.last_executed.id,
sizeof(struct wrtd_trig_id)));
#endif
AssertIntEquals
(
0
,
wrtd_out_trig_unassign
(
wrtd_1
,
&
h_1
));
/* Close */
wrtd_close
(
wrtd_0
);
wrtd_close
(
wrtd_1
);
}
static
void
help
(
void
)
{
printf
(
"usage: wrtd-timetest [-c COUNT] [-d DELAY_US]
\n
"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
c
;
int
count
;
int
delay_us
;
char
*
endptr
;
count
=
100
;
delay_us
=
200
;
while
((
c
=
getopt
(
argc
,
argv
,
"hc:d:"
))
!=
-
1
)
{
switch
(
c
)
{
case
'h'
:
case
'?'
:
help
();
exit
(
1
);
case
'c'
:
count
=
strtol
(
optarg
,
&
endptr
,
0
);
if
(
*
endptr
!=
0
)
count
=
-
1
;
break
;
case
'd'
:
delay_us
=
strtol
(
optarg
,
&
endptr
,
0
);
if
(
*
endptr
!=
0
)
delay_us
=
-
1
;
break
;
}
}
if
(
count
<
1
)
{
fprintf
(
stderr
,
"bad count value (must be > 0)
\n
"
);
exit
(
1
);
}
if
(
delay_us
<
1
)
{
fprintf
(
stderr
,
"bad delay value (must be > 0)
\n
"
);
exit
(
1
);
}
setup
(
delay_us
);
if
(
1
)
disp_timing
(
count
,
delay_us
);
else
test_timing
(
count
);
teardown
();
return
0
;
}
software/tools/wrtd-in-config.c
deleted
100644 → 0
View file @
5f6b23a1
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <libgen.h>
#include <libwrtd.h>
#include <inttypes.h>
#include <wrtd-internal.h>
void
dump_input_state
(
struct
wrtd_input_state
*
state
,
struct
wr_timestamp
current
)
{
char
tmp
[
1024
],
tmp2
[
1024
],
tmp3
[
1024
];
if
(
!
(
state
->
flags
&
WRTD_ENABLED
))
printf
(
"Channel %d: disabled
\n
"
,
state
->
input
);
decode_flags
(
tmp
,
state
->
flags
);
printf
(
"Channel %d state:
\n
"
,
state
->
input
);
printf
(
" - Flags: %s
\n
"
,
tmp
);
decode_mode
(
tmp
,
state
->
mode
);
printf
(
" - Mode: %s
\n
"
,
tmp
);
format_ts
(
tmp
,
state
->
delay
,
0
);
printf
(
" - Delay: %s
\n
"
,
tmp
);
printf
(
" - Total nbr pulses: %-10d
\n
"
,
state
->
total_pulses
);
printf
(
" - Sent triggers: %-10d
\n
"
,
state
->
sent_triggers
);
format_id
(
tmp
,
state
->
assigned_id
);
printf
(
" - Assigned ID: %s
\n
"
,
state
->
flags
&
WRTD_TRIGGER_ASSIGNED
?
tmp
:
"none"
);
if
(
state
->
flags
&
WRTD_LAST_VALID
)
{
format_ts
(
tmp
,
state
->
last_pulse
,
1
);
format_ago
(
tmp2
,
state
->
last_pulse
,
current
);
printf
(
" - Last input pulse: %s (%s)
\n
"
,
tmp
,
tmp2
);
}
if
(
state
->
sent_triggers
>
0
)
{
format_ts
(
tmp
,
state
->
last_sent
.
ts
,
1
);
format_id
(
tmp2
,
state
->
last_sent
.
id
);
format_ago
(
tmp3
,
state
->
last_sent
.
ts
,
current
);
printf
(
" - Last sent trigger: %s (%s), ID: %s, SeqNo %d
\n
"
,
tmp
,
tmp3
,
tmp2
,
state
->
last_sent
.
seq
);
}
printf
(
" - Dead time: %"
PRIu64
" ns
\n
"
,
ts_to_picos
(
state
->
dead_time
)
/
1000
);
wrtd_strlogging_full
(
tmp
,
state
->
log_level
);
printf
(
" - Log level: %s
\n
"
,
tmp
);
printf
(
"Global Input information:
\n
"
);
printf
(
" - Sent packets: %-10d
\n
"
,
state
->
sent_packets
);
}
static
int
wrtd_cmd_state
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
struct
wrtd_input_state
state
;
int
err
;
struct
wr_timestamp
current
;
err
=
wrtd_in_state_get
(
wrtd
,
input
,
&
state
);
if
(
err
)
return
err
;
err
=
wrtd_in_base_time
(
wrtd
,
&
current
);
if
(
err
)
return
err
;
dump_input_state
(
&
state
,
current
);
return
0
;
}
static
int
wrtd_cmd_enable
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
return
wrtd_in_enable
(
wrtd
,
input
,
1
);
}
static
int
wrtd_cmd_disable
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
return
wrtd_in_enable
(
wrtd
,
input
,
0
);
}
static
int
wrtd_cmd_set_dead_time
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
uint64_t
dtime
=
0
;
if
(
argc
!=
1
||
argv
[
0
]
==
NULL
)
{
fprintf
(
stderr
,
"Missing deadtime value
\n
"
);
return
-
1
;
}
parse_delay
(
argv
[
0
],
&
dtime
);
return
wrtd_in_dead_time_set
(
wrtd
,
input
,
dtime
);
}
static
int
wrtd_cmd_set_delay
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
uint64_t
dtime
=
0
;
if
(
argc
!=
1
||
argv
[
0
]
==
NULL
)
{
fprintf
(
stderr
,
"Missing deadtime value
\n
"
);
return
-
1
;
}
parse_delay
(
argv
[
0
],
&
dtime
);
return
wrtd_in_delay_set
(
wrtd
,
input
,
dtime
);
}
static
int
wrtd_cmd_set_mode
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
enum
wrtd_trigger_mode
mode
;
if
(
argc
!=
1
||
argv
[
0
]
==
NULL
)
{
fprintf
(
stderr
,
"Missing deadtime value
\n
"
);
return
-
1
;
}
if
(
!
strcmp
(
"auto"
,
argv
[
0
]))
{
mode
=
WRTD_TRIGGER_MODE_AUTO
;
}
else
if
(
!
strcmp
(
"single"
,
argv
[
0
]))
{
mode
=
WRTD_TRIGGER_MODE_SINGLE
;
}
else
{
fprintf
(
stderr
,
"Invalid trigger mode '%s'
\n
"
,
argv
[
0
]);
return
-
1
;
}
return
wrtd_in_trigger_mode_set
(
wrtd
,
input
,
mode
);
}
int
wrtd_cmd_assign
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
struct
wrtd_trig_id
trig_id
;
int
ret
;
if
(
argc
!=
1
||
argv
[
0
]
==
NULL
)
{
fprintf
(
stderr
,
"Missing deadtime value
\n
"
);
return
-
1
;
}
ret
=
parse_trigger_id
(
argv
[
0
],
&
trig_id
);
if
(
ret
<
0
)
return
-
1
;
return
wrtd_in_trigger_assign
(
wrtd
,
input
,
&
trig_id
);
}
int
wrtd_cmd_unassign
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
return
wrtd_in_trigger_unassign
(
wrtd
,
input
);
}
int
wrtd_cmd_arm
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
return
wrtd_in_arm
(
wrtd
,
input
,
1
);
}
int
wrtd_cmd_disarm
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
return
wrtd_in_arm
(
wrtd
,
input
,
0
);
}
static
int
wrtd_cmd_reset
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
return
wrtd_in_counters_reset
(
wrtd
,
input
);
}
static
int
wrtd_cmd_global_reset
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
return
wrtd_in_global_counters_reset
(
wrtd
);
}
static
int
wrtd_cmd_sw_trigger
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
struct
wrtd_trigger_entry
ent
;
uint64_t
ts
;
int
ret
;
if
(
argc
<
1
||
argv
[
0
]
==
NULL
)
{
fprintf
(
stderr
,
"Missing ID value.
\n
"
);
return
-
1
;
}
ret
=
parse_trigger_id
(
argv
[
0
],
&
ent
.
id
);
if
(
ret
<
0
)
return
-
1
;
if
(
argv
[
1
]
!=
NULL
)
{
parse_delay
(
argv
[
1
],
&
ts
);
wrtd_pico_to_ts
(
&
ts
,
&
ent
.
ts
);
}
else
{
ent
.
ts
.
seconds
=
0
;
ent
.
ts
.
ticks
=
100000000000ULL
/
8000ULL
;
/* 100ms */
ent
.
ts
.
frac
=
0
;
}
return
wrtd_in_trigger_software
(
wrtd
,
&
ent
);
}
static
int
wrtd_cmd_log_level
(
struct
wrtd_node
*
wrtd
,
int
input
,
int
argc
,
char
*
argv
[])
{
int
log_level
;
if
(
argc
<
1
)
{
fprintf
(
stderr
,
"Missing arguments: log_level <all off executed missed filtered promisc>
\n
"
);
return
-
1
;
}
parse_log_level
(
argv
,
argc
,
&
log_level
);
return
wrtd_in_log_level_set
(
wrtd
,
input
,
log_level
);
}
static
struct
wrtd_commands
cmds
[]
=
{
{
"state"
,
""
,
"shows input state"
,
wrtd_cmd_state
},
{
"enable"
,
""
,
"enable the input"
,
wrtd_cmd_enable
},
{
"disable"
,
""
,
"disable the input"
,
wrtd_cmd_disable
},
{
"deadtime"
,
"<number>"
,
"sets the dead time in pico-seconds"
,
wrtd_cmd_set_dead_time
},
{
"delay"
,
"<number>"
,
"sets the input delay in pico-seconds"
,
wrtd_cmd_set_delay
},
{
"mode"
,
"<mode>"
,
"sets triggering mode (see Trigger Modes)"
,
wrtd_cmd_set_mode
},
{
"assign"
,
"<trig-id>"
,
"assigns a trigger (see Trigger ID)"
,
wrtd_cmd_assign
},
{
"unassign"
,
""
,
"un-assigns the currently assigned trigger"
,
wrtd_cmd_unassign
},
{
"arm"
,
""
,
"arms the input"
,
wrtd_cmd_arm
},
{
"disarm"
,
""
,
"disarms the input"
,
wrtd_cmd_disarm
},
{
"reset"
,
""
,
"resets statistics counters"
,
wrtd_cmd_reset
},
{
"global_reset"
,
""
,
"resets global statistics counters"
,
wrtd_cmd_global_reset
},
{
"swtrig"
,
""
,
"sends a software trigger"
,
wrtd_cmd_sw_trigger
},
{
"log_level"
,
"<level>"
,
"set logging level (see Log Levels)"
,
wrtd_cmd_log_level
},
{
NULL
}
};
static
void
help
(
void
)
{
fprintf
(
stderr
,
"
\n\n
"
);
fprintf
(
stderr
,
"wrtd-in-config -D DEVICE -c CHANNEL -C COMMAND [cmd-options]
\n\n
"
);
fprintf
(
stderr
,
"It configures an input channel on a White-Rabbit Trigger-Distribution node
\n\n
"
);
fprintf
(
stderr
,
"-D
\t
device id
\n
"
);
fprintf
(
stderr
,
"-C
\t
command name (see Available commands)
\n
"
);
fprintf
(
stderr
,
"-c
\t
channel to configure [0, %d]
\n
"
,
TDC_NUM_CHANNELS
-
1
);
fprintf
(
stderr
,
"
\n\n
"
);
help_commands
(
cmds
);
fprintf
(
stderr
,
"
\n\n
"
);
help_trig_id
();
fprintf
(
stderr
,
"
\n\n
"
);
help_trig_mode
();
fprintf
(
stderr
,
"
\n\n
"
);
help_log_level
();
exit
(
1
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
wrtd_node
*
wrtd
;
uint32_t
dev_id
=
0
;
char
*
endptr
;
char
*
cmd
=
NULL
;
char
c
;
int
err
=
0
,
i
,
chan
=
-
1
;
while
((
c
=
getopt
(
argc
,
argv
,
"hD:c:C:"
))
!=
-
1
)
{
switch
(
c
)
{
case
'h'
:
case
'?'
:
help
();
break
;
case
'D'
:
dev_id
=
strtoul
(
optarg
,
&
endptr
,
0
);
if
(
*
endptr
!=
0
)
dev_id
=
0
;
break
;
case
'c'
:
sscanf
(
optarg
,
"%d"
,
&
chan
);
break
;
case
'C'
:
cmd
=
optarg
;
break
;
}
}
if
(
dev_id
==
0
||
!
cmd
||
chan
==
-
1
)
{
help
();
exit
(
1
);
}
atexit
(
wrtd_exit
);
err
=
wrtd_init
();
if
(
err
)
{
fprintf
(
stderr
,
"Cannot init White Rabbit Trigger Distribution lib: %s
\n
"
,
trtl_strerror
(
errno
));
exit
(
1
);
}
wrtd
=
wrtd_open
(
dev_id
);
if
(
!
wrtd
)
{
fprintf
(
stderr
,
"Cannot open WRNC: %s
\n
"
,
wrtd_strerror
(
errno
));
exit
(
1
);
}
if
(
!
wrtd_in_is_valid
(
wrtd
))
{
fprintf
(
stderr
,
"Cannot run %s: %s
\n
"
,
basename
(
argv
[
0
]),
wrtd_strerror
(
errno
));
goto
out
;
}
for
(
i
=
0
;
cmds
[
i
].
handler
;
i
++
)
{
if
(
!
strcmp
(
cmds
[
i
].
name
,
cmd
))
break
;
}
if
(
cmds
[
i
].
handler
==
NULL
)
{
fprintf
(
stderr
,
"unknown command '%s', try -h
\n
"
,
cmd
);
exit
(
1
);
}
else
{
err
=
cmds
[
i
].
handler
(
wrtd
,
chan
,
argc
-
optind
,
argv
+
optind
);
if
(
err
)
{
fprintf
(
stderr
,
"Error while executing command '%s': %s
\n
"
,
cmd
,
wrtd_strerror
(
errno
));
}
}
out:
wrtd_close
(
wrtd
);
exit
(
0
);
}
software/tools/wrtd-out-config.c
deleted
100644 → 0
View file @
5f6b23a1
This diff is collapsed.
Click to expand it.
software/unittest/.gitignore
deleted
100644 → 0
View file @
5f6b23a1
wrtd-ut
software/unittest/CuTest.c
deleted
100644 → 0
View file @
5f6b23a1
#include <assert.h>
#include <setjmp.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "CuTest.h"
/*-------------------------------------------------------------------------*
* CuStr
*-------------------------------------------------------------------------*/
char
*
CuStrAlloc
(
int
size
)
{
char
*
newStr
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
(
size
)
);
return
newStr
;
}
char
*
CuStrCopy
(
const
char
*
old
)
{
int
len
=
strlen
(
old
);
char
*
newStr
=
CuStrAlloc
(
len
+
1
);
strcpy
(
newStr
,
old
);
return
newStr
;
}
/*-------------------------------------------------------------------------*
* CuString
*-------------------------------------------------------------------------*/
void
CuStringInit
(
CuString
*
str
)
{
str
->
length
=
0
;
str
->
size
=
STRING_MAX
;
str
->
buffer
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
str
->
size
);
str
->
buffer
[
0
]
=
'\0'
;
}
CuString
*
CuStringNew
(
void
)
{
CuString
*
str
=
(
CuString
*
)
malloc
(
sizeof
(
CuString
));
str
->
length
=
0
;
str
->
size
=
STRING_MAX
;
str
->
buffer
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
str
->
size
);
str
->
buffer
[
0
]
=
'\0'
;
return
str
;
}
void
CuStringDelete
(
CuString
*
str
)
{
if
(
!
str
)
return
;
free
(
str
->
buffer
);
free
(
str
);
}
void
CuStringResize
(
CuString
*
str
,
int
newSize
)
{
str
->
buffer
=
(
char
*
)
realloc
(
str
->
buffer
,
sizeof
(
char
)
*
newSize
);
str
->
size
=
newSize
;
}
void
CuStringAppend
(
CuString
*
str
,
const
char
*
text
)
{
int
length
;
if
(
text
==
NULL
)
{
text
=
"NULL"
;
}
length
=
strlen
(
text
);
if
(
str
->
length
+
length
+
1
>=
str
->
size
)
CuStringResize
(
str
,
str
->
length
+
length
+
1
+
STRING_INC
);
str
->
length
+=
length
;
strcat
(
str
->
buffer
,
text
);
}
void
CuStringAppendChar
(
CuString
*
str
,
char
ch
)
{
char
text
[
2
];
text
[
0
]
=
ch
;
text
[
1
]
=
'\0'
;
CuStringAppend
(
str
,
text
);
}
void
CuStringAppendFormat
(
CuString
*
str
,
const
char
*
format
,
...)
{
va_list
argp
;
char
buf
[
HUGE_STRING_LEN
];
va_start
(
argp
,
format
);
vsprintf
(
buf
,
format
,
argp
);
va_end
(
argp
);
CuStringAppend
(
str
,
buf
);
}
void
CuStringInsert
(
CuString
*
str
,
const
char
*
text
,
int
pos
)
{
int
length
=
strlen
(
text
);
if
(
pos
>
str
->
length
)
pos
=
str
->
length
;
if
(
str
->
length
+
length
+
1
>=
str
->
size
)
CuStringResize
(
str
,
str
->
length
+
length
+
1
+
STRING_INC
);
memmove
(
str
->
buffer
+
pos
+
length
,
str
->
buffer
+
pos
,
(
str
->
length
-
pos
)
+
1
);
str
->
length
+=
length
;
memcpy
(
str
->
buffer
+
pos
,
text
,
length
);
}
/*-------------------------------------------------------------------------*
* CuTest
*-------------------------------------------------------------------------*/
void
CuTestInit
(
CuTest
*
t
,
const
char
*
name
,
TestFunction
function
)
{
t
->
name
=
CuStrCopy
(
name
);
t
->
failed
=
0
;
t
->
ran
=
0
;
t
->
message
=
NULL
;
t
->
function
=
function
;
t
->
jumpBuf
=
NULL
;
}
CuTest
*
CuTestNew
(
const
char
*
name
,
TestFunction
function
)
{
CuTest
*
tc
=
CU_ALLOC
(
CuTest
);
CuTestInit
(
tc
,
name
,
function
);
return
tc
;
}
void
CuTestDelete
(
CuTest
*
t
)
{
if
(
!
t
)
return
;
free
(
t
->
name
);
free
(
t
);
}
void
CuTestRun
(
CuTest
*
tc
,
int
verbose
)
{
jmp_buf
buf
;
tc
->
jumpBuf
=
&
buf
;
if
(
setjmp
(
buf
)
==
0
)
{
if
(
verbose
)
{
printf
(
"Running %s: "
,
tc
->
name
);
fflush
(
stdout
);
}
tc
->
ran
=
1
;
(
tc
->
function
)(
tc
);
if
(
verbose
)
{
printf
(
"success
\n
"
);
}
}
else
{
if
(
verbose
)
{
printf
(
"FAILURE!!
\n
"
);
}
}
tc
->
jumpBuf
=
0
;
}
static
void
CuFailInternal
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
CuString
*
string
)
{
char
buf
[
HUGE_STRING_LEN
];
sprintf
(
buf
,
"%s:%d: "
,
file
,
line
);
CuStringInsert
(
string
,
buf
,
0
);
tc
->
failed
=
1
;
tc
->
message
=
string
->
buffer
;
if
(
tc
->
jumpBuf
!=
NULL
)
longjmp
(
*
(
tc
->
jumpBuf
),
1
);
}
void
CuFail_Line
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message2
,
const
char
*
message
)
{
CuString
string
;
CuStringInit
(
&
string
);
if
(
message2
!=
NULL
)
{
CuStringAppend
(
&
string
,
message2
);
CuStringAppend
(
&
string
,
": "
);
}
CuStringAppend
(
&
string
,
message
);
CuFailInternal
(
tc
,
file
,
line
,
&
string
);
}
void
CuAssert_Line
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
int
condition
)
{
if
(
condition
)
return
;
CuFail_Line
(
tc
,
file
,
line
,
NULL
,
message
);
}
void
CuAssertStrEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
const
char
*
expected
,
const
char
*
actual
)
{
CuString
string
;
if
((
expected
==
NULL
&&
actual
==
NULL
)
||
(
expected
!=
NULL
&&
actual
!=
NULL
&&
strcmp
(
expected
,
actual
)
==
0
))
{
return
;
}
CuStringInit
(
&
string
);
if
(
message
!=
NULL
)
{
CuStringAppend
(
&
string
,
message
);
CuStringAppend
(
&
string
,
": "
);
}
CuStringAppend
(
&
string
,
"expected <"
);
CuStringAppend
(
&
string
,
expected
);
CuStringAppend
(
&
string
,
"> but was <"
);
CuStringAppend
(
&
string
,
actual
);
CuStringAppend
(
&
string
,
">"
);
CuFailInternal
(
tc
,
file
,
line
,
&
string
);
}
void
CuAssertIntEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
int
expected
,
int
actual
)
{
char
buf
[
STRING_MAX
];
if
(
expected
==
actual
)
return
;
sprintf
(
buf
,
"expected <%d> but was <%d>"
,
expected
,
actual
);
CuFail_Line
(
tc
,
file
,
line
,
message
,
buf
);
}
void
CuAssertDblEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
double
expected
,
double
actual
,
double
delta
)
{
char
buf
[
STRING_MAX
];
if
(
fabs
(
expected
-
actual
)
<=
delta
)
return
;
sprintf
(
buf
,
"expected <%f> but was <%f>"
,
expected
,
actual
);
CuFail_Line
(
tc
,
file
,
line
,
message
,
buf
);
}
void
CuAssertPtrEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
void
*
expected
,
void
*
actual
)
{
char
buf
[
STRING_MAX
];
if
(
expected
==
actual
)
return
;
sprintf
(
buf
,
"expected pointer <0x%p> but was <0x%p>"
,
expected
,
actual
);
CuFail_Line
(
tc
,
file
,
line
,
message
,
buf
);
}
/*-------------------------------------------------------------------------*
* CuSuite
*-------------------------------------------------------------------------*/
void
CuSuiteInit
(
CuSuite
*
testSuite
)
{
testSuite
->
count
=
0
;
testSuite
->
failCount
=
0
;
memset
(
testSuite
->
list
,
0
,
sizeof
(
testSuite
->
list
));
}
CuSuite
*
CuSuiteNew
(
void
)
{
CuSuite
*
testSuite
=
CU_ALLOC
(
CuSuite
);
CuSuiteInit
(
testSuite
);
return
testSuite
;
}
void
CuSuiteDelete
(
CuSuite
*
testSuite
)
{
unsigned
int
n
;
for
(
n
=
0
;
n
<
MAX_TEST_CASES
;
n
++
)
{
if
(
testSuite
->
list
[
n
])
{
CuTestDelete
(
testSuite
->
list
[
n
]);
}
}
free
(
testSuite
);
}
void
CuSuiteAdd
(
CuSuite
*
testSuite
,
CuTest
*
testCase
)
{
assert
(
testSuite
->
count
<
MAX_TEST_CASES
);
testSuite
->
list
[
testSuite
->
count
]
=
testCase
;
testSuite
->
count
++
;
}
void
CuSuiteAddSuite
(
CuSuite
*
testSuite
,
CuSuite
*
testSuite2
)
{
int
i
;
for
(
i
=
0
;
i
<
testSuite2
->
count
;
++
i
)
{
CuTest
*
testCase
=
testSuite2
->
list
[
i
];
CuSuiteAdd
(
testSuite
,
testCase
);
}
}
void
CuSuiteRun
(
CuSuite
*
testSuite
,
int
verbose
)
{
int
i
;
for
(
i
=
0
;
i
<
testSuite
->
count
;
++
i
)
{
CuTest
*
testCase
=
testSuite
->
list
[
i
];
CuTestRun
(
testCase
,
verbose
);
if
(
testCase
->
failed
)
{
testSuite
->
failCount
+=
1
;
}
}
}
void
CuSuiteSummary
(
CuSuite
*
testSuite
,
CuString
*
summary
)
{
int
i
;
for
(
i
=
0
;
i
<
testSuite
->
count
;
++
i
)
{
CuTest
*
testCase
=
testSuite
->
list
[
i
];
CuStringAppend
(
summary
,
testCase
->
failed
?
"F"
:
"."
);
}
CuStringAppend
(
summary
,
"
\n\n
"
);
}
void
CuSuiteDetails
(
CuSuite
*
testSuite
,
CuString
*
details
)
{
int
i
;
int
failCount
=
0
;
if
(
testSuite
->
failCount
==
0
)
{
int
passCount
=
testSuite
->
count
-
testSuite
->
failCount
;
const
char
*
testWord
=
passCount
==
1
?
"test"
:
"tests"
;
CuStringAppendFormat
(
details
,
"OK (%d %s)
\n
"
,
passCount
,
testWord
);
}
else
{
if
(
testSuite
->
failCount
==
1
)
CuStringAppend
(
details
,
"There was 1 failure:
\n
"
);
else
CuStringAppendFormat
(
details
,
"There were %d failures:
\n
"
,
testSuite
->
failCount
);
for
(
i
=
0
;
i
<
testSuite
->
count
;
++
i
)
{
CuTest
*
testCase
=
testSuite
->
list
[
i
];
if
(
testCase
->
failed
)
{
failCount
++
;
CuStringAppendFormat
(
details
,
"%d) %s: %s
\n
"
,
failCount
,
testCase
->
name
,
testCase
->
message
);
}
}
CuStringAppend
(
details
,
"
\n
!!!FAILURES!!!
\n
"
);
CuStringAppendFormat
(
details
,
"Runs: %d "
,
testSuite
->
count
);
CuStringAppendFormat
(
details
,
"Passes: %d "
,
testSuite
->
count
-
testSuite
->
failCount
);
CuStringAppendFormat
(
details
,
"Fails: %d
\n
"
,
testSuite
->
failCount
);
}
}
software/unittest/CuTest.h
deleted
100644 → 0
View file @
5f6b23a1
#ifndef CU_TEST_H
#define CU_TEST_H
#include <setjmp.h>
#include <stdarg.h>
#define CUTEST_VERSION "CuTest 1.5"
/* CuString */
char
*
CuStrAlloc
(
int
size
);
char
*
CuStrCopy
(
const
char
*
old
);
#define CU_ALLOC(TYPE) ((TYPE*) malloc(sizeof(TYPE)))
#define HUGE_STRING_LEN 8192
#define STRING_MAX 256
#define STRING_INC 256
typedef
struct
{
int
length
;
int
size
;
char
*
buffer
;
}
CuString
;
void
CuStringInit
(
CuString
*
str
);
CuString
*
CuStringNew
(
void
);
void
CuStringRead
(
CuString
*
str
,
const
char
*
path
);
void
CuStringAppend
(
CuString
*
str
,
const
char
*
text
);
void
CuStringAppendChar
(
CuString
*
str
,
char
ch
);
void
CuStringAppendFormat
(
CuString
*
str
,
const
char
*
format
,
...);
void
CuStringInsert
(
CuString
*
str
,
const
char
*
text
,
int
pos
);
void
CuStringResize
(
CuString
*
str
,
int
newSize
);
void
CuStringDelete
(
CuString
*
str
);
/* CuTest */
typedef
struct
CuTest
CuTest
;
typedef
void
(
*
TestFunction
)(
CuTest
*
);
struct
CuTest
{
char
*
name
;
TestFunction
function
;
int
failed
;
int
ran
;
const
char
*
message
;
jmp_buf
*
jumpBuf
;
};
void
CuTestInit
(
CuTest
*
t
,
const
char
*
name
,
TestFunction
function
);
CuTest
*
CuTestNew
(
const
char
*
name
,
TestFunction
function
);
void
CuTestRun
(
CuTest
*
tc
,
int
verbose
);
void
CuTestDelete
(
CuTest
*
t
);
/* Internal versions of assert functions -- use the public versions */
void
CuFail_Line
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message2
,
const
char
*
message
);
void
CuAssert_Line
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
int
condition
);
void
CuAssertStrEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
const
char
*
expected
,
const
char
*
actual
);
void
CuAssertIntEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
int
expected
,
int
actual
);
void
CuAssertDblEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
double
expected
,
double
actual
,
double
delta
);
void
CuAssertPtrEquals_LineMsg
(
CuTest
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
,
void
*
expected
,
void
*
actual
);
/* public assert functions */
#define CuFail(tc, ms) CuFail_Line( (tc), __FILE__, __LINE__, NULL, (ms))
#define CuAssert(tc, ms, cond) CuAssert_Line((tc), __FILE__, __LINE__, (ms), (cond))
#define CuAssertTrue(tc, cond) CuAssert_Line((tc), __FILE__, __LINE__, "assert failed", (cond))
#define CuAssertTrue_Msg(tc, ms, cond) CuAssert_Line((tc), __FILE__, __LINE__, (ms), (cond))
#define CuAssertStrEquals(tc,ex,ac) CuAssertStrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
#define CuAssertStrEquals_Msg(tc,ms,ex,ac) CuAssertStrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
#define CuAssertIntEquals(tc,ex,ac) CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
#define CuAssertIntEquals_Msg(tc,ms,ex,ac) CuAssertIntEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
#define CuAssertDblEquals(tc,ex,ac,dl) CuAssertDblEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac),(dl))
#define CuAssertDblEquals_Msg(tc,ms,ex,ac,dl) CuAssertDblEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac),(dl))
#define CuAssertPtrEquals(tc,ex,ac) CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,NULL,(ex),(ac))
#define CuAssertPtrEquals_Msg(tc,ms,ex,ac) CuAssertPtrEquals_LineMsg((tc),__FILE__,__LINE__,(ms),(ex),(ac))
#define CuAssertPtrNotNull(tc,p) CuAssert_Line((tc),__FILE__,__LINE__,"null pointer unexpected",(p != NULL))
#define CuAssertPtrNotNullMsg(tc,msg,p) CuAssert_Line((tc),__FILE__,__LINE__,(msg),(p != NULL))
/* CuSuite */
#define MAX_TEST_CASES 1024
#define SUITE_ADD_TEST(SUITE,TEST) CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST))
typedef
struct
{
int
count
;
CuTest
*
list
[
MAX_TEST_CASES
];
int
failCount
;
}
CuSuite
;
void
CuSuiteInit
(
CuSuite
*
testSuite
);
CuSuite
*
CuSuiteNew
(
void
);
void
CuSuiteDelete
(
CuSuite
*
testSuite
);
void
CuSuiteAdd
(
CuSuite
*
testSuite
,
CuTest
*
testCase
);
void
CuSuiteAddSuite
(
CuSuite
*
testSuite
,
CuSuite
*
testSuite2
);
void
CuSuiteRun
(
CuSuite
*
testSuite
,
int
verbose
);
void
CuSuiteSummary
(
CuSuite
*
testSuite
,
CuString
*
summary
);
void
CuSuiteDetails
(
CuSuite
*
testSuite
,
CuString
*
details
);
#endif
/* CU_TEST_H */
software/unittest/Makefile
deleted
100644 → 0
View file @
5f6b23a1
# If it exists includes Makefile.specific. In this Makefile, you should put
# specific Makefile code that you want to run before this. For example,
# build a particular environment.
-include
Makefile.specific
# include parent_common.mk for buildsystem's defines
# It allows you to inherit an environment configuration from larger project
REPO_PARENT
?=
..
-include
$(REPO_PARENT)/parent_common.mk
WRTD_DEP_TRTL
?=
../../dependencies/mock-turtle
CFLAGS
+=
-Wall
-ggdb
-O0
CFLAGS
+=
-I
.
-I
../include
-I
$(WRTD_DEP_TRTL)
/software/include
-I
$(WRTD_DEP_TRTL)
/software/lib
-I
../lib
CFLAGS
+=
$(EXTRACFLAGS)
CFLAGS
+=
$(EXTRACFLAGS)
LDLIBS
+=
-Wl
,-Bstatic
-L
../lib
-lwrtd
-L
$(WRTD_DEP_TRTL)
/software/lib
-lmockturtle
LDLIBS
+=
-Wl
,-Bdynamic
PROG
:=
wrtd-ut
SRCS
=
CuTest.c wrtd-ut.c wrtd-ut-common.c wrtd-ut-input.c wrtd-ut-output.c wrtd-ut-op.c
all
:
$(PROG)
clean
:
rm
-f
$(PROG)
*
.o
*
~
.PHONY
:
all
,
clean
wrtd-ut
:
$(SRCS) ../lib/libwrtd.a
$(CC)
$(CFLAGS)
$(LDFLAGS)
$^
$(LDLIBS)
-o
$@
software/unittest/wrtd-ut-common.c
deleted
100644 → 0
View file @
5f6b23a1
/*
* Copyright (C) 2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "wrtd-ut.h"
#include "CuTest.h"
#include <libmockturtle.h>
#include <libwrtd.h>
static
void
test_open_close
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
wrtd
=
wrtd_open
(
1
);
CuAssertTrue
(
tc
,
!!
wrtd
);
CuAssertTrue
(
tc
,
wrtd_out_is_valid
(
wrtd
));
CuAssertTrue
(
tc
,
wrtd_in_is_valid
(
wrtd
));
wrtd_close
(
wrtd
);
}
CuSuite
*
wrtd_ut_cmm_suite_get
(
void
)
{
CuSuite
*
suite
=
CuSuiteNew
();
SUITE_ADD_TEST
(
suite
,
test_open_close
);
return
suite
;
}
software/unittest/wrtd-ut-input.c
deleted
100644 → 0
View file @
5f6b23a1
/*
* Copyright (C) 2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @TODO software trigger test
*/
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include "wrtd-ut.h"
#include "CuTest.h"
#include <libmockturtle.h>
#include <libwrtd.h>
static
void
test_in_ping
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_ping
(
wrtd
));
wrtd_close
(
wrtd
);
}
static
void
test_in_channels_enable
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
unsigned
int
i
,
enable
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_enable
(
wrtd
,
i
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_is_enabled
(
wrtd
,
i
,
&
enable
));
CuAssertTrue
(
tc
,
enable
);
}
wrtd_close
(
wrtd
);
}
static
void
test_in_channels_disable
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
unsigned
int
i
,
enable
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_enable
(
wrtd
,
i
,
0
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_is_enabled
(
wrtd
,
i
,
&
enable
));
CuAssertTrue
(
tc
,
!
enable
);
}
wrtd_close
(
wrtd
);
}
static
void
test_in_channels_arm
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
unsigned
int
i
,
armed
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_arm
(
wrtd
,
i
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_is_armed
(
wrtd
,
i
,
&
armed
));
CuAssertTrue
(
tc
,
armed
);
}
wrtd_close
(
wrtd
);
}
static
void
test_in_channels_disarm
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
unsigned
int
i
,
armed
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_arm
(
wrtd
,
i
,
0
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_is_armed
(
wrtd
,
i
,
&
armed
));
CuAssertTrue
(
tc
,
!
armed
);
}
wrtd_close
(
wrtd
);
}
static
void
test_in_trigger_mode
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
struct
wrtd_input_state
st
;
int
i
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_mode_set
(
wrtd
,
i
,
WRTD_TRIGGER_MODE_SINGLE
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_state_get
(
wrtd
,
i
,
&
st
));
CuAssertIntEquals
(
tc
,
WRTD_TRIGGER_MODE_SINGLE
,
st
.
mode
);
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_mode_set
(
wrtd
,
i
,
WRTD_TRIGGER_MODE_AUTO
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_state_get
(
wrtd
,
i
,
&
st
));
CuAssertIntEquals
(
tc
,
WRTD_TRIGGER_MODE_AUTO
,
st
.
mode
);
}
wrtd_close
(
wrtd
);
}
static
void
test_in_trigger_assign
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
struct
wrtd_input_state
st
;
struct
wrtd_trig_id
id
=
{
1
,
2
,
3
};
unsigned
int
assigned
;
int
i
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
id
.
trigger
=
i
;
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_assign
(
wrtd
,
i
,
&
id
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_state_get
(
wrtd
,
i
,
&
st
));
CuAssertIntEquals
(
tc
,
0
,
memcmp
(
&
id
,
&
st
.
assigned_id
,
sizeof
(
struct
wrtd_trig_id
)));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_has_trigger
(
wrtd
,
i
,
&
assigned
));
CuAssertTrue
(
tc
,
assigned
);
}
wrtd_close
(
wrtd
);
}
static
void
test_in_trigger_unassign
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
struct
wrtd_input_state
st
;
struct
wrtd_trig_id
id
=
{
0
,
0
,
0
};
unsigned
int
assigned
;
int
i
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_unassign
(
wrtd
,
i
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_state_get
(
wrtd
,
i
,
&
st
));
CuAssertIntEquals
(
tc
,
0
,
memcmp
(
&
id
,
&
st
.
assigned_id
,
sizeof
(
struct
wrtd_trig_id
)));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_has_trigger
(
wrtd
,
i
,
&
assigned
));
CuAssertTrue
(
tc
,
!
assigned
);
}
wrtd_close
(
wrtd
);
}
static
void
test_in_trigger_software
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
struct
wrtd_input_state
st
;
struct
wrtd_trigger_entry
trig
=
{
.
ts
=
{
0
,
100
,
0
},
.
id
=
{
1
,
2
,
3
},
};
int
i
,
sent
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
/* It does not matter which channel we query, the sent triggers
value is global */
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_state_get
(
wrtd
,
0
,
&
st
));
sent
=
st
.
sent_packets
;
for
(
i
=
0
;
i
<
100
;
i
++
)
{
trig
.
seq
=
i
;
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_software
(
wrtd
,
&
trig
));
}
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_state_get
(
wrtd
,
0
,
&
st
));
CuAssertIntEquals
(
tc
,
st
.
sent_packets
,
sent
+
100
);
wrtd_close
(
wrtd
);
}
static
void
test_in_reset_counters
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
struct
wrtd_input_state
st
;
int
i
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
FD_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_counters_reset
(
wrtd
,
i
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_state_get
(
wrtd
,
i
,
&
st
));
CuAssertIntEquals
(
tc
,
0
,
st
.
sent_triggers
);
CuAssertIntEquals
(
tc
,
0
,
st
.
total_pulses
);
CuAssertIntEquals
(
tc
,
0
,
(
st
.
flags
&
WRTD_LAST_VALID
));
}
wrtd_close
(
wrtd
);
}
#define RANGE_DEAD 16000
static
void
test_in_dead_time
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
uint64_t
ps
,
min
,
max
;
char
msg
[
128
];
int
i
,
k
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
CuAssertIntEquals
(
tc
,
-
1
,
wrtd_in_dead_time_set
(
wrtd
,
i
,
0
));
CuAssertIntEquals
(
tc
,
EWRTD_INVALID_DEAD_TIME
,
errno
);
CuAssertIntEquals
(
tc
,
-
1
,
wrtd_in_dead_time_set
(
wrtd
,
i
,
170000000000ULL
));
CuAssertIntEquals
(
tc
,
EWRTD_INVALID_DEAD_TIME
,
errno
);
for
(
k
=
0x8000000
;
k
<
0x80000000
;
k
<<=
1
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_dead_time_set
(
wrtd
,
i
,
k
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_dead_time_get
(
wrtd
,
i
,
&
ps
));
min
=
k
<
RANGE_DEAD
?
0
:
k
-
RANGE_DEAD
;
max
=
k
+
RANGE_DEAD
;
sprintf
(
msg
,
"Assert failed - %"
PRIu64
" not in range [%"
PRIu64
", %"
PRIu64
"]"
,
ps
,
min
,
max
);
CuAssertTrue_Msg
(
tc
,
msg
,
ps
>=
min
&&
ps
<=
max
);
}
}
wrtd_close
(
wrtd
);
}
#define RANGE 10
static
void
test_in_delay
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd
;
uint64_t
ps
,
min
,
max
;
char
msg
[
128
];
int
i
,
k
;
wrtd
=
wrtd_open
(
1
);
CuAssertIntEquals
(
tc
,
0
,
!
wrtd
);
for
(
i
=
0
;
i
<
TDC_NUM_CHANNELS
;
i
++
)
{
for
(
k
=
1
;
k
<
8
;
k
<<=
1
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_delay_set
(
wrtd
,
i
,
k
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_delay_get
(
wrtd
,
i
,
&
ps
));
min
=
k
<
RANGE
?
0
:
k
-
RANGE
;
max
=
k
+
RANGE
;
sprintf
(
msg
,
"Assert failed - %"
PRIu64
" not in range [%"
PRIu64
", %"
PRIu64
"]"
,
ps
,
min
,
max
);
CuAssertTrue_Msg
(
tc
,
msg
,
ps
>=
min
&&
ps
<=
max
);
}
}
wrtd_close
(
wrtd
);
}
CuSuite
*
wrtd_ut_in_suite_get
(
void
)
{
CuSuite
*
suite
=
CuSuiteNew
();
SUITE_ADD_TEST
(
suite
,
test_in_ping
);
SUITE_ADD_TEST
(
suite
,
test_in_channels_enable
);
SUITE_ADD_TEST
(
suite
,
test_in_channels_disable
);
SUITE_ADD_TEST
(
suite
,
test_in_channels_arm
);
SUITE_ADD_TEST
(
suite
,
test_in_channels_disarm
);
SUITE_ADD_TEST
(
suite
,
test_in_trigger_mode
);
SUITE_ADD_TEST
(
suite
,
test_in_trigger_assign
);
SUITE_ADD_TEST
(
suite
,
test_in_trigger_unassign
);
SUITE_ADD_TEST
(
suite
,
test_in_trigger_software
);
SUITE_ADD_TEST
(
suite
,
test_in_reset_counters
);
SUITE_ADD_TEST
(
suite
,
test_in_delay
);
SUITE_ADD_TEST
(
suite
,
test_in_dead_time
);
return
suite
;
}
software/unittest/wrtd-ut-op.c
deleted
100644 → 0
View file @
5f6b23a1
This diff is collapsed.
Click to expand it.
software/unittest/wrtd-ut-output.c
deleted
100644 → 0
View file @
5f6b23a1
This diff is collapsed.
Click to expand it.
software/unittest/wrtd-ut.c
deleted
100644 → 0
View file @
5f6b23a1
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include "wrtd-ut.h"
#include "CuTest.h"
CuSuite
*
suite
;
static
void
BuildSuite
(
void
)
{
suite
=
CuSuiteNew
();
CuSuiteAddSuite
(
suite
,
wrtd_ut_in_suite_get
());
CuSuiteAddSuite
(
suite
,
wrtd_ut_out_suite_get
());
CuSuiteAddSuite
(
suite
,
wrtd_ut_cmm_suite_get
());
CuSuiteAddSuite
(
suite
,
wrtd_ut_op_suite_get
());
}
static
void
run
(
CuSuite
*
s
)
{
CuString
*
output
=
CuStringNew
();
CuSuiteRun
(
s
,
1
);
CuSuiteSummary
(
s
,
output
);
CuSuiteDetails
(
s
,
output
);
printf
(
"%s
\n
"
,
output
->
buffer
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
,
j
;
BuildSuite
();
if
(
argc
==
1
)
{
run
(
suite
);
}
else
{
CuSuite
*
suite2
=
CuSuiteNew
();
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
/* Find test for name argv[i]. */
for
(
j
=
0
;
j
<
suite
->
count
;
j
++
)
if
(
strcmp
(
argv
[
i
],
suite
->
list
[
j
]
->
name
)
==
0
)
break
;
if
(
j
==
suite
->
count
)
{
fprintf
(
stderr
,
"cannot find test '%s'
\n
"
,
argv
[
i
]);
return
1
;
}
CuSuiteAdd
(
suite2
,
suite
->
list
[
j
]);
run
(
suite2
);
}
}
return
0
;
}
software/unittest/wrtd-ut.h
deleted
100644 → 0
View file @
5f6b23a1
/*
* Copyright (C) 2014-2016 CERN (www.cern.ch)
* Author: Federico Vaga <federico.vaga@cern.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WRTD_UT_H__
#define __WRTD_UT_H__
#include "CuTest.h"
extern
CuSuite
*
wrtd_ut_cmm_suite_get
(
void
);
extern
CuSuite
*
wrtd_ut_in_suite_get
(
void
);
extern
CuSuite
*
wrtd_ut_out_suite_get
(
void
);
extern
CuSuite
*
wrtd_ut_op_suite_get
(
void
);
#endif
tests/firmware/.gitignore
deleted
100644 → 0
View file @
5f6b23a1
*.elf
*.bin
*.o
*.d
build/
.config
.config.old
tests/firmware/Makefile
deleted
100644 → 0
View file @
5f6b23a1
-include
Makefile.specific
DIRS
:=
rmq-udp
TRTL
?=
../..
TRTL_SW
=
$(TRTL)
/software
all clean cleanall modules install modules_install
:
$(DIRS)
clean
:
TARGET = clean
cleanall
:
TARGET = cleanall
modules
:
TARGET = modules
install
:
TARGET = install
modules_install
:
TARGET = modules_install
DOT-CONFIGS
=
$
(
addsuffix /.config,
$(DIRS)
)
$(DIRS)
:
$(DOT-CONFIGS)
$(MAKE)
-C
$@
$(TARGET)
$(DOT-CONFIGS)
:
$(MAKE)
-C
$
(
@D
)
defconfig
compare_size
:
$(TRTL_SW)
/tools/compare_size.sh
.PHONY
:
all clean cleanall modules install modules_install
.PHONY
:
$(DIRS)
tests/firmware/rmq-udp/Kconfig
deleted
100644 → 0
View file @
5f6b23a1
mainmenu "rmq_udp_send test configuration"
comment "Project specific configuration"
config FPGA_APPLICATION_ID
int "FPGA application ID"
default 0
help
Help text
config RT_APPLICATION_ID
int "RT application ID"
default 0
help
Help text
# include Mock Turtle's Kconfig
source "Kconfig.mt"
tests/firmware/rmq-udp/Makefile
deleted
100644 → 0
View file @
5f6b23a1
-include
../Makefile.specific
OBJS
=
rmq-udp.o
OBJS
+=
# add other object files that you need
OUTPUT
=
fw-rmq-udp
TRTL
?=
../../../dependencies/mock-turtle
TRTL_SW
=
$(TRTL)
/software
CFLAGS_OPT
=
-O0
# disable optimization
MEM_INIT_GEN
=
../../../dependencies/general-cores/tools/mem_init_gen.py
$(OUTPUT).bram
:
$(OUTPUT).bin
python
$(MEM_INIT_GEN)
-i
$<
>
$@
include
$(TRTL_SW)/firmware/Makefile
tests/firmware/rmq-udp/configs/mt_defconfig
deleted
100644 → 0
View file @
5f6b23a1
#
# Automatically generated file; DO NOT EDIT.
# rmq_udp_send test configuration
#
#
# Project specific configuration
#
CONFIG_FPGA_APPLICATION_ID=0
CONFIG_RT_APPLICATION_ID=0
#
# Mock Turtle configuration
#
CONFIG_CFLAGS_OPT="-Os"
CONFIG_CFLAGS_EXTRA="-ggdb"
#
# Mock Turtle framework configuration
#
# CONFIG_MOCKTURTLE_FRAMEWORK_ENABLE is not set
# CONFIG_MOCKTURTLE_FRAMEWORK_ACTION_ENABLE is not set
#
# Mock Turtle library configuration
#
CONFIG_MOCKTURTLE_LIBRARY_PRINT_ENABLE=y
# CONFIG_MOCKTURTLE_LIBRARY_PRINT_DEBUG_ENABLE is not set
# CONFIG_MOCKTURTLE_LIBRARY_PRINT_ERROR_ENABLE is not set
# CONFIG_MOCKTURTLE_LIBRARY_PRINT_MESSAGE_ENABLE is not set
tests/firmware/rmq-udp/rmq-udp.c
deleted
100644 → 0
View file @
5f6b23a1
#include <mockturtle-rt.h>
#define MT_WR_LINK_READY (MT_CPU_LR_WR_STAT_LINK_OK | MT_CPU_LR_WR_STAT_TIME_OK)
void
send_pkt
(
int
rmq
)
{
struct
trtl_fw_msg
msg
;
// queue full? wait
while
(
mq_claim
(
TRTL_RMQ
,
rmq
)
<
0
)
;
mq_map_out_message
(
TRTL_RMQ
,
rmq
,
&
msg
);
msg
.
header
->
len
=
1
;
*
(
int
*
)
msg
.
payload
=
0x12345678
;
pp_printf
(
"TX data
\n
"
);
mq_send
(
TRTL_RMQ
,
rmq
);
}
void
handle_rx
(
int
rmq
)
{
struct
trtl_fw_msg
tmsg
;
while
(
!
mq_poll_in
(
TRTL_RMQ
,
1
<<
rmq
))
;
mq_map_in_message
(
TRTL_RMQ
,
rmq
,
&
tmsg
);
pp_printf
(
"RX data: 0x%08x
\n
"
,
*
(
int
*
)
tmsg
.
payload
);
mq_discard
(
TRTL_RMQ
,
rmq
);
}
int
main
(
void
)
{
int
cpu
=
trtl_get_core_id
();
int
rmq
=
0
;
struct
trtl_ep_eth_address
bind_addr
;
pp_printf
(
"TEST for: RMQ UDP %s
\n
"
,
cpu
==
1
?
"recv"
:
"send"
);
while
((
lr_readl
(
MT_CPU_LR_REG_WR_STAT
)
&
MT_WR_LINK_READY
)
!=
MT_WR_LINK_READY
)
;
pp_printf
(
"WR link up and time valid
\n
"
);
// set up the RMQ Endpoint
// we operate only with UDP frames
bind_addr
.
type
=
TRTL_EP_FRAME_UDP
;
// destination MAC: we use broadcast
bind_addr
.
dst_mac
[
0
]
=
0xff
;
bind_addr
.
dst_mac
[
1
]
=
0xff
;
bind_addr
.
dst_mac
[
2
]
=
0xff
;
bind_addr
.
dst_mac
[
3
]
=
0xff
;
bind_addr
.
dst_mac
[
4
]
=
0xff
;
bind_addr
.
dst_mac
[
5
]
=
0xff
;
// destination port
bind_addr
.
dst_port
=
12345
;
// source port
bind_addr
.
src_port
=
7777
;
// destination IP: 192.168.90.255 (broadcast)
bind_addr
.
dst_ip
=
0xC0A85AFF
;
// source IP: 192.168.90.17
bind_addr
.
src_ip
=
0xC0A85A11
;
bind_addr
.
ethertype
=
0x800
;
// IPv4
// RX filter: we want only UDP packets with matching desination port & IP address.
bind_addr
.
filter
=
TRTL_EP_FILTER_UDP
|
TRTL_EP_FILTER_DST_PORT
|
TRTL_EP_FILTER_DST_IP
;
bind_addr
.
filter
|=
TRTL_EP_FILTER_ENABLE
;
if
(
cpu
==
1
)
{
// configure incoming channel
rmq_bind_in
(
0
,
TRTL_EP_ETH
,
&
bind_addr
);
}
else
{
// configure outgoing channel
rmq_bind_out
(
0
,
TRTL_EP_ETH
,
&
bind_addr
);
}
if
(
cpu
==
1
)
{
while
(
1
)
handle_rx
(
rmq
);
}
else
{
send_pkt
(
rmq
);
}
while
(
1
)
;
return
0
;
}
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