diff options
| author | MurphyZhao <[email protected]> | 2018-12-08 14:46:38 +0800 |
|---|---|---|
| committer | MurphyZhao <[email protected]> | 2018-12-08 14:48:54 +0800 |
| commit | 98b10877e7e885da961b571bdb8cc3460021ba4d (patch) | |
| tree | 47bfe77a0bc7b33e2145d426d079e7db250f10ef /components/utilities | |
| parent | 51b17a15e4393495d72ec350fbfc392dc129753e (diff) | |
[components/utilities/utest] 修复 gcc 编译警告
[components/utilities/utest] 移除组件的版本号
[components/utilities/utest] 优化 basename 函数的处理
Signed-off-by: MurphyZhao <[email protected]>
Diffstat (limited to 'components/utilities')
| -rw-r--r-- | components/utilities/utest/utest.c | 38 | ||||
| -rw-r--r-- | components/utilities/utest/utest.h | 2 | ||||
| -rw-r--r-- | components/utilities/utest/utest_assert.h | 4 |
3 files changed, 12 insertions, 32 deletions
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 <rtthread.h> #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 ")") |
