-
Notifications
You must be signed in to change notification settings - Fork 3k
Reduce test overhead in preperation for CMSIS 5 #4317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a0fcd3
c82c40f
4f3aabc
07fc7ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,15 +32,10 @@ using namespace utest::v1; | |
#define TABLE_SIZE(TAB) (sizeof(TAB) / sizeof(TAB[0])) | ||
|
||
#define NEGATIVE_INTEGERS -32768,-3214,-999,-100,-1,0,1,4231,999,4123,32760,99999 | ||
#define POSITIVE_INTEGERS 32768,3214,999,100,1,0,1,4231,999,4123,32760,99999 | ||
#define FLOATS 0.002,0.92430,15.91320,791.77368,6208.2,25719.4952,426815.982588,6429271.046,42468024.93,212006462.910 | ||
#define FLOATS_STR "0.002","0.92430","15.91320","791.77368","6208.2","25719.4952","426815.982588","6429271.046","42468024.93","212006462.910" | ||
|
||
|
||
namespace { | ||
int p_integers[] = {POSITIVE_INTEGERS}; | ||
int n_integers[] = {NEGATIVE_INTEGERS}; | ||
float floats[] = {FLOATS}; | ||
|
||
template <class T, class F> | ||
void BubbleSort(T& _array, size_t array_size, F functor) { | ||
|
@@ -59,62 +54,49 @@ void BubbleSort(T& _array, size_t array_size, F functor) { | |
} | ||
} | ||
|
||
struct printInt { | ||
void operator()(int i) { printf("%d ", i); } | ||
}; | ||
|
||
struct printFloat { | ||
void operator()(float f) { printf("%f ", f); } | ||
}; | ||
|
||
struct printString { | ||
void operator()(const char* s) { printf("%s ", s); } | ||
}; | ||
|
||
struct greaterAbs { | ||
bool operator()(int a, int b) { return abs(a) > abs(b); } | ||
}; | ||
|
||
} // namespace | ||
|
||
void test_case_stl_equal() { | ||
std::vector<int> v_pints(p_integers, p_integers + TABLE_SIZE(p_integers)); | ||
TEST_ASSERT_TRUE(std::equal(v_pints.begin(), v_pints.end(), p_integers)); | ||
const int n_integers[] = {NEGATIVE_INTEGERS}; | ||
std::vector<int> v_pints(n_integers, n_integers + TABLE_SIZE(n_integers)); | ||
TEST_ASSERT_TRUE(std::equal(v_pints.begin(), v_pints.end(), n_integers)); | ||
} | ||
|
||
void test_case_stl_transform() { | ||
const float floats[] = {FLOATS}; | ||
const char* floats_str[] = {FLOATS_STR}; | ||
float floats_transform[TABLE_SIZE(floats_str)] = {0.0}; | ||
std::transform(floats_str, floats_str + TABLE_SIZE(floats_str), floats_transform, atof); | ||
//printf("stl_transform::floats_str: "); | ||
//std::for_each(floats_str, floats_str + TABLE_SIZE(floats_str), printString()); | ||
//printf("stl_transform::floats_transform: "); | ||
//std::for_each(floats_transform, floats_transform + TABLE_SIZE(floats_transform), printFloat()); | ||
//printf("\n"); | ||
|
||
TEST_ASSERT_TRUE(std::equal(floats_transform, floats_transform + TABLE_SIZE(floats_transform), floats)); | ||
} | ||
|
||
void test_case_stl_sort_greater() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope I'm not repeating a discussion, but have we considered if it's worthwhile to keep these stl tests? You could spend a lifetime trying to add coverage to the stl.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could remove them, shall be done via separate PR |
||
std::vector<int> v_nints_1(n_integers, n_integers + TABLE_SIZE(n_integers)); | ||
std::vector<int> v_nints_2(n_integers, n_integers + TABLE_SIZE(n_integers)); | ||
int n_integers[] = {NEGATIVE_INTEGERS}; | ||
int n_integers2[] = {NEGATIVE_INTEGERS}; | ||
|
||
BubbleSort(v_nints_1, v_nints_1.size(), std::greater<int>()); | ||
std::sort(v_nints_2.begin(), v_nints_2.end(), std::greater<int>()); | ||
BubbleSort(n_integers, TABLE_SIZE(n_integers), std::greater<int>()); | ||
std::sort(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), std::greater<int>()); | ||
|
||
TEST_ASSERT_TRUE(std::equal(v_nints_1.begin(), v_nints_1.end(), v_nints_2.begin())); | ||
TEST_ASSERT_TRUE(std::equal(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), n_integers)); | ||
} | ||
|
||
|
||
void test_case_stl_sort_abs() { | ||
std::vector<int> v_nints_1(n_integers, n_integers + TABLE_SIZE(n_integers)); | ||
std::vector<int> v_nints_2(n_integers, n_integers + TABLE_SIZE(n_integers)); | ||
int n_integers[] = {NEGATIVE_INTEGERS}; | ||
int n_integers2[] = {NEGATIVE_INTEGERS}; | ||
|
||
BubbleSort(v_nints_1, v_nints_1.size(), greaterAbs()); | ||
std::sort(v_nints_2.begin(), v_nints_2.end(), greaterAbs()); | ||
BubbleSort(n_integers, TABLE_SIZE(n_integers), greaterAbs()); | ||
std::sort(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), greaterAbs()); | ||
|
||
TEST_ASSERT_TRUE(std::equal(v_nints_1.begin(), v_nints_1.end(), v_nints_2.begin())); | ||
TEST_ASSERT_TRUE(std::equal(n_integers2, n_integers2 + TABLE_SIZE(n_integers2), n_integers)); | ||
} | ||
|
||
|
||
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) { | ||
greentea_case_failure_abort_handler(source, reason); | ||
return STATUS_CONTINUE; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,26 +6,7 @@ | |
#error [NOT_SUPPORTED] test not supported | ||
#endif | ||
|
||
/* | ||
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and | ||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes | ||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize. | ||
*/ | ||
#if defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_GCC) | ||
#define STACK_SIZE DEFAULT_STACK_SIZE/2 | ||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO) | ||
#define STACK_SIZE 512 | ||
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO) | ||
#define STACK_SIZE 768 | ||
#elif (defined(TARGET_EFM32GG_STK3700)) && !defined(TOOLCHAIN_ARM_MICRO) | ||
#define STACK_SIZE 1536 | ||
#elif defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832) | ||
#define STACK_SIZE 768 | ||
#elif defined(TARGET_XDOT_L151CC) | ||
#define STACK_SIZE 1024 | ||
#else | ||
#define STACK_SIZE DEFAULT_STACK_SIZE | ||
#endif | ||
#define TEST_STACK_SIZE 768 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
#define SIGNAL_PRINT_TICK 0x01 | ||
|
||
|
@@ -43,15 +24,15 @@ void print_tick_thread() { | |
|
||
int main() { | ||
GREENTEA_SETUP(total_ticks + 5, "timing_drift_auto"); | ||
Thread tick_thread(osPriorityNormal, STACK_SIZE); | ||
|
||
Thread tick_thread(osPriorityNormal, TEST_STACK_SIZE); | ||
tick_thread.start(print_tick_thread); | ||
|
||
for (int i = 0; i <= total_ticks; i++) { | ||
Thread::wait(1000); | ||
tick_thread.signal_set(SIGNAL_PRINT_TICK); | ||
} | ||
|
||
tick_thread.join(); | ||
GREENTEA_TESTSUITE_RESULT(1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bridadan pointed this out to me. Looks great and matches the way we're handling stacks here 👍