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
aa239979
Commit
aa239979
authored
Aug 28, 2018
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrtd-ut: clear counters, refactoring.
parent
ae5a988a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
28 deletions
+64
-28
wrtd-ut-op.c
software/unittest/wrtd-ut-op.c
+55
-16
wrtd-ut-output.c
software/unittest/wrtd-ut-output.c
+9
-12
No files found.
software/unittest/wrtd-ut-op.c
View file @
aa239979
...
...
@@ -30,6 +30,33 @@
#include <libmockturtle.h>
#include <libwrtd.h>
/* Clear counters. */
static
void
clear_counters
(
CuTest
*
tc
,
struct
wrtd_node
*
wrtd
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_global_counters_reset
(
wrtd
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_global_counters_reset
(
wrtd
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_counters_reset
(
wrtd
,
0
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_counters_reset
(
wrtd
,
0
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_counters_reset
(
wrtd
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_counters_reset
(
wrtd
,
1
));
}
static
void
test_clear_stat
(
CuTest
*
tc
)
{
struct
wrtd_node
*
wrtd_0
,
*
wrtd_1
;
wrtd_0
=
wrtd_open
(
2
);
CuAssertPtrNotNull
(
tc
,
wrtd_0
);
wrtd_1
=
wrtd_open
(
1
);
CuAssertPtrNotNull
(
tc
,
wrtd_1
);
clear_counters
(
tc
,
wrtd_0
);
clear_counters
(
tc
,
wrtd_1
);
wrtd_close
(
wrtd_0
);
wrtd_close
(
wrtd_1
);
}
/**
* For this test there is no special configuration because it uses the
* internal loopback
...
...
@@ -45,11 +72,7 @@ static void test_msg_loop(CuTest *tc)
wrtd
=
wrtd_open
(
2
);
CuAssertPtrNotNull
(
tc
,
wrtd
);
/* Clear counters. */
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_global_counters_reset
(
wrtd
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_global_counters_reset
(
wrtd
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_counters_reset
(
wrtd
,
0
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_counters_reset
(
wrtd
,
0
));
clear_counters
(
tc
,
wrtd
);
#if 0
CuAssertIntEquals(tc, 0, trtl_cpu_restart(wrtd_get_trtl_dev(wrtd), 0));
...
...
@@ -173,9 +196,14 @@ static void test_msg_wr(CuTest *tc)
* You have to connect a pulse generator to the channel 0 of the TDC
* mezzanine on board with LUN 1.
* You have to put the following lemo cables:
* - LUN 0, FineDelay channel 0 -----> LUN 1 TDC channel 1
* - LUN 0, FineDelay channel 1 -----> LUN 0 TDC channel 1
* - LUN 1, FineDelay channel 0 -----> LUN 0 TDC channel 0
* - LUN 0, FineDelay channel 0 (Out1) -----> LUN 1 TDC channel 1 (In2)
* - LUN 0, FineDelay channel 1 (Out2) -----> LUN 0 TDC channel 0 (In1)
* - LUN 1, FineDelay channel 0 (Out1) -----> LUN 0 TDC channel 1 (In2)
* Path:
* Lun1/In1 -> tid3 -> Lun0/Out2 ->
* Lun0/In1 -> tid1 -> Lun1/Out1 ->
* Lun0/In2 -> tid2 -> Lun0/Out1 -> (loopback)
* Lun1/In2
*/
static
void
test_msg_mix
(
CuTest
*
tc
)
{
...
...
@@ -184,16 +212,20 @@ static void test_msg_mix(CuTest *tc)
struct
wrtd_trig_id
tid_2
=
{
0
,
1
,
1
};
struct
wrtd_trig_id
tid_3
=
{
1
,
0
,
1
};
struct
wrtd_trig_id
tid_4
=
{
1
,
1
,
1
};
struct
wrtd_trigger_handle
h_
2
,
h_3
,
h_4
;
struct
wrtd_trigger_handle
h_
1
,
h_2
,
h_3
;
struct
wrtd_input_state
sti1
,
sti2
;
struct
wrtd_output_state
sto1
,
sto2
;
unsigned
int
prev_msg_2
,
prev_msg_3
,
prev_msg_4
;
const
uint64_t
tdelay
=
200
*
1000
*
1000
;
wrtd_0
=
wrtd_open
(
1
);
CuAssertPtrNotNull
(
tc
,
wrtd_0
);
wrtd_1
=
wrtd_open
(
2
);
CuAssertPtrNotNull
(
tc
,
wrtd_1
);
clear_counters
(
tc
,
wrtd_0
);
clear_counters
(
tc
,
wrtd_1
);
#if 0
CuAssertIntEquals(tc, 0, trtl_cpu_restart(wrtd_get_trtl_dev(wrtd_0), 0));
CuAssertIntEquals(tc, 0, trtl_cpu_restart(wrtd_get_trtl_dev(wrtd_0), 1));
...
...
@@ -218,11 +250,17 @@ static void test_msg_mix(CuTest *tc)
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_mode_set
(
wrtd_0
,
1
,
WRTD_TRIGGER_MODE_AUTO
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_mode_set
(
wrtd_1
,
0
,
WRTD_TRIGGER_MODE_AUTO
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_trigger_mode_set
(
wrtd_1
,
1
,
WRTD_TRIGGER_MODE_AUTO
));
/* Assign trigger output */
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_assign
(
wrtd_1
,
0
,
&
h_2
,
&
tid_2
,
NULL
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_assign
(
wrtd_0
,
0
,
&
h_3
,
&
tid_3
,
NULL
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_assign
(
wrtd_0
,
1
,
&
h_4
,
&
tid_4
,
NULL
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_assign
(
wrtd_0
,
0
,
&
h_2
,
&
tid_2
,
NULL
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_assign
(
wrtd_0
,
1
,
&
h_3
,
&
tid_3
,
NULL
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_assign
(
wrtd_1
,
0
,
&
h_1
,
&
tid_1
,
NULL
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_delay_set
(
wrtd_1
,
&
h_1
,
tdelay
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_delay_set
(
wrtd_0
,
&
h_2
,
tdelay
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_delay_set
(
wrtd_0
,
&
h_3
,
tdelay
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trigger_mode_set
(
wrtd_0
,
0
,
WRTD_TRIGGER_MODE_AUTO
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trigger_mode_set
(
wrtd_1
,
0
,
WRTD_TRIGGER_MODE_AUTO
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trigger_mode_set
(
wrtd_0
,
1
,
WRTD_TRIGGER_MODE_AUTO
));
...
...
@@ -237,9 +275,9 @@ static void test_msg_mix(CuTest *tc)
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_enable
(
wrtd_0
,
0
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_enable
(
wrtd_0
,
1
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_enable
(
wrtd_1
,
0
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_enable
(
wrtd_1
,
&
h_
2
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_enable
(
wrtd_1
,
&
h_
1
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_enable
(
wrtd_0
,
&
h_3
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_enable
(
wrtd_0
,
&
h_
4
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_enable
(
wrtd_0
,
&
h_
2
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_arm
(
wrtd_0
,
0
,
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_in_arm
(
wrtd_0
,
1
,
1
));
...
...
@@ -285,9 +323,9 @@ static void test_msg_mix(CuTest *tc)
&
sto2
.
last_executed
.
id
,
sizeof
(
struct
wrtd_trig_id
)));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_unassign
(
wrtd_1
,
&
h_
2
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_unassign
(
wrtd_1
,
&
h_
1
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_unassign
(
wrtd_0
,
&
h_3
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_unassign
(
wrtd_0
,
&
h_
4
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_unassign
(
wrtd_0
,
&
h_
2
));
/* Close */
wrtd_close
(
wrtd_0
);
...
...
@@ -298,6 +336,7 @@ CuSuite *wrtd_ut_op_suite_get(void)
{
CuSuite
*
suite
=
CuSuiteNew
();
SUITE_ADD_TEST
(
suite
,
test_clear_stat
);
SUITE_ADD_TEST
(
suite
,
test_msg_loop
);
SUITE_ADD_TEST
(
suite
,
test_msg_wr
);
SUITE_ADD_TEST
(
suite
,
test_msg_mix
);
...
...
software/unittest/wrtd-ut-output.c
View file @
aa239979
...
...
@@ -446,24 +446,21 @@ static void test_out_trigger_delay(CuTest *tc)
char
msg
[
128
];
uint64_t
ps
,
min
,
max
;
int
i
,
k
;
int
ret
;
wrtd
=
wrtd_open
(
1
);
for
(
i
=
0
;
i
<
FD_NUM_CHANNELS
;
i
++
)
{
id
.
source_port
=
i
;
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_assign
(
wrtd
,
i
,
&
h
[
i
],
&
id
,
NULL
));
CuAssertIntEquals
(
tc
,
-
1
,
wrtd_out_trig_delay_set
(
wrtd
,
&
h
[
i
],
999999999999
));
ret
=
wrtd_out_trig_assign
(
wrtd
,
i
,
&
h
[
i
],
&
id
,
NULL
);
CuAssertIntEquals
(
tc
,
0
,
ret
);
ret
=
wrtd_out_trig_delay_set
(
wrtd
,
&
h
[
i
],
999999999999
);
CuAssertIntEquals
(
tc
,
-
1
,
ret
);
CuAssertIntEquals
(
tc
,
EWRTD_INVALID_DELAY
,
errno
);
for
(
k
=
1
;
k
<
0x8000000
;
k
<<=
1
)
{
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_delay_set
(
wrtd
,
&
h
[
i
],
k
));
CuAssertIntEquals
(
tc
,
0
,
wrtd_out_trig_state_get_by_handle
(
wrtd
,
&
h
[
i
],
&
trig
));
ret
=
wrtd_out_trig_delay_set
(
wrtd
,
&
h
[
i
],
k
);
CuAssertIntEquals
(
tc
,
0
,
ret
);
ret
=
wrtd_out_trig_state_get_by_handle
(
wrtd
,
&
h
[
i
],
&
trig
);
CuAssertIntEquals
(
tc
,
0
,
ret
);
wrtd_ts_to_pico
(
&
trig
.
delay_trig
,
&
ps
);
/* Conversion is not precise, some approximation may
happen */
...
...
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