Skip to content

Commit e3ec702

Browse files
golowanowmmahadevan108
authored andcommitted
tests: drivers: ipm: Fix drivers.ipc.mailbox
Fix 'drivers.ipc.mailbox' test suite to restore and improve its testing functionality: * fix printf() redirection through IPM console. * fix and check the dummy driver initialization. * specify correct Twister harness type (Console) and use matching patterns to recognize the expected console output. Signed-off-by: Dmitrii Golovanov <[email protected]>
1 parent 3ca53ac commit e3ec702

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

tests/drivers/ipm/src/main.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015 Intel Corporation
2+
* Copyright (c) 2015-2024 Intel Corporation
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -34,7 +34,7 @@ extern struct ipm_driver_api ipm_dummy_api;
3434
struct ipm_dummy_driver_data ipm_dummy0_driver_data;
3535
DEVICE_DEFINE(ipm_dummy0, "ipm_dummy0", NULL,
3636
NULL, &ipm_dummy0_driver_data, NULL,
37-
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
37+
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
3838
&ipm_dummy_api);
3939

4040
/* Sending side of the console IPM driver, will forward anything sent
@@ -81,24 +81,35 @@ int main(void)
8181
int rv, i;
8282
const struct device *ipm;
8383

84+
rv = TC_PASS;
85+
8486
TC_SUITE_START("test_ipm");
8587
ipm = device_get_binding("ipm_dummy0");
86-
87-
/* Try sending a raw string to the IPM device to show that the
88-
* receiver works
89-
*/
90-
for (i = 0; i < strlen(thestr); i++) {
91-
ipm_send(ipm, 1, thestr[i], NULL, 0);
88+
if (ipm == NULL) {
89+
TC_ERROR("unable to get device 'ipm_dummy0'\n");
90+
rv = TC_FAIL;
91+
} else {
92+
/* Try sending a raw string to the IPM device to show that the
93+
* receiver works
94+
*/
95+
int rc = 0;
96+
97+
for (i = 0; i < strlen(thestr) && rc == 0; i++) {
98+
rc = ipm_send(ipm, 1, thestr[i], NULL, 0);
99+
}
100+
if (rc) {
101+
TC_ERROR("ipm_send() error=%u\n", rc);
102+
rv = TC_FAIL;
103+
} else {
104+
/* Now do this through printf() to exercise the sender */
105+
/* I will be split to lines of LINE_BUF_SIZE */
106+
printf(LOREM_IPSUM_SHORT "\n");
107+
}
92108
}
93-
94-
/* Now do this through printf() to exercise the sender */
95-
printf(LOREM_IPSUM_SHORT "\n");
96-
97-
/* XXX how to tell if something was actually printed out for
98-
* automation purposes?
109+
/* Twister Console Harness checks the output actually printed out for
110+
* automation purposes.
99111
*/
100112

101-
rv = TC_PASS;
102113
TC_END_RESULT(rv);
103114
TC_SUITE_END("test_ipm", rv);
104115
TC_END_REPORT(rv);

tests/drivers/ipm/testcase.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,22 @@ tests:
88
- ipc
99
integration_platforms:
1010
- qemu_x86
11+
harness: console
12+
harness_config:
13+
type: multi_line
14+
ordered: true
15+
regex:
16+
- "Running TESTSUITE test_ipm"
17+
- "ipm_console: 'everything is awesome'"
18+
- "ipm_console: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, \
19+
sed do eiusmod tempor '"
20+
- "ipm_console: 'incididunt ut labore et dolore magna aliqua. Ut enim ad \
21+
minim veniam, quis nost'"
22+
- "ipm_console: 'rud exercitation ullamco laboris nisi ut aliquip ex ea commodo \
23+
consequat. Duis '"
24+
- "ipm_console: 'aute irure dolor in reprehenderit in voluptate velit esse cillum \
25+
dolore eu fugi'"
26+
- "ipm_console: 'at nulla pariatur. Excepteur sint occaecat cupidatat non proident, \
27+
sunt in culp'"
28+
- "ipm_console: 'a qui officia deserunt mollit anim id est laborum.'"
29+
- "TESTSUITE test_ipm succeeded"

0 commit comments

Comments
 (0)