You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2025/11/07 16:53:06 UTC
(mynewt-core) 06/26: test/crash_test: Register commands statically
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit f8de2be21bc1ae23a9055420110d3d16cfaf580a
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Sun Jun 1 10:17:04 2025 +0200
test/crash_test: Register commands statically
Now crash shell commands are register at link time to
reduce memory footprint.
No change in functionality.
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
test/crash_test/pkg.yml | 2 ++
test/crash_test/src/crash_cli.c | 11 ++---------
test/crash_test/src/crash_test.c | 6 ------
test/crash_test/src/crash_test_priv.h | 3 ---
4 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/test/crash_test/pkg.yml b/test/crash_test/pkg.yml
index 22ab276d7..110929da6 100644
--- a/test/crash_test/pkg.yml
+++ b/test/crash_test/pkg.yml
@@ -31,5 +31,7 @@ pkg.deps.CRASH_TEST_MGMT:
- "@apache-mynewt-core/encoding/json"
- "@apache-mynewt-mcumgr/cborattr"
+pkg.whole_archive: true
+
pkg.init:
crash_test_init: 'MYNEWT_VAL(CRASH_TEST_SYSINIT_STAGE)'
diff --git a/test/crash_test/src/crash_cli.c b/test/crash_test/src/crash_cli.c
index 9023012b2..8a547f58b 100644
--- a/test/crash_test/src/crash_cli.c
+++ b/test/crash_test/src/crash_cli.c
@@ -20,21 +20,12 @@
#include "os/mynewt.h"
#if MYNEWT_VAL(CRASH_TEST_CLI)
-#include <inttypes.h>
#include <console/console.h>
#include <shell/shell.h>
-#include <stdio.h>
#include <string.h>
-#include "crash_test/crash_test.h"
#include "crash_test_priv.h"
-static int crash_cli_cmd(int argc, char **argv);
-struct shell_cmd crash_cmd_struct = {
- .sc_cmd = "crash",
- .sc_cmd_func = crash_cli_cmd
-};
-
static int
crash_cli_cmd(int argc, char **argv)
{
@@ -45,4 +36,6 @@ crash_cli_cmd(int argc, char **argv)
return 0;
}
+MAKE_SHELL_CMD(crash, crash_cli_cmd, NULL)
+
#endif /* MYNEWT_VAL(CRASH_TEST_CLI) */
diff --git a/test/crash_test/src/crash_test.c b/test/crash_test/src/crash_test.c
index fa3ec785a..12f514e62 100644
--- a/test/crash_test/src/crash_test.c
+++ b/test/crash_test/src/crash_test.c
@@ -27,9 +27,6 @@
#include "crash_test/crash_test.h"
#include "crash_test_priv.h"
-#if MYNEWT_VAL(CRASH_TEST_CLI)
-#include "shell/shell.h"
-#endif
#if MYNEWT_VAL(CRASH_TEST_MGMT)
#include "mgmt/mgmt.h"
#endif
@@ -90,9 +87,6 @@ crash_test_init(void)
/* Ensure this function only gets called by sysinit. */
SYSINIT_ASSERT_ACTIVE();
-#if MYNEWT_VAL(CRASH_TEST_CLI)
- shell_cmd_register(&crash_cmd_struct);
-#endif
#if MYNEWT_VAL(CRASH_TEST_MGMT)
mgmt_register_group(&crash_test_mgmt_group);
#endif
diff --git a/test/crash_test/src/crash_test_priv.h b/test/crash_test/src/crash_test_priv.h
index 7d6bbcb37..e80355857 100644
--- a/test/crash_test/src/crash_test_priv.h
+++ b/test/crash_test/src/crash_test_priv.h
@@ -23,9 +23,6 @@
extern "C" {
#endif
-#if MYNEWT_VAL(CRASH_TEST_CLI)
-extern struct shell_cmd crash_cmd_struct;
-#endif
#if MYNEWT_VAL(CRASH_TEST_MGMT)
extern struct mgmt_group crash_test_mgmt_group;
#endif