This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new b3d9d96bf testing/ostest: Check the interrupt stack of each CPU.
b3d9d96bf is described below
commit b3d9d96bffab084de8f512e59abf2cc935124330
Author: Marco Casaroli <[email protected]>
AuthorDate: Thu Nov 5 20:21:58 2026 +0100
testing/ostest: Check the interrupt stack of each CPU.
With CONFIG_STACK_COLORATION, each CPU takes an interrupt, then
up_check_intstack() must show some use and some color left. A CPU whose
stack was never colored reports that all of it is used.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
testing/ostest/CMakeLists.txt | 2 +-
testing/ostest/Makefile | 1 +
testing/ostest/intstack.c | 81 +++++++++++++++++++++++++++++++++++++++++++
testing/ostest/ostest.h | 4 +++
testing/ostest/ostest_main.c | 6 ++++
5 files changed, 93 insertions(+), 1 deletion(-)
diff --git a/testing/ostest/CMakeLists.txt b/testing/ostest/CMakeLists.txt
index 387137bd5..921d19202 100644
--- a/testing/ostest/CMakeLists.txt
+++ b/testing/ostest/CMakeLists.txt
@@ -175,7 +175,7 @@ if(CONFIG_TESTING_OSTEST)
endif()
if(CONFIG_SMP)
- list(APPEND SRCS smp_call.c)
+ list(APPEND SRCS smp_call.c intstack.c)
endif()
if(CONFIG_SCHED_EVENTS AND CONFIG_BUILD_FLAT)
diff --git a/testing/ostest/Makefile b/testing/ostest/Makefile
index cee89fc9e..6b07da3a5 100644
--- a/testing/ostest/Makefile
+++ b/testing/ostest/Makefile
@@ -180,6 +180,7 @@ endif
ifeq ($(CONFIG_SMP),y)
CSRCS += smp_call.c
+CSRCS += intstack.c
endif
ifeq ($(CONFIG_SCHED_EVENTS),y)
diff --git a/testing/ostest/intstack.c b/testing/ostest/intstack.c
new file mode 100644
index 000000000..2233f6dd0
--- /dev/null
+++ b/testing/ostest/intstack.c
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * apps/testing/ostest/intstack.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <assert.h>
+#include <stdio.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/sched.h>
+
+#include "ostest.h"
+
+#if defined(CONFIG_SMP) && defined(CONFIG_BUILD_FLAT) && \
+ defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int intstack_func(FAR void *arg)
+{
+ return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: intstack_test
+ *
+ * Description:
+ * Each CPU takes an interrupt, then its interrupt stack must show some
+ * use and must still have some of its color. A stack with no color
+ * reports that all of it is used.
+ *
+ ****************************************************************************/
+
+void intstack_test(void)
+{
+ size_t used;
+ int cpu;
+
+ for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++)
+ {
+ nxsched_smp_call_single(cpu, intstack_func, NULL);
+
+ used = up_check_intstack(cpu, 0);
+ printf("intstack_test: CPU %d used %zu of %d\n", cpu, used,
+ CONFIG_ARCH_INTERRUPTSTACK);
+ ASSERT(used > 0);
+ ASSERT(used < CONFIG_ARCH_INTERRUPTSTACK);
+ }
+
+ printf("intstack_test: Test success\n");
+}
+#endif
diff --git a/testing/ostest/ostest.h b/testing/ostest/ostest.h
index 0ecf7fb83..12e622094 100644
--- a/testing/ostest/ostest.h
+++ b/testing/ostest/ostest.h
@@ -330,6 +330,10 @@ void setjmp_test(void);
#ifdef CONFIG_SMP
void smp_call_test(void);
+
+/* intstack.c ***************************************************************/
+
+void intstack_test(void);
#endif
/* spinlock.c ***************************************************************/
diff --git a/testing/ostest/ostest_main.c b/testing/ostest/ostest_main.c
index 963c6d284..5aa67d8ee 100644
--- a/testing/ostest/ostest_main.c
+++ b/testing/ostest/ostest_main.c
@@ -708,6 +708,12 @@ static int user_main(int argc, char *argv[])
smp_call_test();
#endif
+#if defined(CONFIG_SMP) && defined(CONFIG_BUILD_FLAT) && \
+ defined(CONFIG_STACK_COLORATION) && CONFIG_ARCH_INTERRUPTSTACK > 3
+ printf("\nuser_main: interrupt stack test\n");
+ intstack_test();
+#endif
+
#if defined(CONFIG_SCHED_EVENTS) && defined(CONFIG_BUILD_FLAT)
/* Verify nxevent */