tests: entropy: api: Add nocache buffer option

Add a Kconfig option to put the buffer for random numbers
in the nocache region instead of on the stack.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
diff --git a/tests/drivers/entropy/api/Kconfig b/tests/drivers/entropy/api/Kconfig
new file mode 100644
index 0000000..28767cc
--- /dev/null
+++ b/tests/drivers/entropy/api/Kconfig
@@ -0,0 +1,10 @@
+# Copyright NXP 2022
+# SPDX-License-Identifier: Apache-2.0
+
+mainmenu "Entropy API Test"
+
+source "Kconfig.zephyr"
+source "tests/drivers/entropy/api/Kconfig.mcux"
+
+config RANDOM_BUFFER_NOCACHED
+	bool "Put the buffer of randomly generated numbers in nocache region."
diff --git a/tests/drivers/entropy/api/src/main.c b/tests/drivers/entropy/api/src/main.c
index 3c4d119..803d1dd 100644
--- a/tests/drivers/entropy/api/src/main.c
+++ b/tests/drivers/entropy/api/src/main.c
@@ -25,6 +25,13 @@
 #define BUFFER_LENGTH           10
 #define RECHECK_RANDOM_ENTROPY  0x10
 
+#ifdef CONFIG_RANDOM_BUFFER_NOCACHED
+__attribute__((__section__(".nocache")))
+static uint8_t buffer[BUFFER_LENGTH] = {0};
+#else
+static uint8_t buffer[BUFFER_LENGTH] = {0};
+#endif
+
 static int random_entropy(const struct device *dev, char *buffer, char num)
 {
 	int ret, i;
@@ -69,7 +76,6 @@
 static int get_entropy(void)
 {
 	const struct device *const dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy));
-	uint8_t buffer[BUFFER_LENGTH] = { 0 };
 	int ret;
 
 	if (!device_is_ready(dev)) {