-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New SimMock code library for Model developers.
Code library for developing integration test cases. Signed-off-by: Rule Timothy (CC/EMT2) <[email protected]>
- Loading branch information
1 parent
34f5cab
commit 9352943
Showing
22 changed files
with
1,735 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <dse/testing.h> | ||
#include <dse/modelc/mocks/simmock.h> | ||
|
||
int test_setup(void** state) | ||
{ | ||
const char* inst_names[] = { | ||
"target_inst", | ||
"network_inst", | ||
}; | ||
char* argv[] = { | ||
(char*)"test_runnable", | ||
(char*)"--name=target_inst;network_inst", | ||
(char*)"--logger=5", // 1=debug, 5=QUIET (commit with 5!) | ||
(char*)"../../../../tests/cmocka/network/stack.yaml", | ||
(char*)"../../../../tests/cmocka/network/signalgroup.yaml", | ||
(char*)"../../../../tests/cmocka/network/network.yaml", | ||
(char*)"../../../../tests/cmocka/network/model.yaml", | ||
(char*)"../../../../tests/cmocka/network/runnable.yaml", | ||
}; | ||
SimMock* mock = simmock_alloc(inst_names, ARRAY_SIZE(inst_names)); | ||
simmock_configure(mock, argv, ARRAY_SIZE(argv), ARRAY_SIZE(inst_names)); | ||
simmock_load(mock, true); | ||
simmock_setup(mock, "signal", "network"); | ||
|
||
/* Return the mock. */ | ||
*state = mock; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <dse/testing.h> | ||
#include <dse/modelc/mocks/simmock.h> | ||
|
||
void test_network__frame_check(void** state) | ||
{ | ||
SimMock* mock = *state; | ||
|
||
/* 0ms - initial tick, Rx consumed, Tx of initial content. */ | ||
{ | ||
for (uint32_t i = 0; i < 1; i++) { | ||
assert_int_equal(simmock_step(mock, true), 0); | ||
} | ||
FrameCheck f_checks[] = { | ||
{ .frame_id = 0x1f3u, .offset = 0, .value = 0x01 }, | ||
{ .frame_id = 0x1f4u, .offset = 1, .value = 0x02 }, | ||
{ .frame_id = 0x1f5u, .offset = 4, .value = 0x02 }, | ||
}; | ||
simmock_print_network_frames(mock, LOG_DEBUG); | ||
simmock_frame_check(mock, "network_inst", "can_bus", f_checks, ARRAY_SIZE(f_checks)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <dse/testing.h> | ||
#include <dse/modelc/mocks/simmock.h> | ||
|
||
#define SIG_task_init_done 1 | ||
#define SIG_task_5_active 2 | ||
#define SIG_task_5_counter 6 | ||
|
||
void test_network__signal_check(void** state) | ||
{ | ||
SimMock* mock = *state; | ||
|
||
/* 0ms - initial tick, Rx consumed, Tx of initial content. */ | ||
{ | ||
for (uint32_t i = 0; i < 1; i++) { | ||
assert_int_equal(simmock_step(mock, true), 0); | ||
} | ||
SignalCheck s_checks[] = { | ||
{ .index = SIG_task_init_done, .value = 1.0 }, | ||
{ .index = SIG_task_5_active, .value = 0.0 }, | ||
{ .index = SIG_task_5_counter, .value = 0.0 }, | ||
}; | ||
simmock_print_scalar_signals(mock, LOG_DEBUG); | ||
simmock_signal_check(mock, "network_inst", s_checks, ARRAY_SIZE(s_checks), NULL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.