diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 5ba36ff397..0f5a206d3c 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -74,42 +74,24 @@ static void utest_tc_list(void) LOG_I("[testcase name]:%s; [run timeout]:%d", tc_table[i].name, tc_table[i].run_timeout); } } -MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_tc_list, output all utest testcase); +MSH_CMD_EXPORT_ALIAS(utest_tc_list, utest_list, output all utest testcase); -static char *file_basename(const char *file) +static const char *file_basename(const char *file) { - char *ptr = RT_NULL; + char *end_ptr = RT_NULL; char *rst = RT_NULL; - char *file_bak = rt_strdup(file); - uint8_t len = 0; - if ((ptr = strrchr(file_bak, '\\')) != RT_NULL || (ptr = strrchr(file_bak, '/')) != RT_NULL) + + if (!((end_ptr = strrchr(file, '\\')) != RT_NULL || \ + (end_ptr = strrchr(file, '/')) != RT_NULL) || \ + (rt_strlen(file) < 2)) { - rst = ptr; + rst = (char *)file; } else { - rst = file_bak; + rst = (char *)(end_ptr + 1); } - - len = rst - file_bak; - if (rst != file) - { - file_bak[len] = '\0'; - - if ((ptr = strrchr(file_bak, '\\')) != RT_NULL || (ptr = strrchr(file_bak, '/')) != RT_NULL) - { - rst = ptr; - } - else - { - rst = file_bak; - } - len = rst - file_bak; - } - - rt_free(file_bak); - len = len != 0? len + 1 : len; - return (char *)(file + len); + return (const char *)rst; } static void utest_run(const char *utest_name) diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h index 9a5e58fc57..fc01852b6a 100644 --- a/components/utilities/utest/utest.h +++ b/components/utilities/utest/utest.h @@ -14,8 +14,6 @@ #include #include "utest_log.h" -#define UTEST_SW_VERSION "0.0.1" - /** * utest_error * diff --git a/components/utilities/utest/utest_assert.h b/components/utilities/utest/utest_assert.h index e36fdc8af4..997e8ae7f3 100644 --- a/components/utilities/utest/utest_assert.h +++ b/components/utilities/utest/utest_assert.h @@ -43,8 +43,8 @@ void utest_assert_string(const char *a, const char *b, rt_bool_t equal, const ch */ #define uassert_true(value) __utest_assert(value, "(" #value ") is false") #define uassert_false(value) __utest_assert(!(value), "(" #value ") is true") -#define uassert_null(value) __utest_assert((value) == NULL, "(" #value ") is not null") -#define uassert_not_null(value) __utest_assert((value) != NULL, "(" #value ") is null") +#define uassert_null(value) __utest_assert((const char *)(value) == NULL, "(" #value ") is not null") +#define uassert_not_null(value) __utest_assert((const char *)(value) != NULL, "(" #value ") is null") #define uassert_int_equal(a, b) __utest_assert((a) == (b), "(" #a ") not equal to (" #b ")") #define uassert_int_not_equal(a, b) __utest_assert((a) != (b), "(" #a ") equal to (" #b ")")