From c6fde3dee63ff14469180f280e6bdd286f788a4a Mon Sep 17 00:00:00 2001 From: Dmitrii Golovanov Date: Wed, 6 Nov 2024 23:05:29 +0100 Subject: [PATCH] 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 --- tests/drivers/ipm/src/main.c | 41 +++++++++++++++++++++------------ tests/drivers/ipm/testcase.yaml | 19 +++++++++++++++ 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/tests/drivers/ipm/src/main.c b/tests/drivers/ipm/src/main.c index afd2d9ffce42c..6c1660798d09b 100644 --- a/tests/drivers/ipm/src/main.c +++ b/tests/drivers/ipm/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Intel Corporation + * Copyright (c) 2015-2024 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ @@ -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 @@ -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); diff --git a/tests/drivers/ipm/testcase.yaml b/tests/drivers/ipm/testcase.yaml index 4a9da9054d087..7121a2f309147 100644 --- a/tests/drivers/ipm/testcase.yaml +++ b/tests/drivers/ipm/testcase.yaml @@ -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"