support aliyun sdk on TencentOS tiny
sample: examples\aliyun_iotkit_csdk_mqtt project: board\TencentOS_tiny_EVB_MX_Plus\KEIL\aliyun_iotkit_csdk_mqtt
This commit is contained in:
2426
components/connectivity/iotkit-embedded-3.0.1/3rdparty/tools/build-rules/misc/Doxyfile.tpl
vendored
Normal file
2426
components/connectivity/iotkit-embedded-3.0.1/3rdparty/tools/build-rules/misc/Doxyfile.tpl
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
CONFIG_ENV_CFLAGS += \
|
||||
-Os -Wall \
|
||||
-D_PLATFORM_IS_HOST_ \
|
||||
|
||||
LDFLAGS += -lpthread -lrt
|
@@ -0,0 +1,2 @@
|
||||
CONFIG_ENV_CFLAGS += -Wall
|
||||
CONFIG_ENV_CFLAGS += --coverage
|
192
components/connectivity/iotkit-embedded-3.0.1/3rdparty/tools/build-rules/misc/cut.c
vendored
Normal file
192
components/connectivity/iotkit-embedded-3.0.1/3rdparty/tools/build-rules/misc/cut.c
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
#include "cut.h"
|
||||
|
||||
struct cut_runtime cut;
|
||||
|
||||
static char suite_pattern[64];
|
||||
static char case_pattern[64];
|
||||
|
||||
static void _filter(int argc, char **argv)
|
||||
{
|
||||
int i = 0;
|
||||
struct cut_case *c = NULL;
|
||||
if (argc == 2 && 0 == strcmp(argv[1], "all")) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < cut.ccnt_total; i++) {
|
||||
c = cut.clist[i];
|
||||
if ((argc == 2 && (0 != strcmp(c->sname, argv[1]))) ||
|
||||
(argc == 3 && (0 != strcmp(c->sname, argv[1]) || 0 != strcmp(c->cname, argv[2])))) {
|
||||
|
||||
if (!(argc == 2 && strlen(suite_pattern) && strstr(c->sname, suite_pattern))) {
|
||||
cut.clist[i]->skip = 1;
|
||||
cut.ccnt_skip++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void _usage(const char *me)
|
||||
{
|
||||
cut_printf("Usage: %s [OPTION] S-FILTER [C-FILTER]\n\n" \
|
||||
"OPTION:\n" \
|
||||
" --verbose: verbose when exec cases\n" \
|
||||
" --list: list cases\n" \
|
||||
" --count: print case count\n" \
|
||||
"\n" \
|
||||
"S-FILTER: suite name filter, e.g. '%s all' means run all suites\n" \
|
||||
"C-FILTER: case name filter\n", me, me);
|
||||
}
|
||||
|
||||
static int _verbose_opt = 0;
|
||||
static int _parse_arg(int argc, char **argv)
|
||||
{
|
||||
if (argc >= 2) {
|
||||
if (0 == strcmp(argv[1], "--list")) {
|
||||
int i = 0;
|
||||
int cnt = 0;
|
||||
for (i = 0; i < cut.ccnt_total; i++) {
|
||||
struct cut_case *c = cut.clist[i];
|
||||
if (argc == 2 ||
|
||||
(argc == 3 && 0 == strcmp(argv[2], "all")) ||
|
||||
(argc == 3 && 0 == strcmp(c->sname, argv[2])) ||
|
||||
(argc == 3 && strlen(suite_pattern) && strstr(c->sname, suite_pattern)) ||
|
||||
(argc == 4 && strlen(suite_pattern) && strlen(case_pattern) && strstr(c->sname, suite_pattern)
|
||||
&& strstr(c->cname, case_pattern)) ||
|
||||
(argc == 4 && 0 == strcmp(c->sname, argv[2]) && 0 == strcmp(c->cname, argv[3]))) {
|
||||
cut_printf(" [%02d] %s.%s\n", ++cnt, c->sname, c->cname);
|
||||
}
|
||||
}
|
||||
cut_printf("\n");
|
||||
cut_printf("In total %d case(s), matched %d case(s)\n", cut.ccnt_total, cnt);
|
||||
cut_printf("\n");
|
||||
return 0;
|
||||
}
|
||||
if (0 == strcmp(argv[1], "--count")) {
|
||||
cut_printf("total %d case(s).\n", cut.ccnt_total);
|
||||
return 0;
|
||||
}
|
||||
if (0 == strcmp(argv[1], "--help")) {
|
||||
_usage(argv[0]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cut_main(int argc, char **argv)
|
||||
{
|
||||
int i = 0, j = 0, cnt = 0;
|
||||
char tmpbuf[128];
|
||||
char *pos;
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
int idx = 1;
|
||||
char *q = NULL;
|
||||
|
||||
if (!strcmp(argv[1], "--list") || !strncmp(argv[1], "--verbose", strlen("--verbose"))) {
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
if (idx < argc) {
|
||||
|
||||
if ((q = strchr(argv[idx], '%')) != NULL) {
|
||||
strncpy(suite_pattern, argv[idx], q - argv[idx]);
|
||||
}
|
||||
idx += 1;
|
||||
if (idx < argc) {
|
||||
if ((q = strchr(argv[idx], '%')) != NULL) {
|
||||
strncpy(case_pattern, argv[idx], q - argv[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == _parse_arg(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc >= 2 && !strncmp(argv[1], "--verbose", strlen("--verbose"))) {
|
||||
_verbose_opt = 1;
|
||||
argc --;
|
||||
argv ++;
|
||||
}
|
||||
|
||||
_filter(argc, argv);
|
||||
|
||||
for (; i < cut.ccnt_total; i++) {
|
||||
pos = tmpbuf;
|
||||
|
||||
cut.ccur = cut.clist[i];
|
||||
if (cut.ccur->skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
pos += cut_snprintf(pos,
|
||||
sizeof(tmpbuf),
|
||||
"TEST [%02d/%02d] %s.%s ",
|
||||
++cnt,
|
||||
cut.ccnt_total - cut.ccnt_skip,
|
||||
cut.ccur->sname,
|
||||
cut.ccur->cname);
|
||||
for (j = 80 - strlen(tmpbuf); j >= 0; --j) {
|
||||
pos += sprintf(pos, "%s", ".");
|
||||
}
|
||||
if (_verbose_opt) {
|
||||
pos += sprintf(pos, " [%sEXEC%s]\n", COL_YEL, COL_DEF);
|
||||
cut_printf("%s", tmpbuf);
|
||||
pos -= 19;
|
||||
}
|
||||
TRY {
|
||||
if (cut.ccur->setup)
|
||||
{
|
||||
cut.ccur->setup(cut.ccur->data, cut.ccur);
|
||||
}
|
||||
cut.ccur->run(cut.ccur->data, (struct cut_case *)cut.ccur);
|
||||
if (cut.ccur->teardown)
|
||||
{
|
||||
cut.ccur->teardown(cut.ccur->data);
|
||||
}
|
||||
|
||||
pos += sprintf(pos, " [%sSUCC%s]\n", COL_GRE, COL_DEF);
|
||||
cut_printf("%s", tmpbuf);
|
||||
|
||||
cut.ccnt_pass++;
|
||||
continue;
|
||||
}
|
||||
EXCEPT {
|
||||
|
||||
pos += sprintf(pos, " [%sFAIL%s]\n", COL_RED, COL_DEF);
|
||||
cut_printf("%s", tmpbuf);
|
||||
|
||||
cut.ccnt_fail++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
cut_printf("\n");
|
||||
cut_printf("===========================================================================\n");
|
||||
if (cut.ccnt_fail > 0) {
|
||||
cut_printf("FAIL LIST:\n");
|
||||
for (i = 0; i < cut.ccnt_fail; i++) {
|
||||
cut_printf(" [%02d] %s\n", i + 1, cut.cerrmsg[i]);
|
||||
cut_free(cut.cerrmsg[i]);
|
||||
}
|
||||
cut_printf("---------------------------------------------------------------------------\n");
|
||||
}
|
||||
cut_printf("SUMMARY:\n" \
|
||||
" TOTAL: %d\n" \
|
||||
" SKIPPED: %d\n" \
|
||||
" MATCHED: %d\n" \
|
||||
" PASS: %d\n" \
|
||||
" FAILED: %d\n", cut.ccnt_total, cut.ccnt_skip,
|
||||
cut.ccnt_total - cut.ccnt_skip, cut.ccnt_pass, cut.ccnt_fail);
|
||||
cut_printf("===========================================================================\n");
|
||||
|
||||
return cut.ccnt_fail;
|
||||
|
||||
}
|
||||
|
249
components/connectivity/iotkit-embedded-3.0.1/3rdparty/tools/build-rules/misc/cut.h
vendored
Normal file
249
components/connectivity/iotkit-embedded-3.0.1/3rdparty/tools/build-rules/misc/cut.h
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
#ifndef __CUT_H__
|
||||
#define __CUT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define CUT_CASE_MAX_CNT (1024)
|
||||
#define CUT_MSG_MAX_LEN (512)
|
||||
|
||||
#define cut_printf printf
|
||||
#define cut_snprintf snprintf
|
||||
#define cut_malloc malloc
|
||||
#define cut_free free
|
||||
|
||||
#define CASE2 CASEs
|
||||
|
||||
extern int cut_main(int argc, char **argv);
|
||||
extern struct cut_runtime cut;
|
||||
|
||||
struct cut_case {
|
||||
const char *sname;
|
||||
const char *cname;
|
||||
void *data;
|
||||
void (*run)(void *, void *);
|
||||
void (*setup)(void *, void *);
|
||||
void (*teardown)(void *);
|
||||
int skip;
|
||||
};
|
||||
|
||||
struct cut_runtime {
|
||||
jmp_buf jmpbuf;
|
||||
int scnt_total;
|
||||
int ccnt_total;
|
||||
int ccnt_pass;
|
||||
int ccnt_fail;
|
||||
int ccnt_skip;
|
||||
struct cut_case *clist[CUT_CASE_MAX_CNT];
|
||||
struct cut_case *ccur;
|
||||
char *cerrmsg[CUT_CASE_MAX_CNT];
|
||||
};
|
||||
|
||||
#define CUT_CASE_RUNNER(sname, cname) cut_##sname##_##cname##_run
|
||||
#define CUT_CASE_NAME(sname, cname) cut_##sname##_##cname
|
||||
#define CUT_CASE_DATA(sname) cut_##sname##_data
|
||||
#define CUT_CASE_SETUP(sname) cut_##sname##_setup
|
||||
#define CUT_CASE_TEARDOWN(sname) cut_##sname##_teardown
|
||||
|
||||
#define DATA(sname) \
|
||||
struct CUT_CASE_DATA(sname)
|
||||
|
||||
#define SETUP(sname) \
|
||||
static void CUT_CASE_SETUP(sname)(struct CUT_CASE_DATA(sname) *data, struct cut_case *case_data)
|
||||
|
||||
#define TEARDOWN(sname) \
|
||||
static void CUT_CASE_TEARDOWN(sname)(struct CUT_CASE_DATA(sname) *data)
|
||||
|
||||
|
||||
/*
|
||||
* @brief: construct a test case structor and a test case runner
|
||||
* @sname: suite name
|
||||
* @cname: case name
|
||||
* e.g.
|
||||
CASE(mysuite, mycase1) {
|
||||
// do something here
|
||||
ASSERT_TRUE(1);
|
||||
}
|
||||
*/
|
||||
#define CASE(sname, cname) \
|
||||
static void CUT_CASE_RUNNER(sname, cname)(void *null, struct cut_case *case_data); \
|
||||
static struct cut_case CUT_CASE_NAME(sname, cname) = \
|
||||
{ \
|
||||
#sname, #cname, NULL, (void(*)(void*,void*))CUT_CASE_RUNNER(sname, cname), NULL, NULL, 0}; \
|
||||
static void CUT_CASE_RUNNER(sname, cname)(void *null, struct cut_case *case_data)
|
||||
|
||||
/*
|
||||
* @brief: construct a test case structor and a test case runner
|
||||
* with case_data/setup/teardown for each case.
|
||||
* @sname: suite name
|
||||
* @cname: case name
|
||||
* e.g.
|
||||
CASE_DATA(mysuite) {
|
||||
int errmsg;
|
||||
char *errcode;
|
||||
};
|
||||
|
||||
CASE_SETUP(mysuite) {
|
||||
data->errcode = 0;
|
||||
data->errmsg = (char*)malloc(100);
|
||||
}
|
||||
|
||||
CASE_TEARDOWN(mysuite) {
|
||||
if(data->errmsg) {
|
||||
free(data->errmsg);
|
||||
data->errmsg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CASEs(mysuite, mycase1) {
|
||||
data->errcode = 1;
|
||||
strcpy(data->errmsg, "timeout error");
|
||||
ASSERT_TRUE(1);
|
||||
}
|
||||
*/
|
||||
#define CASEs(sname, cname) \
|
||||
static struct CUT_CASE_DATA(sname) CUT_CASE_DATA(sname); \
|
||||
static void CUT_CASE_RUNNER(sname, cname)(struct CUT_CASE_DATA(sname) * data,struct cut_case *case_data); \
|
||||
static struct cut_case CUT_CASE_NAME(sname, cname) = \
|
||||
{ \
|
||||
#sname, #cname, &CUT_CASE_DATA(sname), (void(*)(void*,void*))CUT_CASE_RUNNER(sname, cname), \
|
||||
(void(*)(void*,void*))CUT_CASE_SETUP(sname), (void(*)(void*))CUT_CASE_TEARDOWN(sname), 0}; \
|
||||
\
|
||||
static void CUT_CASE_RUNNER(sname, cname)(struct CUT_CASE_DATA(sname) * data, struct cut_case *case_data)
|
||||
|
||||
/*
|
||||
* @brief: construct a test suite by adding test case(s)
|
||||
* @sname: suite name
|
||||
* e.g.
|
||||
SUITE(mysuite) = {
|
||||
ADD_CASE(mysuite, mycase1),
|
||||
ADD_CASE(mysuite, mycase2),
|
||||
ADD_CASE_NULL
|
||||
};
|
||||
*/
|
||||
#define SUITE(sname) struct cut_case *cut_suite_##sname[]
|
||||
|
||||
/*
|
||||
* @brief: add a test case into a test suite
|
||||
* @sname: suite name
|
||||
* @cname: case name
|
||||
*/
|
||||
#define ADD_CASE(sname, cname) &CUT_CASE_NAME(sname, cname)
|
||||
#define ADD_CASE_NULL (struct cut_case*)(NULL)
|
||||
|
||||
/*
|
||||
* @brief: add a test suite into case list
|
||||
* @sname: suite name
|
||||
*/
|
||||
#define ADD_SUITE(sname) \
|
||||
do { \
|
||||
int i = 0; \
|
||||
extern struct cut_case *cut_suite_##sname[]; \
|
||||
struct cut_case *c = cut_suite_##sname[i]; \
|
||||
if (cut.ccnt_total >= CUT_CASE_MAX_CNT) { \
|
||||
cut_printf("reaches maximum case count:%d\n", \
|
||||
CUT_CASE_MAX_CNT); \
|
||||
break; \
|
||||
} \
|
||||
while (c) { \
|
||||
*(cut.clist + cut.ccnt_total++) = c; \
|
||||
c = *(cut_suite_##sname + (++i)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define TRY if (0 == setjmp(cut.jmpbuf))
|
||||
#define EXCEPT else
|
||||
#define RAISE_EXCEPTION_WITH_MSG(msg) \
|
||||
do { \
|
||||
int ret = 0, i = cut.ccnt_fail; \
|
||||
cut.cerrmsg[i] = (char*)cut_malloc(CUT_MSG_MAX_LEN); \
|
||||
assert(cut.cerrmsg[i] != NULL); \
|
||||
memset(cut.cerrmsg[i], 0, CUT_MSG_MAX_LEN); \
|
||||
ret = cut_snprintf(cut.cerrmsg[i], \
|
||||
CUT_MSG_MAX_LEN - 1, \
|
||||
"%s.%s in %s(%d) expected %s", \
|
||||
cut.ccur->sname, cut.ccur->cname, \
|
||||
__FILE__, __LINE__, msg); \
|
||||
if (ret >= CUT_MSG_MAX_LEN) \
|
||||
cut_snprintf(cut.cerrmsg[i] + CUT_MSG_MAX_LEN - 4, \
|
||||
4, "..."); \
|
||||
longjmp(cut.jmpbuf, 1); \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT_TRUE(cond) \
|
||||
do { \
|
||||
if (!(cond)) \
|
||||
RAISE_EXCEPTION_WITH_MSG("[True]"); \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT_INT(expected, compare, actual) \
|
||||
do { \
|
||||
if (!((expected)compare(actual))) \
|
||||
RAISE_EXCEPTION_WITH_MSG("[" #expected " " #compare " " #actual "]"); \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT_STR(expected, compare, actual) \
|
||||
do { \
|
||||
if (!(strcmp((expected), (actual)) compare 0)) \
|
||||
RAISE_EXCEPTION_WITH_MSG("[" #expected " " #compare " " #actual "]"); \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT_IN(expected1, actual, expected2) \
|
||||
do { \
|
||||
if ((actual) < (expected1) || (actual) > (expected2)) \
|
||||
RAISE_EXCEPTION_WITH_MSG("[" #expected1 " <= " #actual " <= " #expected2 "]"); \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT_NSTR(expected, compare, actual, len) \
|
||||
do { \
|
||||
if (!(strncmp((expected), (actual), (len)) compare 0)) \
|
||||
RAISE_EXCEPTION_WITH_MSG("[" #expected " " #compare " " #actual "]"); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define ASSERT_FAIL() RAISE_EXCEPTION_WITH_MSG("[should not be here]")
|
||||
#define ASSERT_FALSE(cond) ASSERT_TRUE(!(cond))
|
||||
#define ASSERT_NULL(ptr) ASSERT_INT(ptr, ==, NULL)
|
||||
#define ASSERT_NOT_NULL(ptr) ASSERT_INT(ptr, !=, NULL)
|
||||
#define ASSERT_EQ(actual, expected) ASSERT_INT(actual, ==, expected)
|
||||
#define ASSERT_NE(actual, expected) ASSERT_INT(actual, !=, expected)
|
||||
#define ASSERT_GT(actual, expected) ASSERT_INT(actual, >, expected)
|
||||
#define ASSERT_GE(actual, expected) ASSERT_INT(actual, >=, expected)
|
||||
#define ASSERT_LT(actual, expected) ASSERT_INT(actual, <, expected)
|
||||
#define ASSERT_LE(actual, expected) ASSERT_INT(actual, <=, expected)
|
||||
#define ASSERT_STR_EQ(actual, expected) ASSERT_STR(actual, ==, expected)
|
||||
#define ASSERT_STR_NE(actual, expected) ASSERT_STR(actual, !=, expected)
|
||||
#define ASSERT_STR_GT(actual, expected) ASSERT_STR(actual, >, expected)
|
||||
#define ASSERT_STR_LT(actual, expected) ASSERT_STR(actual, <, expected)
|
||||
#define ASSERT_NSTR_EQ(actual, expected, len) ASSERT_NSTR(actual, ==, expected, len)
|
||||
#define ASSERT_NSTR_NE(actual, expected, len) ASSERT_NSTR(actual, !=, expected, len)
|
||||
#define ASSERT_NSTR_GT(actual, expected, len) ASSERT_NSTR(actual, >, expected, len)
|
||||
#define ASSERT_NSTR_LT(actual, expected, len) ASSERT_NSTR(actual, <, expected, len)
|
||||
|
||||
/*
|
||||
* see http://stackoverflow.com/questions/3585846/color-text-in-terminal-applications-in-unix
|
||||
*/
|
||||
#define COL_DEF "\x1B[0m"
|
||||
#define COL_RED "\x1B[1;31m"
|
||||
#define COL_GRE "\x1B[1;32m"
|
||||
#define COL_YEL "\x1B[1;33m"
|
||||
#define COL_BLU "\x1B[1;34m"
|
||||
#define COL_MAG "\x1B[1;35m"
|
||||
#define COL_CYN "\x1B[1;36m"
|
||||
#define COL_WHE "\x1B[1;37m"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CUT_H__ */
|
||||
|
Reference in New Issue
Block a user