From 9cc710e954bcd9910fa9e67cc20da06d2fa14146 Mon Sep 17 00:00:00 2001 From: Lucas Saavedra Vaz Date: Fri, 26 May 2023 19:50:04 -0300 Subject: [PATCH] testing/nxdiag: Move to "system" and improve info generated Move the application to the "System" category. Improve host OS info by using platform.uname() and get current config file using CONFIG_BASE_DEFCONFIG --- {testing => system}/nxdiag/.gitignore | 0 {testing => system}/nxdiag/Kconfig | 22 ++++++++-------- {testing => system}/nxdiag/Make.defs | 6 ++--- {testing => system}/nxdiag/Makefile | 20 +++++++------- {testing => system}/nxdiag/nxdiag.c | 38 ++++++++++++++------------- tools/host_sysinfo.py | 18 ++++++++----- 6 files changed, 55 insertions(+), 49 deletions(-) rename {testing => system}/nxdiag/.gitignore (100%) rename {testing => system}/nxdiag/Kconfig (84%) rename {testing => system}/nxdiag/Make.defs (89%) rename {testing => system}/nxdiag/Makefile (83%) rename {testing => system}/nxdiag/nxdiag.c (92%) diff --git a/testing/nxdiag/.gitignore b/system/nxdiag/.gitignore similarity index 100% rename from testing/nxdiag/.gitignore rename to system/nxdiag/.gitignore diff --git a/testing/nxdiag/Kconfig b/system/nxdiag/Kconfig similarity index 84% rename from testing/nxdiag/Kconfig rename to system/nxdiag/Kconfig index 2ebea43bc..6a9f5c1e9 100644 --- a/testing/nxdiag/Kconfig +++ b/system/nxdiag/Kconfig @@ -1,4 +1,4 @@ -config TESTING_NXDIAG +menuconfig SYSTEM_NXDIAG bool "System information and diagnostic (nxdiag)" default n ---help--- @@ -6,19 +6,19 @@ config TESTING_NXDIAG and target system information. It can also perform some diagnostic checks on the host and target systems. -if TESTING_NXDIAG +if SYSTEM_NXDIAG -config TESTING_NXDIAG_PRIORITY +config SYSTEM_NXDIAG_PRIORITY int "Nxdiag task priority" default 100 -config TESTING_NXDIAG_STACKSIZE +config SYSTEM_NXDIAG_STACKSIZE int "Nxdiag stack size" default DEFAULT_TASK_STACKSIZE comment "NuttX system information" -config TESTING_NXDIAG_CONF +config SYSTEM_NXDIAG_CONF bool "Get NuttX configuration" default n ---help--- @@ -26,7 +26,7 @@ config TESTING_NXDIAG_CONF used to compile NuttX. This is useful for debugging the host and target systems. Enables the "-c" and "--nuttx-config" options. -config TESTING_NXDIAG_COMP_FLAGS +config SYSTEM_NXDIAG_COMP_FLAGS bool "Get NuttX compilation flags" default n ---help--- @@ -36,7 +36,7 @@ config TESTING_NXDIAG_COMP_FLAGS comment "Host system infromation" -config TESTING_NXDIAG_HOST_PATH +config SYSTEM_NXDIAG_HOST_PATH bool "Get host system PATH" default n ---help--- @@ -44,7 +44,7 @@ config TESTING_NXDIAG_HOST_PATH variable. This is useful for debugging the host system. Enables the "-p" and "--host-path" options. -config TESTING_NXDIAG_HOST_PACKAGES +config SYSTEM_NXDIAG_HOST_PACKAGES bool "Get host system packages" default n ---help--- @@ -52,7 +52,7 @@ config TESTING_NXDIAG_HOST_PACKAGES on the host system. This is useful for debugging the host system. Enables the "-k" and "--host-packages" options. -config TESTING_NXDIAG_HOST_MODULES +config SYSTEM_NXDIAG_HOST_MODULES bool "Get host system python modules" default n ---help--- @@ -62,10 +62,10 @@ config TESTING_NXDIAG_HOST_MODULES comment "Vendor specific information" -config TESTING_NXDIAG_ESPRESSIF +config SYSTEM_NXDIAG_ESPRESSIF bool "Espressif" default n ---help--- Enable Espressif-specific information and checks. -endif +endif # SYSTEM_NXDIAG diff --git a/testing/nxdiag/Make.defs b/system/nxdiag/Make.defs similarity index 89% rename from testing/nxdiag/Make.defs rename to system/nxdiag/Make.defs index 5c1c50994..8ba171698 100644 --- a/testing/nxdiag/Make.defs +++ b/system/nxdiag/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# apps/testing/nxdiag/Make.defs +# apps/system/nxdiag/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -18,6 +18,6 @@ # ############################################################################ -ifneq ($(CONFIG_TESTING_NXDIAG),) -CONFIGURED_APPS += $(APPDIR)/testing/nxdiag +ifneq ($(CONFIG_SYSTEM_NXDIAG),) +CONFIGURED_APPS += $(APPDIR)/system/nxdiag endif diff --git a/testing/nxdiag/Makefile b/system/nxdiag/Makefile similarity index 83% rename from testing/nxdiag/Makefile rename to system/nxdiag/Makefile index d890f4a68..d82d2eb95 100644 --- a/testing/nxdiag/Makefile +++ b/system/nxdiag/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# apps/testing/nxdiag/Makefile +# apps/system/nxdiag/Makefile # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -25,40 +25,40 @@ NXTOOLSDIR = $(APPDIR)/tools # Sysinfo application info PROGNAME = nxdiag -PRIORITY = $(CONFIG_TESTING_NXDIAG_PRIORITY) -STACKSIZE = $(CONFIG_TESTING_NXDIAG_STACKSIZE) -MODULE = $(CONFIG_TESTING_NXDIAG) +PRIORITY = $(CONFIG_SYSTEM_NXDIAG_PRIORITY) +STACKSIZE = $(CONFIG_SYSTEM_NXDIAG_STACKSIZE) +MODULE = $(CONFIG_SYSTEM_NXDIAG) # Sysinfo application MAINSRC = nxdiag.c NXDIAG_FLAGS = "$(realpath $(TOPDIR))" -ifeq ($(CONFIG_TESTING_NXDIAG_CONF),y) +ifeq ($(CONFIG_SYSTEM_NXDIAG_CONF),y) NXDIAG_FLAGS += --config endif -ifeq ($(CONFIG_TESTING_NXDIAG_COMP_FLAGS),y) +ifeq ($(CONFIG_SYSTEM_NXDIAG_COMP_FLAGS),y) NXDIAG_FLAGS += --flags \""$(shell echo '$(CFLAGS)' | sed 's/"/\\\\\\"/g')"\" NXDIAG_FLAGS += \""$(shell echo '$(CXXFLAGS)' | sed 's/"/\\\\\\"/g')"\" NXDIAG_FLAGS += \""$(shell echo '$(LDFLAGS)' | sed 's/"/\\\\\\"/g')"\" endif -ifeq ($(CONFIG_TESTING_NXDIAG_HOST_PACKAGES),y) +ifeq ($(CONFIG_SYSTEM_NXDIAG_HOST_PACKAGES),y) NXDIAG_FLAGS += --packages endif -ifeq ($(CONFIG_TESTING_NXDIAG_HOST_MODULES),y) +ifeq ($(CONFIG_SYSTEM_NXDIAG_HOST_MODULES),y) NXDIAG_FLAGS += --modules endif -ifeq ($(CONFIG_TESTING_NXDIAG_HOST_PATH),y) +ifeq ($(CONFIG_SYSTEM_NXDIAG_HOST_PATH),y) NXDIAG_FLAGS += --path endif # Vendor-specific checks -ifeq ($(CONFIG_TESTING_NXDIAG_ESPRESSIF),y) +ifeq ($(CONFIG_SYSTEM_NXDIAG_ESPRESSIF),y) ifdef ESPTOOL_BINDIR NXDIAG_FLAGS += --espressif "$(ESPTOOL_BINDIR)" else diff --git a/testing/nxdiag/nxdiag.c b/system/nxdiag/nxdiag.c similarity index 92% rename from testing/nxdiag/nxdiag.c rename to system/nxdiag/nxdiag.c index 881090ff8..6c3f218fd 100644 --- a/testing/nxdiag/nxdiag.c +++ b/system/nxdiag/nxdiag.c @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/testing/nxdiag/nxdiag.c + * apps/system/nxdiag/nxdiag.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -29,6 +29,7 @@ #include #include +#include #include #include "sysinfo.h" @@ -45,25 +46,25 @@ static const char *g_valid_args[] = "--help", "-n", "--nuttx", -#ifdef CONFIG_TESTING_NXDIAG_COMP_FLAGS +#ifdef CONFIG_SYSTEM_NXDIAG_COMP_FLAGS "-f", "--flags", #endif -#ifdef CONFIG_TESTING_NXDIAG_CONF +#ifdef CONFIG_SYSTEM_NXDIAG_CONF "-c", "--config", #endif "-o", "--host-os", -#ifdef CONFIG_TESTING_NXDIAG_HOST_PATH +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_PATH "-p", "--host-path", #endif -#ifdef CONFIG_TESTING_NXDIAG_HOST_PACKAGES +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_PACKAGES "-k", "--host-packages", #endif -#ifdef CONFIG_TESTING_NXDIAG_HOST_MODULES +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_MODULES "-m", "--host-modules", #endif @@ -189,25 +190,25 @@ static void print_usage(char *prg) Show this message\n"); fprintf(stderr, " -n, --nuttx \ Output the NuttX operational system information.\n"); -#ifdef CONFIG_TESTING_NXDIAG_COMP_FLAGS +#ifdef CONFIG_SYSTEM_NXDIAG_COMP_FLAGS fprintf(stderr, " -f, --flags \ Output the NuttX compilation and linker flags used.\n"); #endif -#ifdef CONFIG_TESTING_NXDIAG_CONF +#ifdef CONFIG_SYSTEM_NXDIAG_CONF fprintf(stderr, " -c, --config \ Output the NuttX configuration options used.\n"); #endif fprintf(stderr, " -o, --host-os \ Output the host system operational system information.\n"); -#ifdef CONFIG_TESTING_NXDIAG_HOST_PATH +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_PATH fprintf(stderr, " -p, --host-path \ Output the host PATH environment variable.\n"); #endif -#ifdef CONFIG_TESTING_NXDIAG_HOST_PACKAGES +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_PACKAGES fprintf(stderr, " -k, --host-packages \ Output the host installed system packages.\n"); #endif -#ifdef CONFIG_TESTING_NXDIAG_HOST_MODULES +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_MODULES fprintf(stderr, " -m, --host-modules \ Output the host installed Python modules.\n"); #endif @@ -258,10 +259,11 @@ int main(int argc, char *argv[]) #else printf("\tBuild: %s\n", CONFIG_VERSION_BUILD); #endif - printf("\tArch: %s\n\n", CONFIG_ARCH); + printf("\tArch: %s\n", CONFIG_ARCH); + printf("\tConfig: %s\n\n", CONFIG_BASE_DEFCONFIG); } -#ifdef CONFIG_TESTING_NXDIAG_COMP_FLAGS +#ifdef CONFIG_SYSTEM_NXDIAG_COMP_FLAGS if (search_str_in_arr(argc, argv, "-f") || search_str_in_arr(argc, argv, "--flags") || search_str_in_arr(argc, argv, "--all")) @@ -275,7 +277,7 @@ int main(int argc, char *argv[]) } #endif -#ifdef CONFIG_TESTING_NXDIAG_CONF +#ifdef CONFIG_SYSTEM_NXDIAG_CONF if (search_str_in_arr(argc, argv, "-c") || search_str_in_arr(argc, argv, "--config") || search_str_in_arr(argc, argv, "--all")) @@ -295,7 +297,7 @@ int main(int argc, char *argv[]) printf("\t%s\n\n", OS_VERSION); } -#ifdef CONFIG_TESTING_NXDIAG_HOST_PATH +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_PATH if (search_str_in_arr(argc, argv, "-p") || search_str_in_arr(argc, argv, "--host-path") || search_str_in_arr(argc, argv, "--all")) @@ -305,7 +307,7 @@ int main(int argc, char *argv[]) } #endif -#ifdef CONFIG_TESTING_NXDIAG_HOST_PACKAGES +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_PACKAGES if (search_str_in_arr(argc, argv, "-k") || search_str_in_arr(argc, argv, "--host-packages") || search_str_in_arr(argc, argv, "--all")) @@ -315,7 +317,7 @@ int main(int argc, char *argv[]) } #endif -#ifdef CONFIG_TESTING_NXDIAG_HOST_MODULES +#ifdef CONFIG_SYSTEM_NXDIAG_HOST_MODULES if (search_str_in_arr(argc, argv, "-m") || search_str_in_arr(argc, argv, "--host-modules") || search_str_in_arr(argc, argv, "--all")) @@ -336,7 +338,7 @@ int main(int argc, char *argv[]) * in Documentation/applications/nxdiag */ -#ifdef CONFIG_TESTING_NXDIAG_ESPRESSIF +#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF printf("Espressif specific information:\n\n"); printf("Bootloader version:\n"); print_array(ESPRESSIF_BOOTLOADER, ESPRESSIF_BOOTLOADER_ARRAY_SIZE); diff --git a/tools/host_sysinfo.py b/tools/host_sysinfo.py index f258268c8..821901dac 100755 --- a/tools/host_sysinfo.py +++ b/tools/host_sysinfo.py @@ -181,8 +181,7 @@ def get_os_version(): """ Gets the OS distribution and version. This function works on Linux, Windows, and macOS. On Linux, if the distro package is installed, it will be used to - get the OS distribution. Otherwise, the platform.system() function will be - used. + get the OS distribution. Args: None. @@ -192,24 +191,29 @@ def get_os_version(): """ os_name = platform.system() - os_version = platform.release() - os_distro = "" + sys_id = "" if os_name == "Windows": os_distro = "Windows" os_version = platform.win32_ver()[0] + sys_id = f"{os_distro} {os_version}" + elif os_name == "Darwin": os_distro = "macOS" + os_uname = " ".join(platform.uname()) os_version = platform.mac_ver()[0] + sys_id = f"{os_distro} {os_version} {os_uname}" + elif os_name == "Linux": + os_uname = " ".join(platform.uname()) try: import distro - return distro.name(pretty=True) + sys_id = distro.name(pretty=True) + " " + os_uname except ImportError: - os_distro = platform.system() + sys_id = os_uname - return f"{os_distro} {os_version}" + return sys_id def get_compilation_flags(flags):