[components/utilities/utest] 修复 gcc 编译警告

[components/utilities/utest] 移除组件的版本号
[components/utilities/utest] 优化 basename 函数的处理

Signed-off-by: MurphyZhao <d2014zjt@163.com>
This commit is contained in:
MurphyZhao 2018-12-08 14:46:38 +08:00
parent 51b17a15e4
commit 98b10877e7
3 changed files with 12 additions and 32 deletions

View File

@ -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)

View File

@ -14,8 +14,6 @@
#include <rtthread.h>
#include "utest_log.h"
#define UTEST_SW_VERSION "0.0.1"
/**
* utest_error
*

View File

@ -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 ")")