1 /* Copyright (c) 2022 Intel Corporation 2 * SPDX-License-Identifier: Apache-2.0 3 */ 4 #ifndef ZEPHYR_TESTS_INTEL_ADSP_TESTS_H 5 #define ZEPHYR_TESTS_INTEL_ADSP_TESTS_H 6 7 #include <intel_adsp_ipc.h> 8 #include <cavstool.h> 9 10 /* Helper to escape from infinite polling loops with a test failure 11 * instead of a hang. Spins with a relaxation loop so that it works 12 * in interrupt context and doesn't stress shared resources like SRAM 13 */ 14 #define AWAIT(expr) do { \ 15 int i; \ 16 for (i = 0; !(expr) && i < 10000; i++) { \ 17 for (volatile int j = 0; j < 1000; j++) { \ 18 } \ 19 } \ 20 zassert_true(i < 10000, "timeout waiting for %s", #expr); \ 21 } while (0) 22 23 /* Cached copy of the ipm_cavs_host driver's handler. We save it at 24 * the start of the test because we want to do unit testing on the 25 * underlying adsp_ipc device, then recover it later. 26 */ 27 extern intel_adsp_ipc_handler_t ipm_handler; 28 29 #endif /* ZEPHYR_TESTS_INTEL_ADSP_TESTS_H */ 30