Skip to content

Commit

Permalink
tests: drivers: ipm: Fix drivers.ipc.mailbox
Browse files Browse the repository at this point in the history
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 <dmitrii.golovanov@intel.com>
  • Loading branch information
golowanow authored and mmahadevan108 committed Nov 8, 2024
1 parent 3ca53ac commit e3ec702
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
41 changes: 26 additions & 15 deletions tests/drivers/ipm/src/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015 Intel Corporation
* Copyright (c) 2015-2024 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -34,7 +34,7 @@ extern struct ipm_driver_api ipm_dummy_api;
struct ipm_dummy_driver_data ipm_dummy0_driver_data;
DEVICE_DEFINE(ipm_dummy0, "ipm_dummy0", NULL,
NULL, &ipm_dummy0_driver_data, NULL,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&ipm_dummy_api);

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

rv = TC_PASS;

TC_SUITE_START("test_ipm");
ipm = device_get_binding("ipm_dummy0");

/* Try sending a raw string to the IPM device to show that the
* receiver works
*/
for (i = 0; i < strlen(thestr); i++) {
ipm_send(ipm, 1, thestr[i], NULL, 0);
if (ipm == NULL) {
TC_ERROR("unable to get device 'ipm_dummy0'\n");
rv = TC_FAIL;
} else {
/* Try sending a raw string to the IPM device to show that the
* receiver works
*/
int rc = 0;

for (i = 0; i < strlen(thestr) && rc == 0; i++) {
rc = ipm_send(ipm, 1, thestr[i], NULL, 0);
}
if (rc) {
TC_ERROR("ipm_send() error=%u\n", rc);
rv = TC_FAIL;
} else {
/* Now do this through printf() to exercise the sender */
/* I will be split to lines of LINE_BUF_SIZE */
printf(LOREM_IPSUM_SHORT "\n");
}
}

/* Now do this through printf() to exercise the sender */
printf(LOREM_IPSUM_SHORT "\n");

/* XXX how to tell if something was actually printed out for
* automation purposes?
/* Twister Console Harness checks the output actually printed out for
* automation purposes.
*/

rv = TC_PASS;
TC_END_RESULT(rv);
TC_SUITE_END("test_ipm", rv);
TC_END_REPORT(rv);
Expand Down
19 changes: 19 additions & 0 deletions tests/drivers/ipm/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,22 @@ tests:
- ipc
integration_platforms:
- qemu_x86
harness: console
harness_config:
type: multi_line
ordered: true
regex:
- "Running TESTSUITE test_ipm"
- "ipm_console: 'everything is awesome'"
- "ipm_console: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, \
sed do eiusmod tempor '"
- "ipm_console: 'incididunt ut labore et dolore magna aliqua. Ut enim ad \
minim veniam, quis nost'"
- "ipm_console: 'rud exercitation ullamco laboris nisi ut aliquip ex ea commodo \
consequat. Duis '"
- "ipm_console: 'aute irure dolor in reprehenderit in voluptate velit esse cillum \
dolore eu fugi'"
- "ipm_console: 'at nulla pariatur. Excepteur sint occaecat cupidatat non proident, \
sunt in culp'"
- "ipm_console: 'a qui officia deserunt mollit anim id est laborum.'"
- "TESTSUITE test_ipm succeeded"

0 comments on commit e3ec702

Please sign in to comment.