Fix linter path and lint code (#170)

* chage syntax checker path

* fix syntax
This commit is contained in:
coreglitch 2020-10-11 17:03:05 +06:00 committed by GitHub
parent 176e608c6d
commit 469dbf58ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 437 additions and 396 deletions

View File

@ -105,7 +105,6 @@ void fatfs_list(void* p) {
while(1) { while(1) {
if(xQueueReceive(event_queue, (void*)&event, portMAX_DELAY)) { if(xQueueReceive(event_queue, (void*)&event, portMAX_DELAY)) {
// process buttons event // process buttons event
if(event.type == EventTypeKey) { if(event.type == EventTypeKey) {
// button pressed // button pressed

View File

@ -24,17 +24,18 @@
#define MINUNIT_MINUNIT_H #define MINUNIT_MINUNIT_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)
#include <Windows.h> #include <Windows.h>
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#define __func__ __FUNCTION__ #define __func__ __FUNCTION__
#endif #endif
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) #elif defined(__unix__) || defined(__unix) || defined(unix) || \
(defined(__APPLE__) && defined(__MACH__))
/* Change POSIX C SOURCE version for pure c99 compilers */ /* Change POSIX C SOURCE version for pure c99 compilers */
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L #if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
@ -42,9 +43,9 @@
#define _POSIX_C_SOURCE 200112L #define _POSIX_C_SOURCE 200112L
#endif #endif
#include <unistd.h> /* POSIX flags */ #include <unistd.h> /* POSIX flags */
#include <time.h> /* clock_gettime(), time() */ #include <time.h> /* clock_gettime(), time() */
#include <sys/time.h> /* gethrtime(), gettimeofday() */ #include <sys/time.h> /* gethrtime(), gettimeofday() */
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/times.h> #include <sys/times.h>
#include <string.h> #include <string.h>
@ -82,314 +83,366 @@ static void (*minunit_teardown)(void) = NULL;
#define MU_TEST(method_name) static void method_name(void) #define MU_TEST(method_name) static void method_name(void)
#define MU_TEST_SUITE(suite_name) static void suite_name(void) #define MU_TEST_SUITE(suite_name) static void suite_name(void)
#define MU__SAFE_BLOCK(block) do {\ #define MU__SAFE_BLOCK(block) \
block\ do { \
} while(0) block \
} while(0)
/* Run test suite and unset setup and teardown functions */ /* Run test suite and unset setup and teardown functions */
#define MU_RUN_SUITE(suite_name) MU__SAFE_BLOCK(\ #define MU_RUN_SUITE(suite_name) \
suite_name();\ MU__SAFE_BLOCK(suite_name(); minunit_setup = NULL; minunit_teardown = NULL;)
minunit_setup = NULL;\
minunit_teardown = NULL;\
)
/* Configure setup and teardown functions */ /* Configure setup and teardown functions */
#define MU_SUITE_CONFIGURE(setup_fun, teardown_fun) MU__SAFE_BLOCK(\ #define MU_SUITE_CONFIGURE(setup_fun, teardown_fun) \
minunit_setup = setup_fun;\ MU__SAFE_BLOCK(minunit_setup = setup_fun; minunit_teardown = teardown_fun;)
minunit_teardown = teardown_fun;\
)
/* Test runner */ /* Test runner */
#define MU_RUN_TEST(test) MU__SAFE_BLOCK(\ #define MU_RUN_TEST(test) \
if (minunit_real_timer==0 && minunit_proc_timer==0) {\ MU__SAFE_BLOCK( \
minunit_real_timer = mu_timer_real();\ if(minunit_real_timer == 0 && minunit_proc_timer == 0) { \
minunit_proc_timer = mu_timer_cpu();\ minunit_real_timer = mu_timer_real(); \
}\ minunit_proc_timer = mu_timer_cpu(); \
if (minunit_setup) (*minunit_setup)();\ } if(minunit_setup) (*minunit_setup)(); \
minunit_status = 0;\ minunit_status = 0; \
test();\ test(); \
minunit_run++;\ minunit_run++; \
if (minunit_status) {\ if(minunit_status) { \
minunit_fail++;\ minunit_fail++; \
printf("F");\ printf("F"); \
printf("\n%s\n", minunit_last_message);\ printf("\n%s\n", minunit_last_message); \
}\ } fflush(stdout); \
fflush(stdout);\ if(minunit_teardown)(*minunit_teardown)();)
if (minunit_teardown) (*minunit_teardown)();\
)
/* Report */ /* Report */
#define MU_REPORT() MU__SAFE_BLOCK(\ #define MU_REPORT() \
double minunit_end_real_timer;\ MU__SAFE_BLOCK(double minunit_end_real_timer; double minunit_end_proc_timer; printf( \
double minunit_end_proc_timer;\ "\n\n%d tests, %d assertions, %d failures\n", \
printf("\n\n%d tests, %d assertions, %d failures\n", minunit_run, minunit_assert, minunit_fail);\ minunit_run, \
minunit_end_real_timer = mu_timer_real();\ minunit_assert, \
minunit_end_proc_timer = mu_timer_cpu();\ minunit_fail); \
printf("\nFinished in %.8f seconds (real) %.8f seconds (proc)\n\n",\ minunit_end_real_timer = mu_timer_real(); \
minunit_end_real_timer - minunit_real_timer,\ minunit_end_proc_timer = mu_timer_cpu(); \
minunit_end_proc_timer - minunit_proc_timer);\ printf( \
) "\nFinished in %.8f seconds (real) %.8f seconds (proc)\n\n", \
minunit_end_real_timer - minunit_real_timer, \
minunit_end_proc_timer - minunit_proc_timer);)
#define MU_EXIT_CODE minunit_fail #define MU_EXIT_CODE minunit_fail
/* Assertions */ /* Assertions */
#define mu_check(test) MU__SAFE_BLOCK(\ #define mu_check(test) \
minunit_assert++;\ MU__SAFE_BLOCK( \
if (!(test)) {\ minunit_assert++; if(!(test)) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, #test);\ snprintf( \
minunit_status = 1;\ minunit_last_message, \
return;\ MINUNIT_MESSAGE_LEN, \
} else {\ "%s failed:\n\t%s:%d: %s", \
printf(".");\ __func__, \
}\ __FILE__, \
) __LINE__, \
#test); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_fail(message) MU__SAFE_BLOCK(\ #define mu_fail(message) \
minunit_assert++;\ MU__SAFE_BLOCK(minunit_assert++; snprintf( \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, message);\ minunit_last_message, \
minunit_status = 1;\ MINUNIT_MESSAGE_LEN, \
return;\ "%s failed:\n\t%s:%d: %s", \
) __func__, \
__FILE__, \
__LINE__, \
message); \
minunit_status = 1; \
return;)
#define mu_assert(test, message) MU__SAFE_BLOCK(\ #define mu_assert(test, message) \
minunit_assert++;\ MU__SAFE_BLOCK( \
if (!(test)) {\ minunit_assert++; if(!(test)) { \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %s", __func__, __FILE__, __LINE__, message);\ snprintf( \
minunit_status = 1;\ minunit_last_message, \
return;\ MINUNIT_MESSAGE_LEN, \
} else {\ "%s failed:\n\t%s:%d: %s", \
printf(".");\ __func__, \
}\ __FILE__, \
) __LINE__, \
message); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_int_eq(expected, result) MU__SAFE_BLOCK(\ #define mu_assert_int_eq(expected, result) \
int minunit_tmp_e;\ MU__SAFE_BLOCK( \
int minunit_tmp_r;\ int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_assert++;\ minunit_tmp_r = (result); \
minunit_tmp_e = (expected);\ if(minunit_tmp_e != minunit_tmp_r) { \
minunit_tmp_r = (result);\ snprintf( \
if (minunit_tmp_e != minunit_tmp_r) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d expected but was %d", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %d expected but was %d", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_e, \
) minunit_tmp_r); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_int_not_eq(expected, result) MU__SAFE_BLOCK(\ #define mu_assert_int_not_eq(expected, result) \
int minunit_tmp_e;\ MU__SAFE_BLOCK( \
int minunit_tmp_r;\ int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_assert++;\ minunit_tmp_r = (result); \
minunit_tmp_e = (expected);\ if(minunit_tmp_e == minunit_tmp_r) { \
minunit_tmp_r = (result);\ snprintf( \
if (minunit_tmp_e == minunit_tmp_r) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: expected different results but both were %d", __func__, __FILE__, __LINE__, minunit_tmp_e);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: expected different results but both were %d", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_e); \
) minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_int_greater_than(val, result) MU__SAFE_BLOCK(\ #define mu_assert_int_greater_than(val, result) \
int minunit_tmp_e;\ MU__SAFE_BLOCK( \
int minunit_tmp_r;\ int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_assert++;\ minunit_tmp_r = (result); \
minunit_tmp_e = (val);\ if(val >= minunit_tmp_r) { \
minunit_tmp_r = (result);\ snprintf( \
if (val >= minunit_tmp_r) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d <= %d", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %d <= %d", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_r, \
) minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_int_less_than(val, result) MU__SAFE_BLOCK(\ #define mu_assert_int_less_than(val, result) \
int minunit_tmp_e;\ MU__SAFE_BLOCK( \
int minunit_tmp_r;\ int minunit_tmp_e; int minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_assert++;\ minunit_tmp_r = (result); \
minunit_tmp_e = (val);\ if(val <= minunit_tmp_r) { \
minunit_tmp_r = (result);\ snprintf( \
if (val <= minunit_tmp_r) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d >= %d", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %d >= %d", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_r, \
) minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_int_between(expected_lower, expected_upper, result) MU__SAFE_BLOCK(\ #define mu_assert_int_between(expected_lower, expected_upper, result) \
int minunit_tmp_e;\ MU__SAFE_BLOCK( \
int minunit_tmp_m;\ int minunit_tmp_e; int minunit_tmp_m; int minunit_tmp_r; minunit_assert++; \
int minunit_tmp_r;\ minunit_tmp_e = (expected_lower); \
minunit_assert++;\ minunit_tmp_m = (expected_upper); \
minunit_tmp_e = (expected_lower);\ minunit_tmp_r = (result); \
minunit_tmp_m = (expected_upper);\ if(result < minunit_tmp_e || result > minunit_tmp_m) { \
minunit_tmp_r = (result);\ snprintf( \
if (result < minunit_tmp_e || result > minunit_tmp_m) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %d was not between (inclusive) %d and %d", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r, minunit_tmp_m);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %d was not between (inclusive) %d and %d", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_e, \
) minunit_tmp_r, \
minunit_tmp_m); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_int_in(expected, array_length, result) MU__SAFE_BLOCK(\ #define mu_assert_int_in(expected, array_length, result) \
int minunit_tmp_r;\ MU__SAFE_BLOCK( \
minunit_assert++;\ int minunit_tmp_r; minunit_assert++; minunit_tmp_r = (result); int t = 0; int i; \
minunit_tmp_r = (result);\ for(i = 0; i < array_length; i++) { \
int t = 0;\ if(expected[i] == minunit_tmp_r) t = 1; \
int i;\ } if(t == 0) { \
for (i = 0; i < array_length; i++) {\ char tmp[500] = {0}; \
if (expected[i] == minunit_tmp_r)\ tmp[0] = '['; \
t = 1;\ for(i = 0; i < array_length; i++) { \
}\ sprintf(tmp + strlen(tmp), "%d, ", expected[i]); \
if (t == 0) {\ } \
char tmp[500] = {0};\ int len = strlen(tmp); \
tmp[0] = '[';\ tmp[len - 2] = ']'; \
for (i = 0; i < array_length; i++) {\ tmp[len - 1] = '\0'; \
sprintf(tmp + strlen(tmp), "%d, ", expected[i]);\ snprintf( \
}\ minunit_last_message, \
int len = strlen(tmp);\ MINUNIT_MESSAGE_LEN, \
tmp[len - 2] = ']';\ "%s failed:\n\t%s:%d: expected to be one of %s but was %d", \
tmp[len - 1] = '\0';\ __func__, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: expected to be one of %s but was %d", __func__, __FILE__, __LINE__, tmp, minunit_tmp_r);\ __FILE__, \
minunit_status = 1;\ __LINE__, \
return;\ tmp, \
} else {\ minunit_tmp_r); \
printf(".");\ minunit_status = 1; \
}\ return; \
) } else { printf("."); })
#define mu_assert_double_eq(expected, result) MU__SAFE_BLOCK(\ #define mu_assert_double_eq(expected, result) \
double minunit_tmp_e;\ MU__SAFE_BLOCK( \
double minunit_tmp_r;\ double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (expected); \
minunit_assert++;\ minunit_tmp_r = (result); \
minunit_tmp_e = (expected);\ if(fabs(minunit_tmp_e - minunit_tmp_r) > MINUNIT_EPSILON) { \
minunit_tmp_r = (result);\ int minunit_significant_figures = 1 - log10(MINUNIT_EPSILON); \
if (fabs(minunit_tmp_e-minunit_tmp_r) > MINUNIT_EPSILON) {\ snprintf( \
int minunit_significant_figures = 1 - log10(MINUNIT_EPSILON);\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %.*g expected but was %.*g", __func__, __FILE__, __LINE__, minunit_significant_figures, minunit_tmp_e, minunit_significant_figures, minunit_tmp_r);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %.*g expected but was %.*g", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_significant_figures, \
) minunit_tmp_e, \
minunit_significant_figures, \
minunit_tmp_r); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_double_greater_than(val, result) MU__SAFE_BLOCK(\ #define mu_assert_double_greater_than(val, result) \
double minunit_tmp_e;\ MU__SAFE_BLOCK( \
double minunit_tmp_r;\ double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_assert++;\ minunit_tmp_r = (result); \
minunit_tmp_e = (val);\ if(val >= minunit_tmp_r) { \
minunit_tmp_r = (result);\ snprintf( \
if (val >= minunit_tmp_r) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %f <= %f", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %f <= %f", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_r, \
) minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_double_less_than(val, result) MU__SAFE_BLOCK(\ #define mu_assert_double_less_than(val, result) \
double minunit_tmp_e;\ MU__SAFE_BLOCK( \
double minunit_tmp_r;\ double minunit_tmp_e; double minunit_tmp_r; minunit_assert++; minunit_tmp_e = (val); \
minunit_assert++;\ minunit_tmp_r = (result); \
minunit_tmp_e = (val);\ if(val <= minunit_tmp_r) { \
minunit_tmp_r = (result);\ snprintf( \
if (val <= minunit_tmp_r) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %f >= %f", __func__, __FILE__, __LINE__, minunit_tmp_r, minunit_tmp_e);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %f >= %f", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_r, \
) minunit_tmp_e); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_double_between(expected_lower, expected_upper, result) MU__SAFE_BLOCK(\ #define mu_assert_double_between(expected_lower, expected_upper, result) \
double minunit_tmp_e;\ MU__SAFE_BLOCK( \
double minunit_tmp_m;\ double minunit_tmp_e; double minunit_tmp_m; double minunit_tmp_r; minunit_assert++; \
double minunit_tmp_r;\ minunit_tmp_e = (expected_lower); \
minunit_assert++;\ minunit_tmp_m = (expected_upper); \
minunit_tmp_e = (expected_lower);\ minunit_tmp_r = (result); \
minunit_tmp_m = (expected_upper);\ if(result < minunit_tmp_e || result > minunit_tmp_m) { \
minunit_tmp_r = (result);\ snprintf( \
if (result < minunit_tmp_e || result > minunit_tmp_m) {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: %f was not between (inclusive) %f and %f", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r, minunit_tmp_m);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: %f was not between (inclusive) %f and %f", \
return;\ __func__, \
} else {\ __FILE__, \
printf(".");\ __LINE__, \
}\ minunit_tmp_e, \
) minunit_tmp_r, \
minunit_tmp_m); \
minunit_status = 1; \
return; \
} else { printf("."); })
#define mu_assert_string_eq(expected, result) MU__SAFE_BLOCK(\ #define mu_assert_string_eq(expected, result) \
const char* minunit_tmp_e = expected;\ MU__SAFE_BLOCK( \
const char* minunit_tmp_r = result;\ const char* minunit_tmp_e = expected; const char* minunit_tmp_r = result; \
minunit_assert++;\ minunit_assert++; \
if (!minunit_tmp_e) {\ if(!minunit_tmp_e) { minunit_tmp_e = "<null pointer>"; } if(!minunit_tmp_r) { \
minunit_tmp_e = "<null pointer>";\ minunit_tmp_r = "<null pointer>"; \
}\ } if(strcmp(minunit_tmp_e, minunit_tmp_r)) { \
if (!minunit_tmp_r) {\ snprintf( \
minunit_tmp_r = "<null pointer>";\ minunit_last_message, \
}\ MINUNIT_MESSAGE_LEN, \
if(strcmp(minunit_tmp_e, minunit_tmp_r)) {\ "%s failed:\n\t%s:%d: '%s' expected but was '%s'", \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: '%s' expected but was '%s'", __func__, __FILE__, __LINE__, minunit_tmp_e, minunit_tmp_r);\ __func__, \
minunit_status = 1;\ __FILE__, \
return;\ __LINE__, \
} else {\ minunit_tmp_e, \
printf(".");\ minunit_tmp_r); \
}\ minunit_status = 1; \
) return; \
} else { printf("."); })
#define mu_assert_null(result) MU__SAFE_BLOCK(\ #define mu_assert_null(result) \
minunit_assert++;\ MU__SAFE_BLOCK( \
if (result == NULL) {\ minunit_assert++; if(result == NULL) { printf("."); } else { \
printf(".");\ snprintf( \
} else {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected result was not NULL", __func__, __FILE__, __LINE__);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: Expected result was not NULL", \
return;\ __func__, \
}\ __FILE__, \
) __LINE__); \
minunit_status = 1; \
return; \
})
#define mu_assert_not_null(result) MU__SAFE_BLOCK(\ #define mu_assert_not_null(result) \
minunit_assert++;\ MU__SAFE_BLOCK( \
if (result != NULL) {\ minunit_assert++; if(result != NULL) { printf("."); } else { \
printf(".");\ snprintf( \
} else {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected result was not NULL", __func__, __FILE__, __LINE__);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: Expected result was not NULL", \
return;\ __func__, \
}\ __FILE__, \
) __LINE__); \
minunit_status = 1; \
return; \
})
#define mu_assert_pointers_eq(pointer1, pointer2) MU__SAFE_BLOCK(\ #define mu_assert_pointers_eq(pointer1, pointer2) \
minunit_assert++;\ MU__SAFE_BLOCK( \
if (pointer1 == pointer2) {\ minunit_assert++; if(pointer1 == pointer2) { printf("."); } else { \
printf(".");\ snprintf( \
} else {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", __func__, __FILE__, __LINE__);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
return;\ __func__, \
}\ __FILE__, \
) __LINE__); \
minunit_status = 1; \
return; \
})
#define mu_assert_pointers_not_eq(pointer1, pointer2) MU__SAFE_BLOCK(\ #define mu_assert_pointers_not_eq(pointer1, pointer2) \
minunit_assert++;\ MU__SAFE_BLOCK( \
if (pointer1 != pointer2) {\ minunit_assert++; if(pointer1 != pointer2) { printf("."); } else { \
printf(".");\ snprintf( \
} else {\ minunit_last_message, \
snprintf(minunit_last_message, MINUNIT_MESSAGE_LEN, "%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", __func__, __FILE__, __LINE__);\ MINUNIT_MESSAGE_LEN, \
minunit_status = 1;\ "%s failed:\n\t%s:%d: Expected the pointers to point to the same memory location", \
return;\ __func__, \
}\ __FILE__, \
) __LINE__); \
minunit_status = 1; \
return; \
})
/* /*
* The following two functions were written by David Robert Nadeau * The following two functions were written by David Robert Nadeau
@ -404,74 +457,71 @@ static void (*minunit_teardown)(void) = NULL;
* The returned real time is only useful for computing an elapsed time * The returned real time is only useful for computing an elapsed time
* between two calls to this function. * between two calls to this function.
*/ */
static double mu_timer_real(void) static double mu_timer_real(void) {
{
#if defined(_WIN32) #if defined(_WIN32)
/* Windows 2000 and later. ---------------------------------- */ /* Windows 2000 and later. ---------------------------------- */
LARGE_INTEGER Time; LARGE_INTEGER Time;
LARGE_INTEGER Frequency; LARGE_INTEGER Frequency;
QueryPerformanceFrequency(&Frequency); QueryPerformanceFrequency(&Frequency);
QueryPerformanceCounter(&Time); QueryPerformanceCounter(&Time);
Time.QuadPart *= 1000000; Time.QuadPart *= 1000000;
Time.QuadPart /= Frequency.QuadPart; Time.QuadPart /= Frequency.QuadPart;
return (double)Time.QuadPart / 1000000.0; return (double)Time.QuadPart / 1000000.0;
#elif (defined(__hpux) || defined(hpux)) || ((defined(__sun__) || defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__))) #elif(defined(__hpux) || defined(hpux)) || \
/* HP-UX, Solaris. ------------------------------------------ */ ((defined(__sun__) || defined(__sun) || defined(sun)) && \
return (double)gethrtime( ) / 1000000000.0; (defined(__SVR4) || defined(__svr4__)))
/* HP-UX, Solaris. ------------------------------------------ */
return (double)gethrtime() / 1000000000.0;
#elif defined(__MACH__) && defined(__APPLE__) #elif defined(__MACH__) && defined(__APPLE__)
/* OSX. ----------------------------------------------------- */ /* OSX. ----------------------------------------------------- */
static double timeConvert = 0.0; static double timeConvert = 0.0;
if ( timeConvert == 0.0 ) if(timeConvert == 0.0) {
{ mach_timebase_info_data_t timeBase;
mach_timebase_info_data_t timeBase; (void)mach_timebase_info(&timeBase);
(void)mach_timebase_info( &timeBase ); timeConvert = (double)timeBase.numer / (double)timeBase.denom / 1000000000.0;
timeConvert = (double)timeBase.numer / }
(double)timeBase.denom / return (double)mach_absolute_time() * timeConvert;
1000000000.0;
}
return (double)mach_absolute_time( ) * timeConvert;
#elif defined(_POSIX_VERSION) #elif defined(_POSIX_VERSION)
/* POSIX. --------------------------------------------------- */ /* POSIX. --------------------------------------------------- */
struct timeval tm; struct timeval tm;
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) #if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
{ {
struct timespec ts; struct timespec ts;
#if defined(CLOCK_MONOTONIC_PRECISE) #if defined(CLOCK_MONOTONIC_PRECISE)
/* BSD. --------------------------------------------- */ /* BSD. --------------------------------------------- */
const clockid_t id = CLOCK_MONOTONIC_PRECISE; const clockid_t id = CLOCK_MONOTONIC_PRECISE;
#elif defined(CLOCK_MONOTONIC_RAW) #elif defined(CLOCK_MONOTONIC_RAW)
/* Linux. ------------------------------------------- */ /* Linux. ------------------------------------------- */
const clockid_t id = CLOCK_MONOTONIC_RAW; const clockid_t id = CLOCK_MONOTONIC_RAW;
#elif defined(CLOCK_HIGHRES) #elif defined(CLOCK_HIGHRES)
/* Solaris. ----------------------------------------- */ /* Solaris. ----------------------------------------- */
const clockid_t id = CLOCK_HIGHRES; const clockid_t id = CLOCK_HIGHRES;
#elif defined(CLOCK_MONOTONIC) #elif defined(CLOCK_MONOTONIC)
/* AIX, BSD, Linux, POSIX, Solaris. ----------------- */ /* AIX, BSD, Linux, POSIX, Solaris. ----------------- */
const clockid_t id = CLOCK_MONOTONIC; const clockid_t id = CLOCK_MONOTONIC;
#elif defined(CLOCK_REALTIME) #elif defined(CLOCK_REALTIME)
/* AIX, BSD, HP-UX, Linux, POSIX. ------------------- */ /* AIX, BSD, HP-UX, Linux, POSIX. ------------------- */
const clockid_t id = CLOCK_REALTIME; const clockid_t id = CLOCK_REALTIME;
#else #else
const clockid_t id = (clockid_t)-1; /* Unknown. */ const clockid_t id = (clockid_t)-1; /* Unknown. */
#endif /* CLOCK_* */ #endif /* CLOCK_* */
if ( id != (clockid_t)-1 && clock_gettime( id, &ts ) != -1 ) if(id != (clockid_t)-1 && clock_gettime(id, &ts) != -1)
return (double)ts.tv_sec + return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
(double)ts.tv_nsec / 1000000000.0; /* Fall thru. */
/* Fall thru. */ }
}
#endif /* _POSIX_TIMERS */ #endif /* _POSIX_TIMERS */
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, POSIX, Solaris. ----- */ /* AIX, BSD, Cygwin, HP-UX, Linux, OSX, POSIX, Solaris. ----- */
gettimeofday( &tm, NULL ); gettimeofday(&tm, NULL);
return (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0; return (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0;
#else #else
return -1.0; /* Failed. */ return -1.0; /* Failed. */
#endif #endif
} }
@ -479,80 +529,74 @@ static double mu_timer_real(void)
* Returns the amount of CPU time used by the current process, * Returns the amount of CPU time used by the current process,
* in seconds, or -1.0 if an error occurred. * in seconds, or -1.0 if an error occurred.
*/ */
static double mu_timer_cpu(void) static double mu_timer_cpu(void) {
{
#if defined(_WIN32) #if defined(_WIN32)
/* Windows -------------------------------------------------- */ /* Windows -------------------------------------------------- */
FILETIME createTime; FILETIME createTime;
FILETIME exitTime; FILETIME exitTime;
FILETIME kernelTime; FILETIME kernelTime;
FILETIME userTime; FILETIME userTime;
/* This approach has a resolution of 1/64 second. Unfortunately, Windows' API does not offer better */ /* This approach has a resolution of 1/64 second. Unfortunately, Windows' API does not offer better */
if ( GetProcessTimes( GetCurrentProcess( ), if(GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime) != 0) {
&createTime, &exitTime, &kernelTime, &userTime ) != 0 ) ULARGE_INTEGER userSystemTime;
{ memcpy(&userSystemTime, &userTime, sizeof(ULARGE_INTEGER));
ULARGE_INTEGER userSystemTime; return (double)userSystemTime.QuadPart / 10000000.0;
memcpy(&userSystemTime, &userTime, sizeof(ULARGE_INTEGER)); }
return (double)userSystemTime.QuadPart / 10000000.0;
}
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) #elif defined(__unix__) || defined(__unix) || defined(unix) || \
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, and Solaris --------- */ (defined(__APPLE__) && defined(__MACH__))
/* AIX, BSD, Cygwin, HP-UX, Linux, OSX, and Solaris --------- */
#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) #if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
/* Prefer high-res POSIX timers, when available. */ /* Prefer high-res POSIX timers, when available. */
{ {
clockid_t id; clockid_t id;
struct timespec ts; struct timespec ts;
#if _POSIX_CPUTIME > 0 #if _POSIX_CPUTIME > 0
/* Clock ids vary by OS. Query the id, if possible. */ /* Clock ids vary by OS. Query the id, if possible. */
if ( clock_getcpuclockid( 0, &id ) == -1 ) if(clock_getcpuclockid(0, &id) == -1)
#endif #endif
#if defined(CLOCK_PROCESS_CPUTIME_ID) #if defined(CLOCK_PROCESS_CPUTIME_ID)
/* Use known clock id for AIX, Linux, or Solaris. */ /* Use known clock id for AIX, Linux, or Solaris. */
id = CLOCK_PROCESS_CPUTIME_ID; id = CLOCK_PROCESS_CPUTIME_ID;
#elif defined(CLOCK_VIRTUAL) #elif defined(CLOCK_VIRTUAL)
/* Use known clock id for BSD or HP-UX. */ /* Use known clock id for BSD or HP-UX. */
id = CLOCK_VIRTUAL; id = CLOCK_VIRTUAL;
#else #else
id = (clockid_t)-1; id = (clockid_t)-1;
#endif #endif
if ( id != (clockid_t)-1 && clock_gettime( id, &ts ) != -1 ) if(id != (clockid_t)-1 && clock_gettime(id, &ts) != -1)
return (double)ts.tv_sec + return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
(double)ts.tv_nsec / 1000000000.0; }
}
#endif #endif
#if defined(RUSAGE_SELF) #if defined(RUSAGE_SELF)
{ {
struct rusage rusage; struct rusage rusage;
if ( getrusage( RUSAGE_SELF, &rusage ) != -1 ) if(getrusage(RUSAGE_SELF, &rusage) != -1)
return (double)rusage.ru_utime.tv_sec + return (double)rusage.ru_utime.tv_sec + (double)rusage.ru_utime.tv_usec / 1000000.0;
(double)rusage.ru_utime.tv_usec / 1000000.0; }
}
#endif #endif
#if defined(_SC_CLK_TCK) #if defined(_SC_CLK_TCK)
{ {
const double ticks = (double)sysconf( _SC_CLK_TCK ); const double ticks = (double)sysconf(_SC_CLK_TCK);
struct tms tms; struct tms tms;
if ( times( &tms ) != (clock_t)-1 ) if(times(&tms) != (clock_t)-1) return (double)tms.tms_utime / ticks;
return (double)tms.tms_utime / ticks; }
}
#endif #endif
#if defined(CLOCKS_PER_SEC) #if defined(CLOCKS_PER_SEC)
{ {
clock_t cl = clock( ); clock_t cl = clock();
if ( cl != (clock_t)-1 ) if(cl != (clock_t)-1) return (double)cl / (double)CLOCKS_PER_SEC;
return (double)cl / (double)CLOCKS_PER_SEC; }
}
#endif #endif
#endif #endif
return -1; /* Failed. */ return -1; /* Failed. */
} }
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,11 +1,11 @@
#include <stdio.h> #include <stdio.h>
extern "C" { extern "C" {
#include "flipper.h" #include "flipper.h"
#include "furi.h" #include "furi.h"
#include "log.h" #include "log.h"
#include "startup.h" #include "startup.h"
#include "tty_uart.h" #include "tty_uart.h"
} }
// for testing purpose // for testing purpose

View File

@ -28,7 +28,7 @@ uint16_t furiac_get_task_id_by_name(const char* app_name) {
} }
void furiac_wait_libs(const FlipperAppLibrary* libs) { void furiac_wait_libs(const FlipperAppLibrary* libs) {
for(uint8_t i = 0; i < libs->count; i++){ for(uint8_t i = 0; i < libs->count; i++) {
uint16_t app_id = furiac_get_task_id_by_name(libs->name[i]); uint16_t app_id = furiac_get_task_id_by_name(libs->name[i]);
if(app_id == INVALID_TASK_ID) { if(app_id == INVALID_TASK_ID) {

View File

@ -11,10 +11,8 @@ cd $PROJECT_DIR
echo "RUN C\C++ SYNTAX CHECK" echo "RUN C\C++ SYNTAX CHECK"
C_FILES=$(find . \ C_FILES=$(find . \
-not \( -path './target_*/Middlewares' -prune \) \ -not \( -path './firmware/.obj' -prune \) \
-not \( -path './target_*/Drivers' -prune \) \ -not \( -path './firmware/targets' -prune \) \
-not \( -path './target_*/build' -prune \) \
-not \( -path './target_*/Inc' -prune \) \
-not \( -path ./lib -prune \) \ -not \( -path ./lib -prune \) \
-name *.c -o -name *.h -o -name *.cpp) -name *.c -o -name *.h -o -name *.cpp)