mirror of https://github.com/ARMmbed/mbed-os.git
parent
8f7024a226
commit
e52bb68f93
|
@ -38,32 +38,38 @@ using namespace utest::v1;
|
||||||
volatile bool touched = false;
|
volatile bool touched = false;
|
||||||
|
|
||||||
// static functions
|
// static functions
|
||||||
void func5(int a0, int a1, int a2, int a3, int a4) {
|
void func5(int a0, int a1, int a2, int a3, int a4)
|
||||||
|
{
|
||||||
touched = true;
|
touched = true;
|
||||||
TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3 | a4, 0x1f);
|
TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3 | a4, 0x1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void func4(int a0, int a1, int a2, int a3) {
|
void func4(int a0, int a1, int a2, int a3)
|
||||||
|
{
|
||||||
touched = true;
|
touched = true;
|
||||||
TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3, 0xf);
|
TEST_ASSERT_EQUAL(a0 | a1 | a2 | a3, 0xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void func3(int a0, int a1, int a2) {
|
void func3(int a0, int a1, int a2)
|
||||||
|
{
|
||||||
touched = true;
|
touched = true;
|
||||||
TEST_ASSERT_EQUAL(a0 | a1 | a2, 0x7);
|
TEST_ASSERT_EQUAL(a0 | a1 | a2, 0x7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void func2(int a0, int a1) {
|
void func2(int a0, int a1)
|
||||||
|
{
|
||||||
touched = true;
|
touched = true;
|
||||||
TEST_ASSERT_EQUAL(a0 | a1, 0x3);
|
TEST_ASSERT_EQUAL(a0 | a1, 0x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void func1(int a0) {
|
void func1(int a0)
|
||||||
|
{
|
||||||
touched = true;
|
touched = true;
|
||||||
TEST_ASSERT_EQUAL(a0, 0x1);
|
TEST_ASSERT_EQUAL(a0, 0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void func0() {
|
void func0()
|
||||||
|
{
|
||||||
touched = true;
|
touched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,13 +101,15 @@ SIMPLE_POSTS_TEST(1, 0x01)
|
||||||
SIMPLE_POSTS_TEST(0)
|
SIMPLE_POSTS_TEST(0)
|
||||||
|
|
||||||
|
|
||||||
void time_func(Timer *t, int ms) {
|
void time_func(Timer *t, int ms)
|
||||||
|
{
|
||||||
TEST_ASSERT_INT_WITHIN(DELTA(ms), ms, t->read_ms());
|
TEST_ASSERT_INT_WITHIN(DELTA(ms), ms, t->read_ms());
|
||||||
t->reset();
|
t->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int N>
|
template <int N>
|
||||||
void call_in_test() {
|
void call_in_test()
|
||||||
|
{
|
||||||
Timer tickers[N];
|
Timer tickers[N];
|
||||||
|
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
|
@ -115,7 +123,8 @@ void call_in_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int N>
|
template <int N>
|
||||||
void call_every_test() {
|
void call_every_test()
|
||||||
|
{
|
||||||
Timer tickers[N];
|
Timer tickers[N];
|
||||||
|
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
|
@ -128,7 +137,8 @@ void call_every_test() {
|
||||||
queue.dispatch(N * 100);
|
queue.dispatch(N * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allocate_failure_test() {
|
void allocate_failure_test()
|
||||||
|
{
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
|
@ -139,12 +149,14 @@ void allocate_failure_test() {
|
||||||
TEST_ASSERT(!id);
|
TEST_ASSERT(!id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void no() {
|
void no()
|
||||||
|
{
|
||||||
TEST_ASSERT(false);
|
TEST_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int N>
|
template <int N>
|
||||||
void cancel_test1() {
|
void cancel_test1()
|
||||||
|
{
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
|
|
||||||
int ids[N];
|
int ids[N];
|
||||||
|
@ -164,31 +176,38 @@ void cancel_test1() {
|
||||||
// Testing the dynamic arguments to the event class
|
// Testing the dynamic arguments to the event class
|
||||||
unsigned counter = 0;
|
unsigned counter = 0;
|
||||||
|
|
||||||
void count5(unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a5) {
|
void count5(unsigned a0, unsigned a1, unsigned a2, unsigned a3, unsigned a5)
|
||||||
|
{
|
||||||
counter += a0 + a1 + a2 + a3 + a5;
|
counter += a0 + a1 + a2 + a3 + a5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void count4(unsigned a0, unsigned a1, unsigned a2, unsigned a3) {
|
void count4(unsigned a0, unsigned a1, unsigned a2, unsigned a3)
|
||||||
|
{
|
||||||
counter += a0 + a1 + a2 + a3;
|
counter += a0 + a1 + a2 + a3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void count3(unsigned a0, unsigned a1, unsigned a2) {
|
void count3(unsigned a0, unsigned a1, unsigned a2)
|
||||||
|
{
|
||||||
counter += a0 + a1 + a2;
|
counter += a0 + a1 + a2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void count2(unsigned a0, unsigned a1) {
|
void count2(unsigned a0, unsigned a1)
|
||||||
|
{
|
||||||
counter += a0 + a1;
|
counter += a0 + a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void count1(unsigned a0) {
|
void count1(unsigned a0)
|
||||||
|
{
|
||||||
counter += a0;
|
counter += a0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void count0() {
|
void count0()
|
||||||
|
{
|
||||||
counter += 0;
|
counter += 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_class_test() {
|
void event_class_test()
|
||||||
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
|
|
||||||
|
@ -211,7 +230,8 @@ void event_class_test() {
|
||||||
TEST_ASSERT_EQUAL(counter, 30);
|
TEST_ASSERT_EQUAL(counter, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_class_helper_test() {
|
void event_class_helper_test()
|
||||||
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
|
|
||||||
|
@ -234,7 +254,8 @@ void event_class_helper_test() {
|
||||||
TEST_ASSERT_EQUAL(counter, 15);
|
TEST_ASSERT_EQUAL(counter, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_inference_test() {
|
void event_inference_test()
|
||||||
|
{
|
||||||
counter = 0;
|
counter = 0;
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
|
|
||||||
|
@ -259,18 +280,21 @@ void event_inference_test() {
|
||||||
|
|
||||||
int timeleft_events[2];
|
int timeleft_events[2];
|
||||||
|
|
||||||
void check_time_left(EventQueue* queue, int index, int expected) {
|
void check_time_left(EventQueue *queue, int index, int expected)
|
||||||
|
{
|
||||||
const int event_id = timeleft_events[index];
|
const int event_id = timeleft_events[index];
|
||||||
TEST_ASSERT_INT_WITHIN(2, expected, queue->time_left(event_id));
|
TEST_ASSERT_INT_WITHIN(2, expected, queue->time_left(event_id));
|
||||||
touched = true;
|
touched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void time_left(EventQueue* queue, int index) {
|
void time_left(EventQueue *queue, int index)
|
||||||
|
{
|
||||||
const int event_id = timeleft_events[index];
|
const int event_id = timeleft_events[index];
|
||||||
TEST_ASSERT_EQUAL(0, queue->time_left(event_id));
|
TEST_ASSERT_EQUAL(0, queue->time_left(event_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void time_left_test() {
|
void time_left_test()
|
||||||
|
{
|
||||||
EventQueue queue(TEST_EQUEUE_SIZE);
|
EventQueue queue(TEST_EQUEUE_SIZE);
|
||||||
|
|
||||||
// Enque check events
|
// Enque check events
|
||||||
|
@ -299,7 +323,8 @@ void time_left_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(20, "default_auto");
|
GREENTEA_SETUP(20, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -327,7 +352,8 @@ const Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,8 @@ using namespace utest::v1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Random number generation to skew timing values
|
// Random number generation to skew timing values
|
||||||
float gauss(float mu, float sigma) {
|
float gauss(float mu, float sigma)
|
||||||
|
{
|
||||||
float x = (float)rand() / ((float)RAND_MAX + 1);
|
float x = (float)rand() / ((float)RAND_MAX + 1);
|
||||||
float y = (float)rand() / ((float)RAND_MAX + 1);
|
float y = (float)rand() / ((float)RAND_MAX + 1);
|
||||||
float x2pi = x * 2.0 * M_PI;
|
float x2pi = x * 2.0 * M_PI;
|
||||||
|
@ -51,7 +52,8 @@ float gauss(float mu, float sigma) {
|
||||||
return mu + z * sigma;
|
return mu + z * sigma;
|
||||||
}
|
}
|
||||||
|
|
||||||
float chisq(float sigma) {
|
float chisq(float sigma)
|
||||||
|
{
|
||||||
return pow(gauss(0, sqrt(sigma)), 2);
|
return pow(gauss(0, sqrt(sigma)), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +64,8 @@ DigitalOut led(LED1);
|
||||||
equeue_sema_t sema;
|
equeue_sema_t sema;
|
||||||
|
|
||||||
// Timer timing test
|
// Timer timing test
|
||||||
void timer_timing_test() {
|
void timer_timing_test()
|
||||||
|
{
|
||||||
timer.reset();
|
timer.reset();
|
||||||
timer.start();
|
timer.start();
|
||||||
int prev = timer.read_us();
|
int prev = timer.read_us();
|
||||||
|
@ -79,7 +82,8 @@ void timer_timing_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// equeue tick timing test
|
// equeue tick timing test
|
||||||
void tick_timing_test() {
|
void tick_timing_test()
|
||||||
|
{
|
||||||
unsigned start = equeue_tick();
|
unsigned start = equeue_tick();
|
||||||
int prev = 0;
|
int prev = 0;
|
||||||
|
|
||||||
|
@ -95,7 +99,8 @@ void tick_timing_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// equeue semaphore timing test
|
// equeue semaphore timing test
|
||||||
void semaphore_timing_test() {
|
void semaphore_timing_test()
|
||||||
|
{
|
||||||
srand(0);
|
srand(0);
|
||||||
timer.reset();
|
timer.reset();
|
||||||
timer.start();
|
timer.start();
|
||||||
|
@ -124,7 +129,8 @@ void semaphore_timing_test() {
|
||||||
|
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP((number_of_cases + 1)*TEST_EVENTS_TIMING_TIME / 1000, "default_auto");
|
GREENTEA_SETUP((number_of_cases + 1)*TEST_EVENTS_TIMING_TIME / 1000, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +143,8 @@ const Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
*/
|
*/
|
||||||
#include "test_env.h"
|
#include "test_env.h"
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
GREENTEA_SETUP(15, "default_auto");
|
GREENTEA_SETUP(15, "default_auto");
|
||||||
GREENTEA_TESTSUITE_RESULT(true);
|
GREENTEA_TESTSUITE_RESULT(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,7 @@ using namespace utest::v1;
|
||||||
static LoRaRadio *radio = NULL;
|
static LoRaRadio *radio = NULL;
|
||||||
rtos::Semaphore event_sem(0);
|
rtos::Semaphore event_sem(0);
|
||||||
|
|
||||||
enum event_t
|
enum event_t {
|
||||||
{
|
|
||||||
EV_NONE,
|
EV_NONE,
|
||||||
EV_TX_DONE,
|
EV_TX_DONE,
|
||||||
EV_TX_TIMEOUT,
|
EV_TX_TIMEOUT,
|
||||||
|
@ -94,8 +93,7 @@ static void rx_error()
|
||||||
TEST_ASSERT_EQUAL(osOK, event_sem.release());
|
TEST_ASSERT_EQUAL(osOK, event_sem.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
static radio_events radio_callbacks =
|
static radio_events radio_callbacks = {
|
||||||
{
|
|
||||||
.tx_done = tx_done,
|
.tx_done = tx_done,
|
||||||
.tx_timeout = tx_timeout,
|
.tx_timeout = tx_timeout,
|
||||||
.rx_done = rx_done,
|
.rx_done = rx_done,
|
||||||
|
@ -187,7 +185,8 @@ void test_check_rf_frequency()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(20, "default_auto");
|
GREENTEA_SETUP(20, "default_auto");
|
||||||
|
|
||||||
mbed_trace_init();
|
mbed_trace_init();
|
||||||
|
@ -277,6 +276,7 @@ const Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,43 +33,50 @@ static char buffer[256] = {0};
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
|
|
||||||
void test_case_c_string_i_d() {
|
void test_case_c_string_i_d()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
sprintf(buffer, "%i %d %i %d %i %d %i %d %i %d %i %i", NEGATIVE_INTEGERS);
|
sprintf(buffer, "%i %d %i %d %i %d %i %d %i %d %i %i", NEGATIVE_INTEGERS);
|
||||||
TEST_ASSERT_EQUAL_STRING("-32768 -3214 -999 -100 -1 0 -1 -4231 -999 -4123 -32760 -99999", buffer);
|
TEST_ASSERT_EQUAL_STRING("-32768 -3214 -999 -100 -1 0 -1 -4231 -999 -4123 -32760 -99999", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_c_string_u_d() {
|
void test_case_c_string_u_d()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
sprintf(buffer, "%u %d %u %d %u %d %u %d %u %d %u %d", POSITIVE_INTEGERS);
|
sprintf(buffer, "%u %d %u %d %u %d %u %d %u %d %u %d", POSITIVE_INTEGERS);
|
||||||
TEST_ASSERT_EQUAL_STRING("32768 3214 999 100 1 0 1 4231 999 4123 32760 99999", buffer);
|
TEST_ASSERT_EQUAL_STRING("32768 3214 999 100 1 0 1 4231 999 4123 32760 99999", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_c_string_x_E() {
|
void test_case_c_string_x_E()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
sprintf(buffer, "%x %X %x %X %x %X %x %X %x %X %x %X", POSITIVE_INTEGERS);
|
sprintf(buffer, "%x %X %x %X %x %X %x %X %x %X %x %X", POSITIVE_INTEGERS);
|
||||||
TEST_ASSERT_EQUAL_STRING("8000 C8E 3e7 64 1 0 1 1087 3e7 101B 7ff8 1869F", buffer);
|
TEST_ASSERT_EQUAL_STRING("8000 C8E 3e7 64 1 0 1 1087 3e7 101B 7ff8 1869F", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_c_string_f_f() {
|
void test_case_c_string_f_f()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
sprintf(buffer, "%f %f %f %f %f %f %f %f %f %f", FLOATS);
|
sprintf(buffer, "%f %f %f %f %f %f %f %f %f %f", FLOATS);
|
||||||
TEST_ASSERT_EQUAL_STRING("0.002000 0.924300 15.913200 791.773680 6208.200000 25719.495200 426815.982588 6429271.046000 42468024.930000 212006462.910000", buffer);
|
TEST_ASSERT_EQUAL_STRING("0.002000 0.924300 15.913200 791.773680 6208.200000 25719.495200 426815.982588 6429271.046000 42468024.930000 212006462.910000", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_c_string_g_g() {
|
void test_case_c_string_g_g()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
sprintf(buffer, "%g %g %g %g %g %g %g %g %g %g", FLOATS);
|
sprintf(buffer, "%g %g %g %g %g %g %g %g %g %g", FLOATS);
|
||||||
TEST_ASSERT_EQUAL_STRING("0.002 0.9243 15.9132 791.774 6208.2 25719.5 426816 6.42927e+06 4.2468e+07 2.12006e+08", buffer);
|
TEST_ASSERT_EQUAL_STRING("0.002 0.9243 15.9132 791.774 6208.2 25719.5 426816 6.42927e+06 4.2468e+07 2.12006e+08", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_c_string_e_E() {
|
void test_case_c_string_e_E()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
sprintf(buffer, "%e %E %e %E %e %E %e %E %e %E", FLOATS);
|
sprintf(buffer, "%e %E %e %E %e %E %e %E %e %E", FLOATS);
|
||||||
TEST_ASSERT_EQUAL_STRING("2.000000e-03 9.243000E-01 1.591320e+01 7.917737E+02 6.208200e+03 2.571950E+04 4.268160e+05 6.429271E+06 4.246802e+07 2.120065E+08", buffer);
|
TEST_ASSERT_EQUAL_STRING("2.000000e-03 9.243000E-01 1.591320e+01 7.917737E+02 6.208200e+03 2.571950E+04 4.268160e+05 6.429271E+06 4.246802e+07 2.120065E+08", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_c_string_strtok() {
|
void test_case_c_string_strtok()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
char str[] = "- This, a sample string.";
|
char str[] = "- This, a sample string.";
|
||||||
char *pch = strtok(str, " ,.-");
|
char *pch = strtok(str, " ,.-");
|
||||||
|
@ -80,13 +87,13 @@ void test_case_c_string_strtok() {
|
||||||
TEST_ASSERT_EQUAL_STRING("Thisasamplestring", buffer);
|
TEST_ASSERT_EQUAL_STRING("Thisasamplestring", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_c_string_strpbrk() {
|
void test_case_c_string_strpbrk()
|
||||||
|
{
|
||||||
CLEAN_BUFFER;
|
CLEAN_BUFFER;
|
||||||
char str[] = "This is a sample string";
|
char str[] = "This is a sample string";
|
||||||
char key[] = "aeiou";
|
char key[] = "aeiou";
|
||||||
char *pch = strpbrk(str, key);
|
char *pch = strpbrk(str, key);
|
||||||
while (pch != NULL)
|
while (pch != NULL) {
|
||||||
{
|
|
||||||
char buf[2] = {*pch, '\0'};
|
char buf[2] = {*pch, '\0'};
|
||||||
strcat(buffer, buf);
|
strcat(buffer, buf);
|
||||||
pch = strpbrk(pch + 1, key);
|
pch = strpbrk(pch + 1, key);
|
||||||
|
@ -94,7 +101,8 @@ void test_case_c_string_strpbrk() {
|
||||||
TEST_ASSERT_EQUAL_STRING("iiaaei", buffer);
|
TEST_ASSERT_EQUAL_STRING("iiaaei", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
|
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
|
||||||
|
{
|
||||||
greentea_case_failure_abort_handler(source, reason);
|
greentea_case_failure_abort_handler(source, reason);
|
||||||
return STATUS_CONTINUE;
|
return STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -110,13 +118,15 @@ Case cases[] = {
|
||||||
Case("C strings: %g %g float formatting", test_case_c_string_g_g, greentea_failure_handler),
|
Case("C strings: %g %g float formatting", test_case_c_string_g_g, greentea_failure_handler),
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(5, "default_auto");
|
GREENTEA_SETUP(5, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,13 +132,15 @@ Case cases[] = {
|
||||||
Case("Test not supported polynomials", test_any_polynomial)
|
Case("Test not supported polynomials", test_any_polynomial)
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(15, "default_auto");
|
GREENTEA_SETUP(15, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,20 @@ public:
|
||||||
DevNull(const char *name = NULL) : Stream(name) {}
|
DevNull(const char *name = NULL) : Stream(name) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int _getc() {
|
virtual int _getc()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
virtual int _putc(int c) {
|
virtual int _putc(int c)
|
||||||
|
{
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DevNull null("null");
|
DevNull null("null");
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
GREENTEA_SETUP(2, "dev_null_auto");
|
GREENTEA_SETUP(2, "dev_null_auto");
|
||||||
|
|
||||||
printf("MBED: before re-routing stdout to /null\n"); // This shouldn't appear
|
printf("MBED: before re-routing stdout to /null\n"); // This shouldn't appear
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
// Fill a buffer with a slice of the ASCII alphabet.
|
// Fill a buffer with a slice of the ASCII alphabet.
|
||||||
void fill_buffer(char* buffer, unsigned int length, unsigned int index) {
|
void fill_buffer(char *buffer, unsigned int length, unsigned int index)
|
||||||
|
{
|
||||||
unsigned int start = length * index;
|
unsigned int start = length * index;
|
||||||
for (int i = 0; i < length - 1; i++) {
|
for (int i = 0; i < length - 1; i++) {
|
||||||
buffer[i] = 'a' + ((start + i) % 26);
|
buffer[i] = 'a' + ((start + i) % 26);
|
||||||
|
@ -36,7 +37,8 @@ void fill_buffer(char* buffer, unsigned int length, unsigned int index) {
|
||||||
|
|
||||||
// Echo server (echo payload to host)
|
// Echo server (echo payload to host)
|
||||||
template<int N>
|
template<int N>
|
||||||
void test_case_echo_server_x() {
|
void test_case_echo_server_x()
|
||||||
|
{
|
||||||
char _key[11] = {};
|
char _key[11] = {};
|
||||||
char _tx_value[PAYLOAD_LENGTH + 1] = {};
|
char _tx_value[PAYLOAD_LENGTH + 1] = {};
|
||||||
char _rx_value[PAYLOAD_LENGTH + 1] = {};
|
char _rx_value[PAYLOAD_LENGTH + 1] = {};
|
||||||
|
@ -67,7 +69,8 @@ void test_case_echo_server_x() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
|
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
|
||||||
|
{
|
||||||
greentea_case_failure_abort_handler(source, reason);
|
greentea_case_failure_abort_handler(source, reason);
|
||||||
return STATUS_CONTINUE;
|
return STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -76,13 +79,15 @@ Case cases[] = {
|
||||||
Case("Echo server: x16", test_case_echo_server_x<16>, greentea_failure_handler),
|
Case("Echo server: x16", test_case_echo_server_x<16>, greentea_failure_handler),
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(30, "device_echo");
|
GREENTEA_SETUP(30, "device_echo");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,13 +266,15 @@ Case cases[] = {
|
||||||
Case("FlashIAP - timing", flashiap_timing_test),
|
Case("FlashIAP - timing", flashiap_timing_test),
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(120, "default_auto");
|
GREENTEA_SETUP(120, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,44 +32,52 @@ private:
|
||||||
const unsigned pattern;
|
const unsigned pattern;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CppTestCaseHelperClass(const char* _name) : name(_name), pattern(PATTERN_CHECK_VALUE) {
|
CppTestCaseHelperClass(const char *_name) : name(_name), pattern(PATTERN_CHECK_VALUE)
|
||||||
|
{
|
||||||
print("init");
|
print("init");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(const char *message) {
|
void print(const char *message)
|
||||||
|
{
|
||||||
printf("%s::%s\n", name, message);
|
printf("%s::%s\n", name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_init(void) {
|
bool check_init(void)
|
||||||
|
{
|
||||||
bool result = (pattern == PATTERN_CHECK_VALUE);
|
bool result = (pattern == PATTERN_CHECK_VALUE);
|
||||||
print(result ? "check_init: OK" : "check_init: ERROR");
|
print(result ? "check_init: OK" : "check_init: ERROR");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void stack_test(void) {
|
void stack_test(void)
|
||||||
|
{
|
||||||
print("stack_test");
|
print("stack_test");
|
||||||
CppTestCaseHelperClass t("Stack");
|
CppTestCaseHelperClass t("Stack");
|
||||||
t.hello();
|
t.hello();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hello(void) {
|
void hello(void)
|
||||||
|
{
|
||||||
print("hello");
|
print("hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
~CppTestCaseHelperClass() {
|
~CppTestCaseHelperClass()
|
||||||
|
{
|
||||||
print("destroy");
|
print("destroy");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void test_case_basic() {
|
void test_case_basic()
|
||||||
|
{
|
||||||
TEST_ASSERT_TRUE(true);
|
TEST_ASSERT_TRUE(true);
|
||||||
TEST_ASSERT_FALSE(false);
|
TEST_ASSERT_FALSE(false);
|
||||||
TEST_ASSERT_EQUAL_STRING("The quick brown fox jumps over the lazy dog",
|
TEST_ASSERT_EQUAL_STRING("The quick brown fox jumps over the lazy dog",
|
||||||
"The quick brown fox jumps over the lazy dog");
|
"The quick brown fox jumps over the lazy dog");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_blinky() {
|
void test_case_blinky()
|
||||||
|
{
|
||||||
static DigitalOut myled(LED1);
|
static DigitalOut myled(LED1);
|
||||||
const int cnt_max = 1024;
|
const int cnt_max = 1024;
|
||||||
for (int cnt = 0; cnt < cnt_max; ++cnt) {
|
for (int cnt = 0; cnt < cnt_max; ++cnt) {
|
||||||
|
@ -77,7 +85,8 @@ void test_case_blinky() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_cpp_stack() {
|
void test_case_cpp_stack()
|
||||||
|
{
|
||||||
// Check C++ start-up initialisation
|
// Check C++ start-up initialisation
|
||||||
CppTestCaseHelperClass s("Static");
|
CppTestCaseHelperClass s("Static");
|
||||||
|
|
||||||
|
@ -86,7 +95,8 @@ void test_case_cpp_stack() {
|
||||||
TEST_ASSERT_TRUE_MESSAGE(s.check_init(), "s.check_init() failed");
|
TEST_ASSERT_TRUE_MESSAGE(s.check_init(), "s.check_init() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_cpp_heap() {
|
void test_case_cpp_heap()
|
||||||
|
{
|
||||||
// Heap test object simple test
|
// Heap test object simple test
|
||||||
CppTestCaseHelperClass *m = new CppTestCaseHelperClass("Heap");
|
CppTestCaseHelperClass *m = new CppTestCaseHelperClass("Heap");
|
||||||
m->hello();
|
m->hello();
|
||||||
|
@ -94,7 +104,8 @@ void test_case_cpp_heap() {
|
||||||
delete m;
|
delete m;
|
||||||
}
|
}
|
||||||
|
|
||||||
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
|
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
|
||||||
|
{
|
||||||
greentea_case_failure_abort_handler(source, reason);
|
greentea_case_failure_abort_handler(source, reason);
|
||||||
return STATUS_CONTINUE;
|
return STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -107,13 +118,15 @@ Case cases[] = {
|
||||||
Case("C++ heap", test_case_cpp_heap, greentea_failure_handler)
|
Case("C++ heap", test_case_cpp_heap, greentea_failure_handler)
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(20, "default_auto");
|
GREENTEA_SETUP(20, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,8 +403,7 @@ static void test_case_multithread_malloc_free()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Case cases[] =
|
static Case cases[] = {
|
||||||
{
|
|
||||||
Case("Test single malloc/free trace", test_case_single_malloc_free),
|
Case("Test single malloc/free trace", test_case_single_malloc_free),
|
||||||
Case("Test all memory operations trace", test_case_all_memory_ops),
|
Case("Test all memory operations trace", test_case_all_memory_ops),
|
||||||
Case("Test trace off", test_case_trace_off),
|
Case("Test trace off", test_case_trace_off),
|
||||||
|
|
|
@ -37,16 +37,19 @@ static uint32_t instance_count = 0;
|
||||||
|
|
||||||
class TestClass {
|
class TestClass {
|
||||||
public:
|
public:
|
||||||
TestClass() {
|
TestClass()
|
||||||
|
{
|
||||||
Thread::wait(500);
|
Thread::wait(500);
|
||||||
instance_count++;
|
instance_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_something() {
|
void do_something()
|
||||||
|
{
|
||||||
Thread::wait(100);
|
Thread::wait(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
~TestClass() {
|
~TestClass()
|
||||||
|
{
|
||||||
instance_count--;
|
instance_count--;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -490,6 +490,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,13 +120,15 @@ Case cases[] = {
|
||||||
Case("timer lock test", timer_lock_test),
|
Case("timer lock test", timer_lock_test),
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(20, "default_auto");
|
GREENTEA_SETUP(20, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ using namespace utest::v1;
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <class T, class F>
|
template <class T, class F>
|
||||||
void BubbleSort(T& _array, size_t array_size, F functor) {
|
void BubbleSort(T &_array, size_t array_size, F functor)
|
||||||
|
{
|
||||||
bool flag = true;
|
bool flag = true;
|
||||||
size_t numLength = array_size;
|
size_t numLength = array_size;
|
||||||
for (size_t i = 1; (i <= numLength) && flag; i++) {
|
for (size_t i = 1; (i <= numLength) && flag; i++) {
|
||||||
|
@ -56,18 +57,23 @@ void BubbleSort(T& _array, size_t array_size, F functor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct greaterAbs {
|
struct greaterAbs {
|
||||||
bool operator()(int a, int b) { return abs(a) > abs(b); }
|
bool operator()(int a, int b)
|
||||||
|
{
|
||||||
|
return abs(a) > abs(b);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void test_case_stl_equal() {
|
void test_case_stl_equal()
|
||||||
|
{
|
||||||
const int n_integers[] = {NEGATIVE_INTEGERS};
|
const int n_integers[] = {NEGATIVE_INTEGERS};
|
||||||
std::vector<int> v_pints(n_integers, n_integers + TABLE_SIZE(n_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));
|
TEST_ASSERT_TRUE(std::equal(v_pints.begin(), v_pints.end(), n_integers));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_stl_transform() {
|
void test_case_stl_transform()
|
||||||
|
{
|
||||||
const float floats[] = {FLOATS};
|
const float floats[] = {FLOATS};
|
||||||
const char *floats_str[] = {FLOATS_STR};
|
const char *floats_str[] = {FLOATS_STR};
|
||||||
float floats_transform[TABLE_SIZE(floats_str)] = {0.0};
|
float floats_transform[TABLE_SIZE(floats_str)] = {0.0};
|
||||||
|
@ -76,7 +82,8 @@ void test_case_stl_transform() {
|
||||||
TEST_ASSERT_TRUE(std::equal(floats_transform, floats_transform + TABLE_SIZE(floats_transform), floats));
|
TEST_ASSERT_TRUE(std::equal(floats_transform, floats_transform + TABLE_SIZE(floats_transform), floats));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_case_stl_sort_greater() {
|
void test_case_stl_sort_greater()
|
||||||
|
{
|
||||||
int n_integers[] = {NEGATIVE_INTEGERS};
|
int n_integers[] = {NEGATIVE_INTEGERS};
|
||||||
int n_integers2[] = {NEGATIVE_INTEGERS};
|
int n_integers2[] = {NEGATIVE_INTEGERS};
|
||||||
|
|
||||||
|
@ -87,7 +94,8 @@ void test_case_stl_sort_greater() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_case_stl_sort_abs() {
|
void test_case_stl_sort_abs()
|
||||||
|
{
|
||||||
int n_integers[] = {NEGATIVE_INTEGERS};
|
int n_integers[] = {NEGATIVE_INTEGERS};
|
||||||
int n_integers2[] = {NEGATIVE_INTEGERS};
|
int n_integers2[] = {NEGATIVE_INTEGERS};
|
||||||
|
|
||||||
|
@ -98,7 +106,8 @@ void test_case_stl_sort_abs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
|
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
|
||||||
|
{
|
||||||
greentea_case_failure_abort_handler(source, reason);
|
greentea_case_failure_abort_handler(source, reason);
|
||||||
return STATUS_CONTINUE;
|
return STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -110,13 +119,15 @@ Case cases[] = {
|
||||||
Case("STL std::sort abs", test_case_stl_sort_abs, greentea_failure_handler)
|
Case("STL std::sort abs", test_case_stl_sort_abs, greentea_failure_handler)
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(5, "default_auto");
|
GREENTEA_SETUP(5, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,7 +740,8 @@ void test_timer_time_measurement()
|
||||||
TEST_ASSERT_UINT64_WITHIN(DELTA_US(wait_val_us / US_PER_MSEC), wait_val_us, p_timer->read_high_resolution_us());
|
TEST_ASSERT_UINT64_WITHIN(DELTA_US(wait_val_us / US_PER_MSEC), wait_val_us, p_timer->read_high_resolution_us());
|
||||||
}
|
}
|
||||||
|
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(15, "default_auto");
|
GREENTEA_SETUP(15, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -769,7 +770,8 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,22 +37,26 @@ using namespace utest::v1;
|
||||||
class TestTimerEvent: public TimerEvent {
|
class TestTimerEvent: public TimerEvent {
|
||||||
private:
|
private:
|
||||||
Semaphore sem;
|
Semaphore sem;
|
||||||
virtual void handler() {
|
virtual void handler()
|
||||||
|
{
|
||||||
sem.release();
|
sem.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestTimerEvent() :
|
TestTimerEvent() :
|
||||||
TimerEvent(), sem(0, 1) {
|
TimerEvent(), sem(0, 1)
|
||||||
|
{
|
||||||
|
|
||||||
sleep_manager_lock_deep_sleep();
|
sleep_manager_lock_deep_sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTimerEvent(const ticker_data_t *data) :
|
TestTimerEvent(const ticker_data_t *data) :
|
||||||
TimerEvent(data), sem(0, 1) {
|
TimerEvent(data), sem(0, 1)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~TestTimerEvent() {
|
virtual ~TestTimerEvent()
|
||||||
|
{
|
||||||
sleep_manager_unlock_deep_sleep();
|
sleep_manager_unlock_deep_sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +65,8 @@ public:
|
||||||
using TimerEvent::insert_absolute;
|
using TimerEvent::insert_absolute;
|
||||||
using TimerEvent::remove;
|
using TimerEvent::remove;
|
||||||
|
|
||||||
int32_t sem_wait(uint32_t millisec) {
|
int32_t sem_wait(uint32_t millisec)
|
||||||
|
{
|
||||||
return sem.wait(millisec);
|
return sem.wait(millisec);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -70,19 +75,23 @@ class TestTimerEventRelative: public TestTimerEvent {
|
||||||
public:
|
public:
|
||||||
static const int32_t SEM_SLOTS_AFTER_PAST_TS_INSERTED = 0;
|
static const int32_t SEM_SLOTS_AFTER_PAST_TS_INSERTED = 0;
|
||||||
TestTimerEventRelative() :
|
TestTimerEventRelative() :
|
||||||
TestTimerEvent() {
|
TestTimerEvent()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTimerEventRelative(const ticker_data_t *data) :
|
TestTimerEventRelative(const ticker_data_t *data) :
|
||||||
TestTimerEvent(data) {
|
TestTimerEvent(data)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set relative timestamp of internal event to present_time + ts
|
// Set relative timestamp of internal event to present_time + ts
|
||||||
void set_future_timestamp(timestamp_t ts) {
|
void set_future_timestamp(timestamp_t ts)
|
||||||
|
{
|
||||||
insert(::ticker_read(_ticker_data) + ts);
|
insert(::ticker_read(_ticker_data) + ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_past_timestamp(void) {
|
void set_past_timestamp(void)
|
||||||
|
{
|
||||||
insert(::ticker_read(_ticker_data) - 1UL);
|
insert(::ticker_read(_ticker_data) - 1UL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -91,19 +100,23 @@ class TestTimerEventAbsolute: public TestTimerEvent {
|
||||||
public:
|
public:
|
||||||
static const int32_t SEM_SLOTS_AFTER_PAST_TS_INSERTED = 1;
|
static const int32_t SEM_SLOTS_AFTER_PAST_TS_INSERTED = 1;
|
||||||
TestTimerEventAbsolute() :
|
TestTimerEventAbsolute() :
|
||||||
TestTimerEvent() {
|
TestTimerEvent()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTimerEventAbsolute(const ticker_data_t *data) :
|
TestTimerEventAbsolute(const ticker_data_t *data) :
|
||||||
TestTimerEvent(data) {
|
TestTimerEvent(data)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set absolute timestamp of internal event to present_time + ts
|
// Set absolute timestamp of internal event to present_time + ts
|
||||||
void set_future_timestamp(us_timestamp_t ts) {
|
void set_future_timestamp(us_timestamp_t ts)
|
||||||
|
{
|
||||||
insert_absolute(::ticker_read_us(_ticker_data) + ts);
|
insert_absolute(::ticker_read_us(_ticker_data) + ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_past_timestamp(void) {
|
void set_past_timestamp(void)
|
||||||
|
{
|
||||||
insert_absolute(::ticker_read_us(_ticker_data) - 1ULL);
|
insert_absolute(::ticker_read_us(_ticker_data) - 1ULL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -123,7 +136,8 @@ public:
|
||||||
* Then an event handler is called
|
* Then an event handler is called
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void test_insert(void) {
|
void test_insert(void)
|
||||||
|
{
|
||||||
T tte;
|
T tte;
|
||||||
|
|
||||||
tte.set_future_timestamp(TEST_DELAY_US);
|
tte.set_future_timestamp(TEST_DELAY_US);
|
||||||
|
@ -151,7 +165,8 @@ void test_insert(void) {
|
||||||
* Then the event handler is never called
|
* Then the event handler is never called
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void test_remove(void) {
|
void test_remove(void)
|
||||||
|
{
|
||||||
T tte;
|
T tte;
|
||||||
|
|
||||||
tte.set_future_timestamp(TEST_DELAY_US * 2);
|
tte.set_future_timestamp(TEST_DELAY_US * 2);
|
||||||
|
@ -168,7 +183,8 @@ void test_remove(void) {
|
||||||
* When a timestamp of 0 us is set with @a insert_absolute()
|
* When a timestamp of 0 us is set with @a insert_absolute()
|
||||||
* Then an event handler is called instantly
|
* Then an event handler is called instantly
|
||||||
*/
|
*/
|
||||||
void test_insert_zero(void) {
|
void test_insert_zero(void)
|
||||||
|
{
|
||||||
TestTimerEvent tte;
|
TestTimerEvent tte;
|
||||||
|
|
||||||
tte.insert_absolute(0ULL);
|
tte.insert_absolute(0ULL);
|
||||||
|
@ -194,7 +210,8 @@ void test_insert_zero(void) {
|
||||||
* Then an event handler is called instantly
|
* Then an event handler is called instantly
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void test_insert_past(void) {
|
void test_insert_past(void)
|
||||||
|
{
|
||||||
T tte;
|
T tte;
|
||||||
|
|
||||||
tte.set_past_timestamp();
|
tte.set_past_timestamp();
|
||||||
|
|
|
@ -24,22 +24,34 @@ using namespace utest::v1;
|
||||||
// static functions
|
// static functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func0()
|
T static_func0()
|
||||||
{ return 0; }
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func1(T a0)
|
T static_func1(T a0)
|
||||||
{ return 0 | a0; }
|
{
|
||||||
|
return 0 | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func2(T a0, T a1)
|
T static_func2(T a0, T a1)
|
||||||
{ return 0 | a0 | a1; }
|
{
|
||||||
|
return 0 | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func3(T a0, T a1, T a2)
|
T static_func3(T a0, T a1, T a2)
|
||||||
{ return 0 | a0 | a1 | a2; }
|
{
|
||||||
|
return 0 | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func4(T a0, T a1, T a2, T a3)
|
T static_func4(T a0, T a1, T a2, T a3)
|
||||||
{ return 0 | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func5(T a0, T a1, T a2, T a3, T a4)
|
T static_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return 0 | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// class functions
|
// class functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -48,205 +60,349 @@ struct Thing {
|
||||||
Thing() : t(0x80) {}
|
Thing() : t(0x80) {}
|
||||||
|
|
||||||
T member_func0()
|
T member_func0()
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T member_func1(T a0)
|
T member_func1(T a0)
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T member_func2(T a0, T a1)
|
T member_func2(T a0, T a1)
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T member_func3(T a0, T a1, T a2)
|
T member_func3(T a0, T a1, T a2)
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T member_func4(T a0, T a1, T a2, T a3)
|
T member_func4(T a0, T a1, T a2, T a3)
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T member_func5(T a0, T a1, T a2, T a3, T a4)
|
T member_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_member_func0() const
|
T const_member_func0() const
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T const_member_func1(T a0) const
|
T const_member_func1(T a0) const
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T const_member_func2(T a0, T a1) const
|
T const_member_func2(T a0, T a1) const
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T const_member_func3(T a0, T a1, T a2) const
|
T const_member_func3(T a0, T a1, T a2) const
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T const_member_func4(T a0, T a1, T a2, T a3) const
|
T const_member_func4(T a0, T a1, T a2, T a3) const
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
|
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T volatile_member_func0() volatile
|
T volatile_member_func0() volatile
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T volatile_member_func1(T a0) volatile
|
T volatile_member_func1(T a0) volatile
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T volatile_member_func2(T a0, T a1) volatile
|
T volatile_member_func2(T a0, T a1) volatile
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T volatile_member_func3(T a0, T a1, T a2) volatile
|
T volatile_member_func3(T a0, T a1, T a2) volatile
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
|
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
|
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_volatile_member_func0() const volatile
|
T const_volatile_member_func0() const volatile
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T const_volatile_member_func1(T a0) const volatile
|
T const_volatile_member_func1(T a0) const volatile
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T const_volatile_member_func2(T a0, T a1) const volatile
|
T const_volatile_member_func2(T a0, T a1) const volatile
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
|
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
|
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
|
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// bound functions
|
// bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func0(Thing<T> *t)
|
T bound_func0(Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func1(Thing<T> *t, T a0)
|
T bound_func1(Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func2(Thing<T> *t, T a0, T a1)
|
T bound_func2(Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
|
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
|
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func0(const Thing<T> *t)
|
T const_bound_func0(const Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func1(const Thing<T> *t, T a0)
|
T const_bound_func1(const Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func2(const Thing<T> *t, T a0, T a1)
|
T const_bound_func2(const Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2)
|
T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
|
T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func0(volatile Thing<T> *t)
|
T volatile_bound_func0(volatile Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func1(volatile Thing<T> *t, T a0)
|
T volatile_bound_func1(volatile Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1)
|
T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2)
|
T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func0(const volatile Thing<T> *t)
|
T const_volatile_bound_func0(const volatile Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func1(const volatile Thing<T> *t, T a0)
|
T const_volatile_bound_func1(const volatile Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1)
|
T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
|
T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// void functions
|
// void functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func0(void *t)
|
T void_func0(void *t)
|
||||||
{ return static_cast<Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func1(void *t, T a0)
|
T void_func1(void *t, T a0)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func2(void *t, T a0, T a1)
|
T void_func2(void *t, T a0, T a1)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func3(void *t, T a0, T a1, T a2)
|
T void_func3(void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func4(void *t, T a0, T a1, T a2, T a3)
|
T void_func4(void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func5(void *t, T a0, T a1, T a2, T a3, T a4)
|
T void_func5(void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func0(const void *t)
|
T const_void_func0(const void *t)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func1(const void *t, T a0)
|
T const_void_func1(const void *t, T a0)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func2(const void *t, T a0, T a1)
|
T const_void_func2(const void *t, T a0, T a1)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func3(const void *t, T a0, T a1, T a2)
|
T const_void_func3(const void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func4(const void *t, T a0, T a1, T a2, T a3)
|
T const_void_func4(const void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4)
|
T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func0(volatile void *t)
|
T volatile_void_func0(volatile void *t)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func1(volatile void *t, T a0)
|
T volatile_void_func1(volatile void *t, T a0)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func2(volatile void *t, T a0, T a1)
|
T volatile_void_func2(volatile void *t, T a0, T a1)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func3(volatile void *t, T a0, T a1, T a2)
|
T volatile_void_func3(volatile void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3)
|
T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func0(const volatile void *t)
|
T const_volatile_void_func0(const volatile void *t)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func1(const volatile void *t, T a0)
|
T const_volatile_void_func1(const volatile void *t, T a0)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func2(const volatile void *t, T a0, T a1)
|
T const_volatile_void_func2(const volatile void *t, T a0, T a1)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2)
|
T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3)
|
T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// Inheriting class
|
// Inheriting class
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -257,73 +413,85 @@ class Thing2 : public Thing<T> {
|
||||||
// function call and result verification
|
// function call and result verification
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Verifier {
|
struct Verifier {
|
||||||
static void verify0(Callback<T()> func) {
|
static void verify0(Callback<T()> func)
|
||||||
|
{
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x00);
|
TEST_ASSERT_EQUAL(result, 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify0(O *obj, M method) {
|
static void verify0(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T()> func(obj, method);
|
Callback<T()> func(obj, method);
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x80);
|
TEST_ASSERT_EQUAL(result, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify1(Callback<T(T)> func) {
|
static void verify1(Callback<T(T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify1(O *obj, M method) {
|
static void verify1(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T)> func(obj, method);
|
Callback<T(T)> func(obj, method);
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify2(Callback<T(T, T)> func) {
|
static void verify2(Callback<T(T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify2(O *obj, M method) {
|
static void verify2(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T)> func(obj, method);
|
Callback<T(T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify3(Callback<T(T, T, T)> func) {
|
static void verify3(Callback<T(T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify3(O *obj, M method) {
|
static void verify3(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T)> func(obj, method);
|
Callback<T(T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify4(Callback<T(T, T, T, T)> func) {
|
static void verify4(Callback<T(T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify4(O *obj, M method) {
|
static void verify4(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify5(Callback<T(T, T, T, T, T)> func) {
|
static void verify5(Callback<T(T, T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify5(O *obj, M method) {
|
static void verify5(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
|
@ -333,7 +501,8 @@ struct Verifier {
|
||||||
|
|
||||||
// test dispatch
|
// test dispatch
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch0() {
|
void test_dispatch0()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Thing2<T> thing2;
|
Thing2<T> thing2;
|
||||||
Verifier<T>::verify0(static_func0<T>);
|
Verifier<T>::verify0(static_func0<T>);
|
||||||
|
@ -363,7 +532,8 @@ void test_dispatch0() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch1() {
|
void test_dispatch1()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Thing2<T> thing2;
|
Thing2<T> thing2;
|
||||||
Verifier<T>::verify1(static_func1<T>);
|
Verifier<T>::verify1(static_func1<T>);
|
||||||
|
@ -393,7 +563,8 @@ void test_dispatch1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch2() {
|
void test_dispatch2()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Thing2<T> thing2;
|
Thing2<T> thing2;
|
||||||
Verifier<T>::verify2(static_func2<T>);
|
Verifier<T>::verify2(static_func2<T>);
|
||||||
|
@ -423,7 +594,8 @@ void test_dispatch2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch3() {
|
void test_dispatch3()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Thing2<T> thing2;
|
Thing2<T> thing2;
|
||||||
Verifier<T>::verify3(static_func3<T>);
|
Verifier<T>::verify3(static_func3<T>);
|
||||||
|
@ -453,7 +625,8 @@ void test_dispatch3() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch4() {
|
void test_dispatch4()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Thing2<T> thing2;
|
Thing2<T> thing2;
|
||||||
Verifier<T>::verify4(static_func4<T>);
|
Verifier<T>::verify4(static_func4<T>);
|
||||||
|
@ -483,7 +656,8 @@ void test_dispatch4() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch5() {
|
void test_dispatch5()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Thing2<T> thing2;
|
Thing2<T> thing2;
|
||||||
Verifier<T>::verify5(static_func5<T>);
|
Verifier<T>::verify5(static_func5<T>);
|
||||||
|
@ -514,7 +688,8 @@ void test_dispatch5() {
|
||||||
|
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(10, "default_auto");
|
GREENTEA_SETUP(10, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -530,6 +705,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,35 @@ using namespace utest::v1;
|
||||||
|
|
||||||
// static functions
|
// static functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func0() { return 0; }
|
T static_func0()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func1(T a0) { return 0 | a0; }
|
T static_func1(T a0)
|
||||||
|
{
|
||||||
|
return 0 | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func2(T a0, T a1) { return 0 | a0 | a1; }
|
T static_func2(T a0, T a1)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func3(T a0, T a1, T a2) { return 0 | a0 | a1 | a2; }
|
T static_func3(T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func4(T a0, T a1, T a2, T a3) { return 0 | a0 | a1 | a2 | a3; }
|
T static_func4(T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func5(T a0, T a1, T a2, T a3, T a4) { return 0 | a0 | a1 | a2 | a3 | a4; }
|
T static_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// class functions
|
// class functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -41,162 +59,318 @@ struct Thing {
|
||||||
T t;
|
T t;
|
||||||
Thing() : t(0x80) {}
|
Thing() : t(0x80) {}
|
||||||
|
|
||||||
T member_func0() { return t; }
|
T member_func0()
|
||||||
T member_func1(T a0) { return t | a0; }
|
{
|
||||||
T member_func2(T a0, T a1) { return t | a0 | a1; }
|
return t;
|
||||||
T member_func3(T a0, T a1, T a2) { return t | a0 | a1 | a2; }
|
}
|
||||||
T member_func4(T a0, T a1, T a2, T a3) { return t | a0 | a1 | a2 | a3; }
|
T member_func1(T a0)
|
||||||
T member_func5(T a0, T a1, T a2, T a3, T a4) { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T member_func2(T a0, T a1)
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T member_func3(T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T member_func4(T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T member_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_member_func0() const { return t; }
|
T const_member_func0() const
|
||||||
T const_member_func1(T a0) const { return t | a0; }
|
{
|
||||||
T const_member_func2(T a0, T a1) const { return t | a0 | a1; }
|
return t;
|
||||||
T const_member_func3(T a0, T a1, T a2) const { return t | a0 | a1 | a2; }
|
}
|
||||||
T const_member_func4(T a0, T a1, T a2, T a3) const { return t | a0 | a1 | a2 | a3; }
|
T const_member_func1(T a0) const
|
||||||
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T const_member_func2(T a0, T a1) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T const_member_func3(T a0, T a1, T a2) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T const_member_func4(T a0, T a1, T a2, T a3) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T volatile_member_func0() volatile { return t; }
|
T volatile_member_func0() volatile
|
||||||
T volatile_member_func1(T a0) volatile { return t | a0; }
|
{
|
||||||
T volatile_member_func2(T a0, T a1) volatile { return t | a0 | a1; }
|
return t;
|
||||||
T volatile_member_func3(T a0, T a1, T a2) volatile { return t | a0 | a1 | a2; }
|
}
|
||||||
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile { return t | a0 | a1 | a2 | a3; }
|
T volatile_member_func1(T a0) volatile
|
||||||
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T volatile_member_func2(T a0, T a1) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T volatile_member_func3(T a0, T a1, T a2) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_volatile_member_func0() const volatile { return t; }
|
T const_volatile_member_func0() const volatile
|
||||||
T const_volatile_member_func1(T a0) const volatile { return t | a0; }
|
{
|
||||||
T const_volatile_member_func2(T a0, T a1) const volatile { return t | a0 | a1; }
|
return t;
|
||||||
T const_volatile_member_func3(T a0, T a1, T a2) const volatile { return t | a0 | a1 | a2; }
|
}
|
||||||
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile { return t | a0 | a1 | a2 | a3; }
|
T const_volatile_member_func1(T a0) const volatile
|
||||||
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func2(T a0, T a1) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// bound functions
|
// bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func0(Thing<T> *t) { return t->t; }
|
T bound_func0(Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func1(Thing<T> *t, T a0) { return t->t | a0; }
|
T bound_func1(Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func2(Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T bound_func2(Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func3(Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// const bound functions
|
// const bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func0(const Thing<T> *t) { return t->t; }
|
T const_func0(const Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func1(const Thing<T> *t, T a0) { return t->t | a0; }
|
T const_func1(const Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func2(const Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T const_func2(const Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func3(const Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T const_func3(const Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T const_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T const_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// volatile bound functions
|
// volatile bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func0(volatile Thing<T> *t) { return t->t; }
|
T volatile_func0(volatile Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func1(volatile Thing<T> *t, T a0) { return t->t | a0; }
|
T volatile_func1(volatile Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func2(volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T volatile_func2(volatile Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func3(volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T volatile_func3(volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T volatile_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T volatile_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// const volatile bound functions
|
// const volatile bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func0(const volatile Thing<T> *t) { return t->t; }
|
T const_volatile_func0(const volatile Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func1(const volatile Thing<T> *t, T a0) { return t->t | a0; }
|
T const_volatile_func1(const volatile Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func2(const volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T const_volatile_func2(const volatile Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func3(const volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T const_volatile_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T const_volatile_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T const_volatile_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// function call and result verification
|
// function call and result verification
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Verifier {
|
struct Verifier {
|
||||||
static void verify0(Callback<T()> func) {
|
static void verify0(Callback<T()> func)
|
||||||
|
{
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x00);
|
TEST_ASSERT_EQUAL(result, 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify0(O *obj, M method) {
|
static void verify0(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T()> func(obj, method);
|
Callback<T()> func(obj, method);
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x80);
|
TEST_ASSERT_EQUAL(result, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify1(Callback<T(T)> func) {
|
static void verify1(Callback<T(T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify1(O *obj, M method) {
|
static void verify1(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T)> func(obj, method);
|
Callback<T(T)> func(obj, method);
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify2(Callback<T(T, T)> func) {
|
static void verify2(Callback<T(T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify2(O *obj, M method) {
|
static void verify2(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T)> func(obj, method);
|
Callback<T(T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify3(Callback<T(T, T, T)> func) {
|
static void verify3(Callback<T(T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify3(O *obj, M method) {
|
static void verify3(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T)> func(obj, method);
|
Callback<T(T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify4(Callback<T(T, T, T, T)> func) {
|
static void verify4(Callback<T(T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify4(O *obj, M method) {
|
static void verify4(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify5(Callback<T(T, T, T, T, T)> func) {
|
static void verify5(Callback<T(T, T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify5(O *obj, M method) {
|
static void verify5(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
|
@ -206,7 +380,8 @@ struct Verifier {
|
||||||
|
|
||||||
// test dispatch
|
// test dispatch
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch0() {
|
void test_dispatch0()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify0(static_func0<T>);
|
Verifier<T>::verify0(static_func0<T>);
|
||||||
Verifier<T>::verify0(&thing, &Thing<T>::member_func0);
|
Verifier<T>::verify0(&thing, &Thing<T>::member_func0);
|
||||||
|
@ -229,7 +404,8 @@ void test_dispatch0() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch1() {
|
void test_dispatch1()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify1(static_func1<T>);
|
Verifier<T>::verify1(static_func1<T>);
|
||||||
Verifier<T>::verify1(&thing, &Thing<T>::member_func1);
|
Verifier<T>::verify1(&thing, &Thing<T>::member_func1);
|
||||||
|
@ -252,7 +428,8 @@ void test_dispatch1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch2() {
|
void test_dispatch2()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify2(static_func2<T>);
|
Verifier<T>::verify2(static_func2<T>);
|
||||||
Verifier<T>::verify2(&thing, &Thing<T>::member_func2);
|
Verifier<T>::verify2(&thing, &Thing<T>::member_func2);
|
||||||
|
@ -275,7 +452,8 @@ void test_dispatch2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch3() {
|
void test_dispatch3()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify3(static_func3<T>);
|
Verifier<T>::verify3(static_func3<T>);
|
||||||
Verifier<T>::verify3(&thing, &Thing<T>::member_func3);
|
Verifier<T>::verify3(&thing, &Thing<T>::member_func3);
|
||||||
|
@ -298,7 +476,8 @@ void test_dispatch3() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch4() {
|
void test_dispatch4()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify4(static_func4<T>);
|
Verifier<T>::verify4(static_func4<T>);
|
||||||
Verifier<T>::verify4(&thing, &Thing<T>::member_func4);
|
Verifier<T>::verify4(&thing, &Thing<T>::member_func4);
|
||||||
|
@ -321,7 +500,8 @@ void test_dispatch4() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch5() {
|
void test_dispatch5()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify5(static_func5<T>);
|
Verifier<T>::verify5(static_func5<T>);
|
||||||
Verifier<T>::verify5(&thing, &Thing<T>::member_func5);
|
Verifier<T>::verify5(&thing, &Thing<T>::member_func5);
|
||||||
|
@ -345,7 +525,8 @@ void test_dispatch5() {
|
||||||
|
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(10, "default_auto");
|
GREENTEA_SETUP(10, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -361,6 +542,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,35 @@ using namespace utest::v1;
|
||||||
|
|
||||||
// static functions
|
// static functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func0() { return 0; }
|
T static_func0()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func1(T a0) { return 0 | a0; }
|
T static_func1(T a0)
|
||||||
|
{
|
||||||
|
return 0 | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func2(T a0, T a1) { return 0 | a0 | a1; }
|
T static_func2(T a0, T a1)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func3(T a0, T a1, T a2) { return 0 | a0 | a1 | a2; }
|
T static_func3(T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func4(T a0, T a1, T a2, T a3) { return 0 | a0 | a1 | a2 | a3; }
|
T static_func4(T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func5(T a0, T a1, T a2, T a3, T a4) { return 0 | a0 | a1 | a2 | a3 | a4; }
|
T static_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// class functions
|
// class functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -41,162 +59,318 @@ struct Thing {
|
||||||
T t;
|
T t;
|
||||||
Thing() : t(0x80) {}
|
Thing() : t(0x80) {}
|
||||||
|
|
||||||
T member_func0() { return t; }
|
T member_func0()
|
||||||
T member_func1(T a0) { return t | a0; }
|
{
|
||||||
T member_func2(T a0, T a1) { return t | a0 | a1; }
|
return t;
|
||||||
T member_func3(T a0, T a1, T a2) { return t | a0 | a1 | a2; }
|
}
|
||||||
T member_func4(T a0, T a1, T a2, T a3) { return t | a0 | a1 | a2 | a3; }
|
T member_func1(T a0)
|
||||||
T member_func5(T a0, T a1, T a2, T a3, T a4) { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T member_func2(T a0, T a1)
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T member_func3(T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T member_func4(T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T member_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_member_func0() const { return t; }
|
T const_member_func0() const
|
||||||
T const_member_func1(T a0) const { return t | a0; }
|
{
|
||||||
T const_member_func2(T a0, T a1) const { return t | a0 | a1; }
|
return t;
|
||||||
T const_member_func3(T a0, T a1, T a2) const { return t | a0 | a1 | a2; }
|
}
|
||||||
T const_member_func4(T a0, T a1, T a2, T a3) const { return t | a0 | a1 | a2 | a3; }
|
T const_member_func1(T a0) const
|
||||||
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T const_member_func2(T a0, T a1) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T const_member_func3(T a0, T a1, T a2) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T const_member_func4(T a0, T a1, T a2, T a3) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T volatile_member_func0() volatile { return t; }
|
T volatile_member_func0() volatile
|
||||||
T volatile_member_func1(T a0) volatile { return t | a0; }
|
{
|
||||||
T volatile_member_func2(T a0, T a1) volatile { return t | a0 | a1; }
|
return t;
|
||||||
T volatile_member_func3(T a0, T a1, T a2) volatile { return t | a0 | a1 | a2; }
|
}
|
||||||
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile { return t | a0 | a1 | a2 | a3; }
|
T volatile_member_func1(T a0) volatile
|
||||||
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T volatile_member_func2(T a0, T a1) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T volatile_member_func3(T a0, T a1, T a2) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_volatile_member_func0() const volatile { return t; }
|
T const_volatile_member_func0() const volatile
|
||||||
T const_volatile_member_func1(T a0) const volatile { return t | a0; }
|
{
|
||||||
T const_volatile_member_func2(T a0, T a1) const volatile { return t | a0 | a1; }
|
return t;
|
||||||
T const_volatile_member_func3(T a0, T a1, T a2) const volatile { return t | a0 | a1 | a2; }
|
}
|
||||||
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile { return t | a0 | a1 | a2 | a3; }
|
T const_volatile_member_func1(T a0) const volatile
|
||||||
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile { return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func2(T a0, T a1) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
|
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
|
||||||
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// bound functions
|
// bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func0(Thing<T> *t) { return t->t; }
|
T bound_func0(Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func1(Thing<T> *t, T a0) { return t->t | a0; }
|
T bound_func1(Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func2(Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T bound_func2(Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func3(Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// const bound functions
|
// const bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func0(const Thing<T> *t) { return t->t; }
|
T const_func0(const Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func1(const Thing<T> *t, T a0) { return t->t | a0; }
|
T const_func1(const Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func2(const Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T const_func2(const Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func3(const Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T const_func3(const Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T const_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T const_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// volatile bound functions
|
// volatile bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func0(volatile Thing<T> *t) { return t->t; }
|
T volatile_func0(volatile Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func1(volatile Thing<T> *t, T a0) { return t->t | a0; }
|
T volatile_func1(volatile Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func2(volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T volatile_func2(volatile Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func3(volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T volatile_func3(volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T volatile_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T volatile_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// const volatile bound functions
|
// const volatile bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func0(const volatile Thing<T> *t) { return t->t; }
|
T const_volatile_func0(const volatile Thing<T> *t)
|
||||||
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func1(const volatile Thing<T> *t, T a0) { return t->t | a0; }
|
T const_volatile_func1(const volatile Thing<T> *t, T a0)
|
||||||
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func2(const volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
|
T const_volatile_func2(const volatile Thing<T> *t, T a0, T a1)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func3(const volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
|
T const_volatile_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
|
T const_volatile_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
|
T const_volatile_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// function call and result verification
|
// function call and result verification
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Verifier {
|
struct Verifier {
|
||||||
static void verify0(Callback<T()> func) {
|
static void verify0(Callback<T()> func)
|
||||||
|
{
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x00);
|
TEST_ASSERT_EQUAL(result, 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify0(O *obj, M method) {
|
static void verify0(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T()> func(obj, method);
|
Callback<T()> func(obj, method);
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x80);
|
TEST_ASSERT_EQUAL(result, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify1(Callback<T(T)> func) {
|
static void verify1(Callback<T(T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify1(O *obj, M method) {
|
static void verify1(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T)> func(obj, method);
|
Callback<T(T)> func(obj, method);
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify2(Callback<T(T, T)> func) {
|
static void verify2(Callback<T(T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify2(O *obj, M method) {
|
static void verify2(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T)> func(obj, method);
|
Callback<T(T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify3(Callback<T(T, T, T)> func) {
|
static void verify3(Callback<T(T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify3(O *obj, M method) {
|
static void verify3(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T)> func(obj, method);
|
Callback<T(T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify4(Callback<T(T, T, T, T)> func) {
|
static void verify4(Callback<T(T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify4(O *obj, M method) {
|
static void verify4(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify5(Callback<T(T, T, T, T, T)> func) {
|
static void verify5(Callback<T(T, T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify5(O *obj, M method) {
|
static void verify5(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
|
@ -206,7 +380,8 @@ struct Verifier {
|
||||||
|
|
||||||
// test dispatch
|
// test dispatch
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch0() {
|
void test_dispatch0()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify0(static_func0<T>);
|
Verifier<T>::verify0(static_func0<T>);
|
||||||
Verifier<T>::verify0(&thing, &Thing<T>::member_func0);
|
Verifier<T>::verify0(&thing, &Thing<T>::member_func0);
|
||||||
|
@ -229,7 +404,8 @@ void test_dispatch0() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch1() {
|
void test_dispatch1()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify1(static_func1<T>);
|
Verifier<T>::verify1(static_func1<T>);
|
||||||
Verifier<T>::verify1(&thing, &Thing<T>::member_func1);
|
Verifier<T>::verify1(&thing, &Thing<T>::member_func1);
|
||||||
|
@ -252,7 +428,8 @@ void test_dispatch1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch2() {
|
void test_dispatch2()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify2(static_func2<T>);
|
Verifier<T>::verify2(static_func2<T>);
|
||||||
Verifier<T>::verify2(&thing, &Thing<T>::member_func2);
|
Verifier<T>::verify2(&thing, &Thing<T>::member_func2);
|
||||||
|
@ -275,7 +452,8 @@ void test_dispatch2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch3() {
|
void test_dispatch3()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify3(static_func3<T>);
|
Verifier<T>::verify3(static_func3<T>);
|
||||||
Verifier<T>::verify3(&thing, &Thing<T>::member_func3);
|
Verifier<T>::verify3(&thing, &Thing<T>::member_func3);
|
||||||
|
@ -298,7 +476,8 @@ void test_dispatch3() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch4() {
|
void test_dispatch4()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify4(static_func4<T>);
|
Verifier<T>::verify4(static_func4<T>);
|
||||||
Verifier<T>::verify4(&thing, &Thing<T>::member_func4);
|
Verifier<T>::verify4(&thing, &Thing<T>::member_func4);
|
||||||
|
@ -321,7 +500,8 @@ void test_dispatch4() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_dispatch5() {
|
void test_dispatch5()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
Verifier<T>::verify5(static_func5<T>);
|
Verifier<T>::verify5(static_func5<T>);
|
||||||
Verifier<T>::verify5(&thing, &Thing<T>::member_func5);
|
Verifier<T>::verify5(&thing, &Thing<T>::member_func5);
|
||||||
|
@ -345,7 +525,8 @@ void test_dispatch5() {
|
||||||
|
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(10, "default_auto");
|
GREENTEA_SETUP(10, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -361,6 +542,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,22 +24,34 @@ using namespace utest::v1;
|
||||||
// static functions
|
// static functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func0()
|
T static_func0()
|
||||||
{ return 0; }
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func1(T a0)
|
T static_func1(T a0)
|
||||||
{ return 0 | a0; }
|
{
|
||||||
|
return 0 | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func2(T a0, T a1)
|
T static_func2(T a0, T a1)
|
||||||
{ return 0 | a0 | a1; }
|
{
|
||||||
|
return 0 | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func3(T a0, T a1, T a2)
|
T static_func3(T a0, T a1, T a2)
|
||||||
{ return 0 | a0 | a1 | a2; }
|
{
|
||||||
|
return 0 | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func4(T a0, T a1, T a2, T a3)
|
T static_func4(T a0, T a1, T a2, T a3)
|
||||||
{ return 0 | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T static_func5(T a0, T a1, T a2, T a3, T a4)
|
T static_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return 0 | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return 0 | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// class functions
|
// class functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -48,277 +60,433 @@ struct Thing {
|
||||||
Thing() : t(0x80) {}
|
Thing() : t(0x80) {}
|
||||||
|
|
||||||
T member_func0()
|
T member_func0()
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T member_func1(T a0)
|
T member_func1(T a0)
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T member_func2(T a0, T a1)
|
T member_func2(T a0, T a1)
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T member_func3(T a0, T a1, T a2)
|
T member_func3(T a0, T a1, T a2)
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T member_func4(T a0, T a1, T a2, T a3)
|
T member_func4(T a0, T a1, T a2, T a3)
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T member_func5(T a0, T a1, T a2, T a3, T a4)
|
T member_func5(T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_member_func0() const
|
T const_member_func0() const
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T const_member_func1(T a0) const
|
T const_member_func1(T a0) const
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T const_member_func2(T a0, T a1) const
|
T const_member_func2(T a0, T a1) const
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T const_member_func3(T a0, T a1, T a2) const
|
T const_member_func3(T a0, T a1, T a2) const
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T const_member_func4(T a0, T a1, T a2, T a3) const
|
T const_member_func4(T a0, T a1, T a2, T a3) const
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
|
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T volatile_member_func0() volatile
|
T volatile_member_func0() volatile
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T volatile_member_func1(T a0) volatile
|
T volatile_member_func1(T a0) volatile
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T volatile_member_func2(T a0, T a1) volatile
|
T volatile_member_func2(T a0, T a1) volatile
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T volatile_member_func3(T a0, T a1, T a2) volatile
|
T volatile_member_func3(T a0, T a1, T a2) volatile
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
|
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
|
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
T const_volatile_member_func0() const volatile
|
T const_volatile_member_func0() const volatile
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
T const_volatile_member_func1(T a0) const volatile
|
T const_volatile_member_func1(T a0) const volatile
|
||||||
{ return t | a0; }
|
{
|
||||||
|
return t | a0;
|
||||||
|
}
|
||||||
T const_volatile_member_func2(T a0, T a1) const volatile
|
T const_volatile_member_func2(T a0, T a1) const volatile
|
||||||
{ return t | a0 | a1; }
|
{
|
||||||
|
return t | a0 | a1;
|
||||||
|
}
|
||||||
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
|
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
|
||||||
{ return t | a0 | a1 | a2; }
|
{
|
||||||
|
return t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
|
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
|
||||||
{ return t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
|
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
|
||||||
{ return t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// bound functions
|
// bound functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func0(Thing<T> *t)
|
T bound_func0(Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func1(Thing<T> *t, T a0)
|
T bound_func1(Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func2(Thing<T> *t, T a0, T a1)
|
T bound_func2(Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
|
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
|
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func0(const Thing<T> *t)
|
T const_bound_func0(const Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func1(const Thing<T> *t, T a0)
|
T const_bound_func1(const Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func2(const Thing<T> *t, T a0, T a1)
|
T const_bound_func2(const Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2)
|
T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
|
T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func0(volatile Thing<T> *t)
|
T volatile_bound_func0(volatile Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func1(volatile Thing<T> *t, T a0)
|
T volatile_bound_func1(volatile Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1)
|
T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2)
|
T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func0(const volatile Thing<T> *t)
|
T const_volatile_bound_func0(const volatile Thing<T> *t)
|
||||||
{ return t->t; }
|
{
|
||||||
|
return t->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func1(const volatile Thing<T> *t, T a0)
|
T const_volatile_bound_func1(const volatile Thing<T> *t, T a0)
|
||||||
{ return t->t | a0; }
|
{
|
||||||
|
return t->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1)
|
T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1)
|
||||||
{ return t->t | a0 | a1; }
|
{
|
||||||
|
return t->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
|
T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
|
||||||
{ return t->t | a0 | a1 | a2; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
|
||||||
{ return t->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return t->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return t->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
// void functions
|
// void functions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func0(void *t)
|
T void_func0(void *t)
|
||||||
{ return static_cast<Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func1(void *t, T a0)
|
T void_func1(void *t, T a0)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func2(void *t, T a0, T a1)
|
T void_func2(void *t, T a0, T a1)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func3(void *t, T a0, T a1, T a2)
|
T void_func3(void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func4(void *t, T a0, T a1, T a2, T a3)
|
T void_func4(void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T void_func5(void *t, T a0, T a1, T a2, T a3, T a4)
|
T void_func5(void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func0(const void *t)
|
T const_void_func0(const void *t)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func1(const void *t, T a0)
|
T const_void_func1(const void *t, T a0)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func2(const void *t, T a0, T a1)
|
T const_void_func2(const void *t, T a0, T a1)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func3(const void *t, T a0, T a1, T a2)
|
T const_void_func3(const void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func4(const void *t, T a0, T a1, T a2, T a3)
|
T const_void_func4(const void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4)
|
T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func0(volatile void *t)
|
T volatile_void_func0(volatile void *t)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func1(volatile void *t, T a0)
|
T volatile_void_func1(volatile void *t, T a0)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func2(volatile void *t, T a0, T a1)
|
T volatile_void_func2(volatile void *t, T a0, T a1)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func3(volatile void *t, T a0, T a1, T a2)
|
T volatile_void_func3(volatile void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3)
|
T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func0(const volatile void *t)
|
T const_volatile_void_func0(const volatile void *t)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func1(const volatile void *t, T a0)
|
T const_volatile_void_func1(const volatile void *t, T a0)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func2(const volatile void *t, T a0, T a1)
|
T const_volatile_void_func2(const volatile void *t, T a0, T a1)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2)
|
T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3)
|
T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3;
|
||||||
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4)
|
||||||
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
|
{
|
||||||
|
return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// function call and result verification
|
// function call and result verification
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Verifier {
|
struct Verifier {
|
||||||
static void verify0(Callback<T()> func) {
|
static void verify0(Callback<T()> func)
|
||||||
|
{
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x00);
|
TEST_ASSERT_EQUAL(result, 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify0(O *obj, M method) {
|
static void verify0(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T()> func(obj, method);
|
Callback<T()> func(obj, method);
|
||||||
T result = func();
|
T result = func();
|
||||||
TEST_ASSERT_EQUAL(result, 0x80);
|
TEST_ASSERT_EQUAL(result, 0x80);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify1(Callback<T(T)> func) {
|
static void verify1(Callback<T(T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify1(O *obj, M method) {
|
static void verify1(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T)> func(obj, method);
|
Callback<T(T)> func(obj, method);
|
||||||
T result = func((1 << 0));
|
T result = func((1 << 0));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify2(Callback<T(T, T)> func) {
|
static void verify2(Callback<T(T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify2(O *obj, M method) {
|
static void verify2(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T)> func(obj, method);
|
Callback<T(T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1));
|
T result = func((1 << 0), (1 << 1));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify3(Callback<T(T, T, T)> func) {
|
static void verify3(Callback<T(T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify3(O *obj, M method) {
|
static void verify3(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T)> func(obj, method);
|
Callback<T(T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2));
|
T result = func((1 << 0), (1 << 1), (1 << 2));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify4(Callback<T(T, T, T, T)> func) {
|
static void verify4(Callback<T(T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify4(O *obj, M method) {
|
static void verify4(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify5(Callback<T(T, T, T, T, T)> func) {
|
static void verify5(Callback<T(T, T, T, T, T)> func)
|
||||||
|
{
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x00 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename O, typename M>
|
template <typename O, typename M>
|
||||||
static void verify5(O *obj, M method) {
|
static void verify5(O *obj, M method)
|
||||||
|
{
|
||||||
Callback<T(T, T, T, T, T)> func(obj, method);
|
Callback<T(T, T, T, T, T)> func(obj, method);
|
||||||
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
T result = func((1 << 0), (1 << 1), (1 << 2), (1 << 3), (1 << 4));
|
||||||
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
TEST_ASSERT_EQUAL(result, 0x80 | (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4));
|
||||||
|
@ -328,7 +496,8 @@ struct Verifier {
|
||||||
|
|
||||||
// test dispatch
|
// test dispatch
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_fparg1() {
|
void test_fparg1()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
FunctionPointerArg1<T, T> fp(static_func1<T>);
|
FunctionPointerArg1<T, T> fp(static_func1<T>);
|
||||||
Verifier<T>::verify1(fp);
|
Verifier<T>::verify1(fp);
|
||||||
|
@ -336,7 +505,8 @@ void test_fparg1() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void test_fparg0() {
|
void test_fparg0()
|
||||||
|
{
|
||||||
Thing<T> thing;
|
Thing<T> thing;
|
||||||
FunctionPointerArg1<T, void> fp(static_func0<T>);
|
FunctionPointerArg1<T, void> fp(static_func0<T>);
|
||||||
Verifier<T>::verify0(fp);
|
Verifier<T>::verify0(fp);
|
||||||
|
@ -345,7 +515,8 @@ void test_fparg0() {
|
||||||
|
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(10, "default_auto");
|
GREENTEA_SETUP(10, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -357,6 +528,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,7 @@ using namespace utest::v1;
|
||||||
|
|
||||||
const uint8_t input_data[] = "123456789";
|
const uint8_t input_data[] = "123456789";
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
const crc_mbed_config config_data;
|
const crc_mbed_config config_data;
|
||||||
uint32_t expected_result;
|
uint32_t expected_result;
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,13 @@ static void erase_range(flash_t *flash, uint32_t addr, uint32_t size)
|
||||||
MBED_NOINLINE
|
MBED_NOINLINE
|
||||||
__asm static void delay_loop(uint32_t count)
|
__asm static void delay_loop(uint32_t count)
|
||||||
{
|
{
|
||||||
|
// AStyle should not format inline assembly
|
||||||
|
// *INDENT-OFF*
|
||||||
1
|
1
|
||||||
SUBS a1, a1, #1
|
SUBS a1, a1, #1
|
||||||
BCS %BT1
|
BCS %BT1
|
||||||
BX lr
|
BX lr
|
||||||
|
// *INDENT-ON*
|
||||||
}
|
}
|
||||||
#elif defined (__ICCARM__)
|
#elif defined (__ICCARM__)
|
||||||
MBED_NOINLINE
|
MBED_NOINLINE
|
||||||
|
@ -246,13 +249,15 @@ Case cases[] = {
|
||||||
Case("Flash - clock and cache test", flash_clock_and_cache_test),
|
Case("Flash - clock and cache test", flash_clock_and_cache_test),
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(20, "default_auto");
|
GREENTEA_SETUP(20, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,9 @@ void rtc_sleep_test_support (bool deepsleep_mode)
|
||||||
|
|
||||||
TEST_ASSERT(sleep_manager_can_deep_sleep() == deepsleep_mode);
|
TEST_ASSERT(sleep_manager_can_deep_sleep() == deepsleep_mode);
|
||||||
|
|
||||||
while(!expired) sleep();
|
while (!expired) {
|
||||||
|
sleep();
|
||||||
|
}
|
||||||
|
|
||||||
const uint32_t stop = rtc_read();
|
const uint32_t stop = rtc_read();
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,7 @@ void test_is_leap_year()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Structure to test border values for _rtc_maketime(). */
|
/* Structure to test border values for _rtc_maketime(). */
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
time_t exp_seconds; // if result is false then exp_seconds is irrelevant
|
time_t exp_seconds; // if result is false then exp_seconds is irrelevant
|
||||||
bool result;
|
bool result;
|
||||||
|
|
|
@ -51,8 +51,8 @@ bool is_leap_year(int year)
|
||||||
|
|
||||||
struct tm make_time_info(int year, int month, int day, int hours, int minutes, int seconds)
|
struct tm make_time_info(int year, int month, int day, int hours, int minutes, int seconds)
|
||||||
{
|
{
|
||||||
struct tm timeinfo =
|
struct tm timeinfo = {
|
||||||
{ seconds, // tm_sec
|
seconds, // tm_sec
|
||||||
minutes, // tm_min
|
minutes, // tm_min
|
||||||
hours, // tm_hour
|
hours, // tm_hour
|
||||||
day, // tm_mday
|
day, // tm_mday
|
||||||
|
@ -100,8 +100,7 @@ void test_case_mktime_localtime()
|
||||||
* day 0 - first,
|
* day 0 - first,
|
||||||
* day 1 - last
|
* day 1 - last
|
||||||
* */
|
* */
|
||||||
switch (dayid)
|
switch (dayid) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
day = 1;
|
day = 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -265,8 +265,8 @@ utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Case cases[] =
|
Case cases[] = {
|
||||||
{ Case("sleep - source of wake-up - us ticker", sleep_usticker_test, greentea_failure_handler),
|
Case("sleep - source of wake-up - us ticker", sleep_usticker_test, greentea_failure_handler),
|
||||||
#if DEVICE_LPTICKER
|
#if DEVICE_LPTICKER
|
||||||
Case("deep-sleep - source of wake-up - lp ticker", deepsleep_lpticker_test, greentea_failure_handler),
|
Case("deep-sleep - source of wake-up - lp ticker", deepsleep_lpticker_test, greentea_failure_handler),
|
||||||
Case("deep-sleep - high-speed clocks are turned off", deepsleep_high_speed_clocks_turned_off_test, greentea_failure_handler),
|
Case("deep-sleep - high-speed clocks are turned off", deepsleep_high_speed_clocks_turned_off_test, greentea_failure_handler),
|
||||||
|
|
|
@ -55,6 +55,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Harness::run(specification);
|
Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,8 @@ static void test_over_frequency_and_width(void)
|
||||||
|
|
||||||
static utest::v1::status_t case_setup_handler(
|
static utest::v1::status_t case_setup_handler(
|
||||||
const Case *const source, const size_t index_of_case
|
const Case *const source, const size_t index_of_case
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
utest::v1::status_t status = greentea_case_setup_handler(source, index_of_case);
|
utest::v1::status_t status = greentea_case_setup_handler(source, index_of_case);
|
||||||
reset_ticker_stub();
|
reset_ticker_stub();
|
||||||
return status;
|
return status;
|
||||||
|
@ -188,7 +189,8 @@ static utest::v1::status_t case_setup_handler(
|
||||||
|
|
||||||
static utest::v1::status_t case_teardown_handler(
|
static utest::v1::status_t case_teardown_handler(
|
||||||
const Case *const source, const size_t passed, const size_t failed, const failure_t reason
|
const Case *const source, const size_t passed, const size_t failed, const failure_t reason
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
reset_ticker_stub();
|
reset_ticker_stub();
|
||||||
utest::v1::status_t status = greentea_case_teardown_handler(
|
utest::v1::status_t status = greentea_case_teardown_handler(
|
||||||
source, passed, failed, reason
|
source, passed, failed, reason
|
||||||
|
@ -198,7 +200,8 @@ static utest::v1::status_t case_teardown_handler(
|
||||||
|
|
||||||
static utest::v1::status_t greentea_failure_handler(
|
static utest::v1::status_t greentea_failure_handler(
|
||||||
const Case *const source, const failure_t reason
|
const Case *const source, const failure_t reason
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
utest::v1::status_t status = greentea_case_failure_abort_handler(
|
utest::v1::status_t status = greentea_case_failure_abort_handler(
|
||||||
source, reason
|
source, reason
|
||||||
);
|
);
|
||||||
|
@ -493,7 +496,8 @@ static void test_legacy_insert_event_in_overflow_range()
|
||||||
* timestamp state stored in the queue plus one.
|
* timestamp state stored in the queue plus one.
|
||||||
* - The id of the event should be equal to the id passed in parameter.
|
* - The id of the event should be equal to the id passed in parameter.
|
||||||
*/
|
*/
|
||||||
static void test_legacy_insert_event_overflow(){
|
static void test_legacy_insert_event_overflow()
|
||||||
|
{
|
||||||
ticker_set_handler(&ticker_stub, NULL);
|
ticker_set_handler(&ticker_stub, NULL);
|
||||||
interface_stub.set_interrupt_call = 0;
|
interface_stub.set_interrupt_call = 0;
|
||||||
|
|
||||||
|
@ -1540,7 +1544,8 @@ static void test_overflow_event_update()
|
||||||
{
|
{
|
||||||
static uint32_t handler_call = 0;
|
static uint32_t handler_call = 0;
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
++handler_call;
|
++handler_call;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1582,7 +1587,8 @@ static void test_overflow_event_update_when_spurious_interrupt()
|
||||||
{
|
{
|
||||||
static uint32_t handler_call = 0;
|
static uint32_t handler_call = 0;
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
++handler_call;
|
++handler_call;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1629,7 +1635,8 @@ static void test_irq_handler_single_event()
|
||||||
|
|
||||||
uint32_t handler_call = 0;
|
uint32_t handler_call = 0;
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
++ (*((uint32_t *) id));
|
++ (*((uint32_t *) id));
|
||||||
interface_stub.timestamp = interface_timestamp_after_irq;
|
interface_stub.timestamp = interface_timestamp_after_irq;
|
||||||
}
|
}
|
||||||
|
@ -1672,7 +1679,8 @@ static void test_irq_handler_single_event()
|
||||||
static void test_irq_handler_single_event_spurious()
|
static void test_irq_handler_single_event_spurious()
|
||||||
{
|
{
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
TEST_FAIL();
|
TEST_FAIL();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1733,7 +1741,8 @@ static void test_irq_handler_multiple_event_multiple_dequeue()
|
||||||
|
|
||||||
static size_t handler_called = 0;
|
static size_t handler_called = 0;
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
++handler_called;
|
++handler_called;
|
||||||
ticker_event_t *e = (ticker_event_t *) id;
|
ticker_event_t *e = (ticker_event_t *) id;
|
||||||
if (e->next) {
|
if (e->next) {
|
||||||
|
@ -1793,7 +1802,8 @@ static void test_irq_handler_multiple_event_single_dequeue_overflow()
|
||||||
|
|
||||||
size_t handler_called = 0;
|
size_t handler_called = 0;
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
++ (*((size_t *) id));
|
++ (*((size_t *) id));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1848,7 +1858,8 @@ static void test_irq_handler_multiple_event_single_dequeue()
|
||||||
|
|
||||||
size_t handler_called = 0;
|
size_t handler_called = 0;
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
++ (*((size_t *) id));
|
++ (*((size_t *) id));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1915,7 +1926,8 @@ static void test_irq_handler_insert_immediate_in_irq()
|
||||||
ctrl_block_t ctrl_block = { 0 };
|
ctrl_block_t ctrl_block = { 0 };
|
||||||
|
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
ctrl_block_t *ctrl_block = (ctrl_block_t *) id;
|
ctrl_block_t *ctrl_block = (ctrl_block_t *) id;
|
||||||
|
|
||||||
if (ctrl_block->handler_called == 0) {
|
if (ctrl_block->handler_called == 0) {
|
||||||
|
@ -1991,7 +2003,8 @@ static void test_irq_handler_insert_non_immediate_in_irq()
|
||||||
ctrl_block_t ctrl_block = { 0 };
|
ctrl_block_t ctrl_block = { 0 };
|
||||||
|
|
||||||
struct irq_handler_stub_t {
|
struct irq_handler_stub_t {
|
||||||
static void event_handler(uint32_t id) {
|
static void event_handler(uint32_t id)
|
||||||
|
{
|
||||||
ctrl_block_t *ctrl_block = (ctrl_block_t *) id;
|
ctrl_block_t *ctrl_block = (ctrl_block_t *) id;
|
||||||
|
|
||||||
if (ctrl_block->handler_called == 0) {
|
if (ctrl_block->handler_called == 0) {
|
||||||
|
|
|
@ -39,8 +39,7 @@ public:
|
||||||
ssize_t read;
|
ssize_t read;
|
||||||
_fnCalled = fnRead;
|
_fnCalled = fnRead;
|
||||||
|
|
||||||
for(read = 0; (size_t)read < size; read++)
|
for (read = 0; (size_t)read < size; read++) {
|
||||||
{
|
|
||||||
if (POS_IS_VALID(_pos)) {
|
if (POS_IS_VALID(_pos)) {
|
||||||
((uint8_t *)buffer)[read] = _data[_pos++];
|
((uint8_t *)buffer)[read] = _data[_pos++];
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,8 +54,7 @@ public:
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
_fnCalled = fnWrite;
|
_fnCalled = fnWrite;
|
||||||
|
|
||||||
for(written = 0; (size_t)written < size; written++)
|
for (written = 0; (size_t)written < size; written++) {
|
||||||
{
|
|
||||||
if (NEW_POS_IS_VALID(_pos)) {
|
if (NEW_POS_IS_VALID(_pos)) {
|
||||||
_data[_pos++] = ((uint8_t *)buffer)[written];
|
_data[_pos++] = ((uint8_t *)buffer)[written];
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,8 +75,7 @@ public:
|
||||||
_fnCalled = fnSeek;
|
_fnCalled = fnSeek;
|
||||||
int32_t new_pos = INVALID_POS;
|
int32_t new_pos = INVALID_POS;
|
||||||
|
|
||||||
switch(whence)
|
switch (whence) {
|
||||||
{
|
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
new_pos = offset;
|
new_pos = offset;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,12 +9,15 @@ MBED_PACKED(struct) TestAttrPackedStruct1 {
|
||||||
int x;
|
int x;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef MBED_PACKED(struct) {
|
typedef MBED_PACKED(struct)
|
||||||
|
{
|
||||||
char a;
|
char a;
|
||||||
int x;
|
int x;
|
||||||
} TestAttrPackedStruct2;
|
}
|
||||||
|
TestAttrPackedStruct2;
|
||||||
|
|
||||||
int testPacked() {
|
int testPacked()
|
||||||
|
{
|
||||||
int failed = 0;
|
int failed = 0;
|
||||||
|
|
||||||
if (sizeof(struct TestAttrPackedStruct1) != sizeof(int) + sizeof(char)) {
|
if (sizeof(struct TestAttrPackedStruct1) != sizeof(int) + sizeof(char)) {
|
||||||
|
@ -35,7 +38,8 @@ MBED_ALIGN(16) char c;
|
||||||
MBED_ALIGN(8) char d;
|
MBED_ALIGN(8) char d;
|
||||||
MBED_ALIGN(16) char e;
|
MBED_ALIGN(16) char e;
|
||||||
|
|
||||||
int testAlign() {
|
int testAlign()
|
||||||
|
{
|
||||||
int failed = 0;
|
int failed = 0;
|
||||||
|
|
||||||
if (((uintptr_t)&a) & 0x7) {
|
if (((uintptr_t)&a) & 0x7) {
|
||||||
|
@ -58,11 +62,13 @@ int testAlign() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int testUnused1(MBED_UNUSED int arg) {
|
int testUnused1(MBED_UNUSED int arg)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUnused() {
|
int testUnused()
|
||||||
|
{
|
||||||
return testUnused1(0);
|
return testUnused1(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,42 +76,51 @@ int testUnused() {
|
||||||
int testWeak1();
|
int testWeak1();
|
||||||
int testWeak2();
|
int testWeak2();
|
||||||
|
|
||||||
MBED_WEAK int testWeak1() {
|
MBED_WEAK int testWeak1()
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testWeak2() {
|
int testWeak2()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testWeak() {
|
int testWeak()
|
||||||
|
{
|
||||||
return testWeak1() | testWeak2();
|
return testWeak1() | testWeak2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MBED_PURE int testPure1() {
|
MBED_PURE int testPure1()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testPure() {
|
int testPure()
|
||||||
|
{
|
||||||
return testPure1();
|
return testPure1();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MBED_FORCEINLINE int testForceInline1() {
|
MBED_FORCEINLINE int testForceInline1()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testForceInline() {
|
int testForceInline()
|
||||||
|
{
|
||||||
return testForceInline1();
|
return testForceInline1();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MBED_NORETURN int testNoReturn1() {
|
MBED_NORETURN int testNoReturn1()
|
||||||
|
{
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
int testNoReturn() {
|
int testNoReturn()
|
||||||
|
{
|
||||||
if (0) {
|
if (0) {
|
||||||
testNoReturn1();
|
testNoReturn1();
|
||||||
}
|
}
|
||||||
|
@ -113,7 +128,8 @@ int testNoReturn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int testUnreachable1(int i) {
|
int testUnreachable1(int i)
|
||||||
|
{
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -122,7 +138,8 @@ int testUnreachable1(int i) {
|
||||||
MBED_UNREACHABLE;
|
MBED_UNREACHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testUnreachable() {
|
int testUnreachable()
|
||||||
|
{
|
||||||
return testUnreachable1(0);
|
return testUnreachable1(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +150,8 @@ void testDeprecatedUnused() { }
|
||||||
|
|
||||||
MBED_DEPRECATED("this message should be displayed")
|
MBED_DEPRECATED("this message should be displayed")
|
||||||
int testDeprecatedUsed();
|
int testDeprecatedUsed();
|
||||||
int testDeprecatedUsed() {
|
int testDeprecatedUsed()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,11 +161,13 @@ void testDeprecatedSinceUnused() { }
|
||||||
|
|
||||||
MBED_DEPRECATED_SINCE("mbed-os-3.14", "this message should be displayed")
|
MBED_DEPRECATED_SINCE("mbed-os-3.14", "this message should be displayed")
|
||||||
int testDeprecatedSinceUsed();
|
int testDeprecatedSinceUsed();
|
||||||
int testDeprecatedSinceUsed() {
|
int testDeprecatedSinceUsed()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testDeprecated() {
|
int testDeprecated()
|
||||||
|
{
|
||||||
return testDeprecatedUsed() + testDeprecatedSinceUsed();
|
return testDeprecatedUsed() + testDeprecatedSinceUsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,13 @@ extern "C" {
|
||||||
|
|
||||||
// Test wrapper and test cases for utest
|
// Test wrapper and test cases for utest
|
||||||
template <int (*F)()>
|
template <int (*F)()>
|
||||||
void test_wrapper() {
|
void test_wrapper()
|
||||||
|
{
|
||||||
TEST_ASSERT_UNLESS(F());
|
TEST_ASSERT_UNLESS(F());
|
||||||
}
|
}
|
||||||
|
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(5, "default_auto");
|
GREENTEA_SETUP(5, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +65,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#include "mbed_toolchain.h"
|
#include "mbed_toolchain.h"
|
||||||
|
|
||||||
int testWeak1() {
|
int testWeak1()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MBED_WEAK int testWeak2() {
|
MBED_WEAK int testWeak2()
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,14 @@ namespace {
|
||||||
bool mbed_main_called = false;
|
bool mbed_main_called = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void mbed_main() {
|
extern "C" void mbed_main()
|
||||||
|
{
|
||||||
printf("MBED: mbed_main() call before main()\r\n");
|
printf("MBED: mbed_main() call before main()\r\n");
|
||||||
mbed_main_called = true;
|
mbed_main_called = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
GREENTEA_SETUP(5, "default_auto");
|
GREENTEA_SETUP(5, "default_auto");
|
||||||
printf("MBED: main() starts now!\r\n");
|
printf("MBED: main() starts now!\r\n");
|
||||||
GREENTEA_TESTSUITE_RESULT(mbed_main_called);
|
GREENTEA_TESTSUITE_RESULT(mbed_main_called);
|
||||||
|
|
|
@ -24,33 +24,39 @@ private:
|
||||||
const int pattern;
|
const int pattern;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Test(const char* _name, bool print_message=true) : name(_name), pattern(PATTERN_CHECK_VALUE) {
|
Test(const char *_name, bool print_message = true) : name(_name), pattern(PATTERN_CHECK_VALUE)
|
||||||
|
{
|
||||||
if (print_message) {
|
if (print_message) {
|
||||||
print("init");
|
print("init");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(const char *message) {
|
void print(const char *message)
|
||||||
|
{
|
||||||
printf("%s::%s\n", name, message);
|
printf("%s::%s\n", name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_init(void) {
|
bool check_init(void)
|
||||||
|
{
|
||||||
bool result = (pattern == PATTERN_CHECK_VALUE);
|
bool result = (pattern == PATTERN_CHECK_VALUE);
|
||||||
print(result ? "check_init: OK" : "check_init: ERROR");
|
print(result ? "check_init: OK" : "check_init: ERROR");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void stack_test(void) {
|
void stack_test(void)
|
||||||
|
{
|
||||||
print("stack_test");
|
print("stack_test");
|
||||||
Test t("Stack");
|
Test t("Stack");
|
||||||
t.hello();
|
t.hello();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hello(void) {
|
void hello(void)
|
||||||
|
{
|
||||||
print("hello");
|
print("hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
~Test() {
|
~Test()
|
||||||
|
{
|
||||||
print("destroy");
|
print("destroy");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -70,17 +76,16 @@ Heap::init
|
||||||
Heap::hello
|
Heap::hello
|
||||||
Heap::destroy
|
Heap::destroy
|
||||||
*******************/
|
*******************/
|
||||||
int main (void) {
|
int main(void)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(10, "default_auto");
|
GREENTEA_SETUP(10, "default_auto");
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
for (;;)
|
for (;;) {
|
||||||
{
|
|
||||||
s.print("init");
|
s.print("init");
|
||||||
// Global stack object simple test
|
// Global stack object simple test
|
||||||
s.stack_test();
|
s.stack_test();
|
||||||
if (s.check_init() == false)
|
if (s.check_init() == false) {
|
||||||
{
|
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -89,8 +94,7 @@ int main (void) {
|
||||||
Test *m = new Test("Heap");
|
Test *m = new Test("Heap");
|
||||||
m->hello();
|
m->hello();
|
||||||
|
|
||||||
if (m->check_init() == false)
|
if (m->check_init() == false) {
|
||||||
{
|
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
delete m;
|
delete m;
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "greentea-client/test_env.h"
|
#include "greentea-client/test_env.h"
|
||||||
|
|
||||||
uint32_t test_64(uint64_t ticks) {
|
uint32_t test_64(uint64_t ticks)
|
||||||
|
{
|
||||||
ticks >>= 3; // divide by 8
|
ticks >>= 3; // divide by 8
|
||||||
if (ticks > 0xFFFFFFFF) {
|
if (ticks > 0xFFFFFFFF) {
|
||||||
ticks /= 3;
|
ticks /= 3;
|
||||||
|
@ -27,16 +28,19 @@ uint32_t test_64(uint64_t ticks) {
|
||||||
return (uint32_t)(0xFFFFFFFF & ticks);
|
return (uint32_t)(0xFFFFFFFF & ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *result_str(bool result) {
|
const char *result_str(bool result)
|
||||||
|
{
|
||||||
return result ? "[OK]" : "[FAIL]";
|
return result ? "[OK]" : "[FAIL]";
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
GREENTEA_SETUP(5, "default_auto");
|
GREENTEA_SETUP(5, "default_auto");
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
{ // 0xFFFFFFFF * 8 = 0x7fffffff8
|
{
|
||||||
|
// 0xFFFFFFFF * 8 = 0x7fffffff8
|
||||||
std::pair<uint32_t, uint64_t> values = std::make_pair(0x55555555, 0x7FFFFFFF8);
|
std::pair<uint32_t, uint64_t> values = std::make_pair(0x55555555, 0x7FFFFFFF8);
|
||||||
uint32_t test_ret = test_64(values.second);
|
uint32_t test_ret = test_64(values.second);
|
||||||
bool test_res = values.first == test_ret;
|
bool test_res = values.first == test_ret;
|
||||||
|
@ -44,7 +48,8 @@ int main() {
|
||||||
printf("64bit: 0x7FFFFFFF8: expected 0x%lX got 0x%lX ... %s\r\n", values.first, test_ret, result_str(test_res));
|
printf("64bit: 0x7FFFFFFF8: expected 0x%lX got 0x%lX ... %s\r\n", values.first, test_ret, result_str(test_res));
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // 0xFFFFFFFF * 24 = 0x17ffffffe8
|
{
|
||||||
|
// 0xFFFFFFFF * 24 = 0x17ffffffe8
|
||||||
std::pair<uint32_t, uint64_t> values = std::make_pair(0xFFFFFFFF, 0x17FFFFFFE8);
|
std::pair<uint32_t, uint64_t> values = std::make_pair(0xFFFFFFFF, 0x17FFFFFFE8);
|
||||||
uint32_t test_ret = test_64(values.second);
|
uint32_t test_ret = test_64(values.second);
|
||||||
bool test_res = values.first == test_ret;
|
bool test_res = values.first == test_ret;
|
||||||
|
|
|
@ -25,7 +25,8 @@ using namespace utest::v1;
|
||||||
|
|
||||||
void no_test() {}
|
void no_test() {}
|
||||||
|
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(5, "default_auto");
|
GREENTEA_SETUP(5, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +37,7 @@ Case cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@ struct test {
|
||||||
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
|
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
|
||||||
"Static assertions should not change the size of a struct");
|
"Static assertions should not change the size of a struct");
|
||||||
|
|
||||||
void doit_c(void) {
|
void doit_c(void)
|
||||||
|
{
|
||||||
// Test for static asserts in function context
|
// Test for static asserts in function context
|
||||||
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
|
|
|
@ -34,7 +34,8 @@ struct test {
|
||||||
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
|
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
|
||||||
"Static assertions should not change the size of a struct");
|
"Static assertions should not change the size of a struct");
|
||||||
|
|
||||||
void doit_c(void) {
|
void doit_c(void)
|
||||||
|
{
|
||||||
// Test for static asserts in function context
|
// Test for static asserts in function context
|
||||||
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
|
||||||
"An int must be larger than char");
|
"An int must be larger than char");
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
/* Structure for complex type. */
|
/* Structure for complex type. */
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
int a;
|
int a;
|
||||||
char b;
|
char b;
|
||||||
int c;
|
int c;
|
||||||
|
|
|
@ -21,14 +21,12 @@
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
/* Enum used to select block allocation method. */
|
/* Enum used to select block allocation method. */
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
ALLOC, CALLOC
|
ALLOC, CALLOC
|
||||||
} AllocType;
|
} AllocType;
|
||||||
|
|
||||||
/* Structure for complex block type. */
|
/* Structure for complex block type. */
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
int a;
|
int a;
|
||||||
char b;
|
char b;
|
||||||
int c;
|
int c;
|
||||||
|
|
|
@ -56,7 +56,8 @@ Semaphore sync_sem(0, 1);
|
||||||
* which aborts test program.
|
* which aborts test program.
|
||||||
*/
|
*/
|
||||||
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
|
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
|
||||||
void error(const char* format, ...) {
|
void error(const char *format, ...)
|
||||||
|
{
|
||||||
(void) format;
|
(void) format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,8 @@ struct Sync {
|
||||||
* which aborts test program.
|
* which aborts test program.
|
||||||
*/
|
*/
|
||||||
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
|
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
|
||||||
void error(const char* format, ...) {
|
void error(const char *format, ...)
|
||||||
|
{
|
||||||
(void) format;
|
(void) format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,14 +31,16 @@ public:
|
||||||
* Construct a LockGuard instance and ackire ownership of mutex in input.
|
* Construct a LockGuard instance and ackire ownership of mutex in input.
|
||||||
* @param mutex The mutex to ackire ownership of.
|
* @param mutex The mutex to ackire ownership of.
|
||||||
*/
|
*/
|
||||||
LockGuard(rtos::Mutex& mutex) : _mutex(mutex) {
|
LockGuard(rtos::Mutex &mutex) : _mutex(mutex)
|
||||||
|
{
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destruct the lock and release the inner mutex.
|
* Destruct the lock and release the inner mutex.
|
||||||
*/
|
*/
|
||||||
~LockGuard() {
|
~LockGuard()
|
||||||
|
{
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,37 +31,43 @@ public:
|
||||||
SynchronizedIntegral(T value) : _mutex(), _value(value) { }
|
SynchronizedIntegral(T value) : _mutex(), _value(value) { }
|
||||||
|
|
||||||
// preincrement operator
|
// preincrement operator
|
||||||
T operator++() {
|
T operator++()
|
||||||
|
{
|
||||||
LockGuard lock(_mutex);
|
LockGuard lock(_mutex);
|
||||||
return ++_value;
|
return ++_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// predecrement operator
|
// predecrement operator
|
||||||
T operator--() {
|
T operator--()
|
||||||
|
{
|
||||||
LockGuard lock(_mutex);
|
LockGuard lock(_mutex);
|
||||||
return --_value;
|
return --_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// post increment operator
|
// post increment operator
|
||||||
T operator++(int) {
|
T operator++(int)
|
||||||
|
{
|
||||||
LockGuard lock(_mutex);
|
LockGuard lock(_mutex);
|
||||||
return _value++;
|
return _value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// post decrement operator
|
// post decrement operator
|
||||||
T operator--(int) {
|
T operator--(int)
|
||||||
|
{
|
||||||
LockGuard lock(_mutex);
|
LockGuard lock(_mutex);
|
||||||
return _value--;
|
return _value--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// conversion operator, used also for <,>,<=,>=,== and !=
|
// conversion operator, used also for <,>,<=,>=,== and !=
|
||||||
operator T() const {
|
operator T() const
|
||||||
|
{
|
||||||
LockGuard lock(_mutex);
|
LockGuard lock(_mutex);
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// access to the internal mutex
|
// access to the internal mutex
|
||||||
rtos::Mutex& internal_mutex() {
|
rtos::Mutex &internal_mutex()
|
||||||
|
{
|
||||||
return _mutex;
|
return _mutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,28 +52,33 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tasks with different functions to test on threads
|
// Tasks with different functions to test on threads
|
||||||
void increment(counter_t* counter) {
|
void increment(counter_t *counter)
|
||||||
|
{
|
||||||
(*counter)++;
|
(*counter)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment_with_yield(counter_t* counter) {
|
void increment_with_yield(counter_t *counter)
|
||||||
|
{
|
||||||
Thread::yield();
|
Thread::yield();
|
||||||
(*counter)++;
|
(*counter)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment_with_wait(counter_t* counter) {
|
void increment_with_wait(counter_t *counter)
|
||||||
|
{
|
||||||
Thread::wait(100);
|
Thread::wait(100);
|
||||||
(*counter)++;
|
(*counter)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment_with_child(counter_t* counter) {
|
void increment_with_child(counter_t *counter)
|
||||||
|
{
|
||||||
Thread *child = new Thread(osPriorityNormal, CHILD_THREAD_STACK_SIZE);
|
Thread *child = new Thread(osPriorityNormal, CHILD_THREAD_STACK_SIZE);
|
||||||
child->start(callback(increment, counter));
|
child->start(callback(increment, counter));
|
||||||
child->join();
|
child->join();
|
||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment_with_murder(counter_t* counter) {
|
void increment_with_murder(counter_t *counter)
|
||||||
|
{
|
||||||
{
|
{
|
||||||
// take ownership of the counter mutex so it prevent the child to
|
// take ownership of the counter mutex so it prevent the child to
|
||||||
// modify counter.
|
// modify counter.
|
||||||
|
@ -87,7 +92,8 @@ void increment_with_murder(counter_t* counter) {
|
||||||
(*counter)++;
|
(*counter)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void self_terminate(Thread *self) {
|
void self_terminate(Thread *self)
|
||||||
|
{
|
||||||
self->terminate();
|
self->terminate();
|
||||||
// Code should not get here
|
// Code should not get here
|
||||||
TEST_ASSERT(0);
|
TEST_ASSERT(0);
|
||||||
|
@ -126,7 +132,8 @@ void self_terminate(Thread *self) {
|
||||||
then the final value of the counter is equal to 1
|
then the final value of the counter is equal to 1
|
||||||
*/
|
*/
|
||||||
template <void (*F)(counter_t *)>
|
template <void (*F)(counter_t *)>
|
||||||
void test_single_thread() {
|
void test_single_thread()
|
||||||
|
{
|
||||||
counter_t counter(0);
|
counter_t counter(0);
|
||||||
Thread thread(osPriorityNormal, THREAD_STACK_SIZE);
|
Thread thread(osPriorityNormal, THREAD_STACK_SIZE);
|
||||||
thread.start(callback(F, &counter));
|
thread.start(callback(F, &counter));
|
||||||
|
@ -165,7 +172,8 @@ void test_single_thread() {
|
||||||
then the final value of the counter is equal to number of parallel threads
|
then the final value of the counter is equal to number of parallel threads
|
||||||
*/
|
*/
|
||||||
template <int N, void (*F)(counter_t *)>
|
template <int N, void (*F)(counter_t *)>
|
||||||
void test_parallel_threads() {
|
void test_parallel_threads()
|
||||||
|
{
|
||||||
counter_t counter(0);
|
counter_t counter(0);
|
||||||
ParallelThread<osPriorityNormal, PARALLEL_THREAD_STACK_SIZE> threads[N];
|
ParallelThread<osPriorityNormal, PARALLEL_THREAD_STACK_SIZE> threads[N];
|
||||||
|
|
||||||
|
@ -211,7 +219,8 @@ void test_parallel_threads() {
|
||||||
then the final value of the counter is equal to number of serial threads
|
then the final value of the counter is equal to number of serial threads
|
||||||
*/
|
*/
|
||||||
template <int N, void (*F)(counter_t *)>
|
template <int N, void (*F)(counter_t *)>
|
||||||
void test_serial_threads() {
|
void test_serial_threads()
|
||||||
|
{
|
||||||
counter_t counter(0);
|
counter_t counter(0);
|
||||||
|
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
|
@ -229,7 +238,8 @@ void test_serial_threads() {
|
||||||
when the thread calls @a terminate on its self
|
when the thread calls @a terminate on its self
|
||||||
then the thread terminates execution cleanly
|
then the thread terminates execution cleanly
|
||||||
*/
|
*/
|
||||||
void test_self_terminate() {
|
void test_self_terminate()
|
||||||
|
{
|
||||||
Thread *thread = new Thread(osPriorityNormal, THREAD_STACK_SIZE);
|
Thread *thread = new Thread(osPriorityNormal, THREAD_STACK_SIZE);
|
||||||
thread->start(callback(self_terminate, thread));
|
thread->start(callback(self_terminate, thread));
|
||||||
thread->join();
|
thread->join();
|
||||||
|
@ -336,11 +346,13 @@ void test_thread_signal_clr()
|
||||||
t_wait.join();
|
t_wait.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void thread_wait_signal() {
|
void thread_wait_signal()
|
||||||
|
{
|
||||||
Thread::signal_wait(0x1);
|
Thread::signal_wait(0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void stack_info() {
|
void stack_info()
|
||||||
|
{
|
||||||
Thread::signal_wait(0x1);
|
Thread::signal_wait(0x1);
|
||||||
|
|
||||||
thread_wait_signal();
|
thread_wait_signal();
|
||||||
|
@ -360,7 +372,8 @@ void stack_info() {
|
||||||
and the reported stack size is as requested in the constructor
|
and the reported stack size is as requested in the constructor
|
||||||
and the sum of free and used stack sizes is equal to the total stack size
|
and the sum of free and used stack sizes is equal to the total stack size
|
||||||
*/
|
*/
|
||||||
void test_thread_stack_info() {
|
void test_thread_stack_info()
|
||||||
|
{
|
||||||
Thread t(osPriorityNormal, THREAD_STACK_SIZE);
|
Thread t(osPriorityNormal, THREAD_STACK_SIZE);
|
||||||
t.start(callback(stack_info));
|
t.start(callback(stack_info));
|
||||||
|
|
||||||
|
@ -394,7 +407,8 @@ void test_thread_stack_info() {
|
||||||
when the @a wait function is called
|
when the @a wait function is called
|
||||||
then the thread sleeps for given amount of time
|
then the thread sleeps for given amount of time
|
||||||
*/
|
*/
|
||||||
void test_thread_wait() {
|
void test_thread_wait()
|
||||||
|
{
|
||||||
Timer timer;
|
Timer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
|
@ -409,7 +423,8 @@ void test_thread_wait() {
|
||||||
when the name is queried using @a get_name
|
when the name is queried using @a get_name
|
||||||
then the returned name is as set
|
then the returned name is as set
|
||||||
*/
|
*/
|
||||||
void test_thread_name() {
|
void test_thread_name()
|
||||||
|
{
|
||||||
const char tname[] = "Amazing thread";
|
const char tname[] = "Amazing thread";
|
||||||
Thread t(osPriorityNormal, THREAD_STACK_SIZE, NULL, tname);
|
Thread t(osPriorityNormal, THREAD_STACK_SIZE, NULL, tname);
|
||||||
t.start(callback(thread_wait_signal));
|
t.start(callback(thread_wait_signal));
|
||||||
|
@ -627,7 +642,8 @@ void test_msg_put()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Utility function that places some date on the stack */
|
/** Utility function that places some date on the stack */
|
||||||
void use_some_stack () {
|
void use_some_stack()
|
||||||
|
{
|
||||||
volatile uint32_t stack_filler[10] = {0xDEADBEEF};
|
volatile uint32_t stack_filler[10] = {0xDEADBEEF};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +653,8 @@ void use_some_stack () {
|
||||||
when the thread executes
|
when the thread executes
|
||||||
then the supplies buffer is used as a stack
|
then the supplies buffer is used as a stack
|
||||||
*/
|
*/
|
||||||
void test_thread_ext_stack() {
|
void test_thread_ext_stack()
|
||||||
|
{
|
||||||
char stack[512];
|
char stack[512];
|
||||||
Thread t(osPriorityNormal, sizeof(stack), (unsigned char *)stack);
|
Thread t(osPriorityNormal, sizeof(stack), (unsigned char *)stack);
|
||||||
|
|
||||||
|
@ -647,9 +664,10 @@ void test_thread_ext_stack() {
|
||||||
|
|
||||||
/* If buffer was used as a stack it was cleared with pattern and some data were placed in it */
|
/* If buffer was used as a stack it was cleared with pattern and some data were placed in it */
|
||||||
for (unsigned i = 0; i < sizeof(stack); i++) {
|
for (unsigned i = 0; i < sizeof(stack); i++) {
|
||||||
if (stack[i] != 0)
|
if (stack[i] != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_FAIL_MESSAGE("External stack was not used.");
|
TEST_FAIL_MESSAGE("External stack was not used.");
|
||||||
}
|
}
|
||||||
|
@ -660,7 +678,8 @@ void test_thread_ext_stack() {
|
||||||
when new priority is set using @a set_priority
|
when new priority is set using @a set_priority
|
||||||
then priority is changed and can be retrieved using @a get_priority
|
then priority is changed and can be retrieved using @a get_priority
|
||||||
*/
|
*/
|
||||||
void test_thread_prio() {
|
void test_thread_prio()
|
||||||
|
{
|
||||||
Thread t(osPriorityNormal, THREAD_STACK_SIZE);
|
Thread t(osPriorityNormal, THREAD_STACK_SIZE);
|
||||||
t.start(callback(thread_wait_signal));
|
t.start(callback(thread_wait_signal));
|
||||||
|
|
||||||
|
@ -674,7 +693,8 @@ void test_thread_prio() {
|
||||||
t.join();
|
t.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(20, "default_auto");
|
GREENTEA_SETUP(20, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -733,6 +753,7 @@ static const case_t cases[] = {
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,16 @@ using namespace utest::v1;
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA256_C)
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
/* Tests several call to mbedtls_sha256_update function that are not modulo 64 bytes */
|
/* Tests several call to mbedtls_sha256_update function that are not modulo 64 bytes */
|
||||||
void test_case_sha256_split() {
|
void test_case_sha256_split()
|
||||||
|
{
|
||||||
const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
|
const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
|
||||||
// sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
// sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
||||||
const unsigned char test_sum[] =
|
const unsigned char test_sum[] = {
|
||||||
{ 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22,
|
0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22,
|
||||||
0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93,
|
0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93,
|
||||||
0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0,
|
0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0,
|
||||||
0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C};
|
0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C
|
||||||
|
};
|
||||||
unsigned char outsum[32];
|
unsigned char outsum[32];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -63,7 +65,9 @@ void test_case_sha256_split() {
|
||||||
mbedtls_sha256_free(&ctx);
|
mbedtls_sha256_free(&ctx);
|
||||||
|
|
||||||
printf("\nreceived result : ");
|
printf("\nreceived result : ");
|
||||||
for (i=0;i<32;i++) { printf("%02X",outsum[i]);}
|
for (i = 0; i < 32; i++) {
|
||||||
|
printf("%02X", outsum[i]);
|
||||||
|
}
|
||||||
printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
||||||
|
|
||||||
printf("\nend of test sha256\n");
|
printf("\nend of test sha256\n");
|
||||||
|
@ -71,28 +75,32 @@ void test_case_sha256_split() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tests that treating 2 sha256 objects in // does not impact the result */
|
/* Tests that treating 2 sha256 objects in // does not impact the result */
|
||||||
void test_case_sha256_multi() {
|
void test_case_sha256_multi()
|
||||||
|
{
|
||||||
const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
|
const unsigned char test_buf[] = {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"};
|
||||||
const unsigned char test_buf2[] = {"abcdefghijklmnopqrstuvwxyz012345678901234567890123456789"};
|
const unsigned char test_buf2[] = {"abcdefghijklmnopqrstuvwxyz012345678901234567890123456789"};
|
||||||
|
|
||||||
// sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
// sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
||||||
const unsigned char test_sum1[] =
|
const unsigned char test_sum1[] = {
|
||||||
{ 0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8,
|
0x24, 0x8D, 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8,
|
||||||
0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39,
|
0xE5, 0xC0, 0x26, 0x93, 0x0C, 0x3E, 0x60, 0x39,
|
||||||
0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67,
|
0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67,
|
||||||
0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 };
|
0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1
|
||||||
|
};
|
||||||
// sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
// sha256_output_values for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
||||||
const unsigned char test_sum2[] =
|
const unsigned char test_sum2[] = {
|
||||||
{ 0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22,
|
0x50, 0xEA, 0x82, 0x5D, 0x96, 0x84, 0xF4, 0x22,
|
||||||
0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93,
|
0x9C, 0xA2, 0x9F, 0x1F, 0xEC, 0x51, 0x15, 0x93,
|
||||||
0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0,
|
0xE2, 0x81, 0xE4, 0x6A, 0x14, 0x0D, 0x81, 0xE0,
|
||||||
0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C};
|
0x00, 0x5F, 0x8F, 0x68, 0x86, 0x69, 0xA0, 0x6C
|
||||||
|
};
|
||||||
// sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdefghijklmnopqrstuvwxyz012345678901234567890123456789
|
// sha256_output_values for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopqabcdefghijklmnopqrstuvwxyz012345678901234567890123456789
|
||||||
const unsigned char test_sum3[] =
|
const unsigned char test_sum3[] = {
|
||||||
{ 0x6D, 0x5D, 0xDB, 0x5F, 0x4A, 0x94, 0xAB, 0x7E,
|
0x6D, 0x5D, 0xDB, 0x5F, 0x4A, 0x94, 0xAB, 0x7E,
|
||||||
0x5C, 0xF7, 0x9A, 0xD8, 0x3F, 0x58, 0xD3, 0x97,
|
0x5C, 0xF7, 0x9A, 0xD8, 0x3F, 0x58, 0xD3, 0x97,
|
||||||
0xFE, 0x79, 0xFB, 0x0D, 0x79, 0xB2, 0x0D, 0x22,
|
0xFE, 0x79, 0xFB, 0x0D, 0x79, 0xB2, 0x0D, 0x22,
|
||||||
0xFF, 0x95, 0x9F, 0x04, 0xA2, 0xE4, 0x6C, 0x68};
|
0xFF, 0x95, 0x9F, 0x04, 0xA2, 0xE4, 0x6C, 0x68
|
||||||
|
};
|
||||||
unsigned char outsum1[32], outsum2[32], outsum3[32];
|
unsigned char outsum1[32], outsum2[32], outsum3[32];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -134,13 +142,19 @@ void test_case_sha256_multi() {
|
||||||
mbedtls_sha256_free(&ctx3);
|
mbedtls_sha256_free(&ctx3);
|
||||||
|
|
||||||
printf("\nreceived result ctx1 : ");
|
printf("\nreceived result ctx1 : ");
|
||||||
for (i=0;i<32;i++) { printf("%02X",outsum1[i]);}
|
for (i = 0; i < 32; i++) {
|
||||||
|
printf("%02X", outsum1[i]);
|
||||||
|
}
|
||||||
printf("\nawaited result : 248D6A61D20638B8E5C026930C3E6039A33CE45964FF216F6ECEDD19DB06C1\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
printf("\nawaited result : 248D6A61D20638B8E5C026930C3E6039A33CE45964FF216F6ECEDD19DB06C1\n"); // for abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
||||||
printf("\nreceived result ctx2 : ");
|
printf("\nreceived result ctx2 : ");
|
||||||
for (i=0;i<32;i++) { printf("%02X",outsum2[i]);}
|
for (i = 0; i < 32; i++) {
|
||||||
|
printf("%02X", outsum2[i]);
|
||||||
|
}
|
||||||
printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
printf("\nawaited result : 50EA825D9684F4229CA29F1FEC511593E281E46A140D81E0005F8F688669A06C\n"); // for 3*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
|
||||||
printf("\nreceived result ctx3 : ");
|
printf("\nreceived result ctx3 : ");
|
||||||
for (i=0;i<32;i++) { printf("%02X",outsum3[i]);}
|
for (i = 0; i < 32; i++) {
|
||||||
|
printf("%02X", outsum3[i]);
|
||||||
|
}
|
||||||
printf("\nawaited result : 6D5DDB5F4A94AB7E5CF79AD83F58D397FE79FB0D79B20D22FF959F04A2E46C68\n"); // for 2*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq+3*0123456789
|
printf("\nawaited result : 6D5DDB5F4A94AB7E5CF79AD83F58D397FE79FB0D79B20D22FF959F04A2E46C68\n"); // for 2*abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq+3*0123456789
|
||||||
printf("\nend of test sha256\n");
|
printf("\nend of test sha256\n");
|
||||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum1, test_sum1, 32);
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(outsum1, test_sum1, 32);
|
||||||
|
@ -149,7 +163,8 @@ void test_case_sha256_multi() {
|
||||||
}
|
}
|
||||||
#endif //MBEDTLS_SHA256_C
|
#endif //MBEDTLS_SHA256_C
|
||||||
|
|
||||||
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
|
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason)
|
||||||
|
{
|
||||||
greentea_case_failure_abort_handler(source, reason);
|
greentea_case_failure_abort_handler(source, reason);
|
||||||
return STATUS_CONTINUE;
|
return STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -161,19 +176,20 @@ Case cases[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
|
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(10, "default_auto");
|
GREENTEA_SETUP(10, "default_auto");
|
||||||
return greentea_test_setup_handler(number_of_cases);
|
return greentea_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#if defined(MBEDTLS_PLATFORM_C)
|
#if defined(MBEDTLS_PLATFORM_C)
|
||||||
mbedtls_platform_context platform_ctx;
|
mbedtls_platform_context platform_ctx;
|
||||||
if((ret = mbedtls_platform_setup(&platform_ctx))!= 0)
|
if ((ret = mbedtls_platform_setup(&platform_ctx)) != 0) {
|
||||||
{
|
|
||||||
mbedtls_printf("Mbed TLS multitest failed! mbedtls_platform_setup returned %d\n", ret);
|
mbedtls_printf("Mbed TLS multitest failed! mbedtls_platform_setup returned %d\n", ret);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,19 +84,20 @@ Case cases[] = {
|
||||||
#endif /* MBEDTLS_SELF_TEST */
|
#endif /* MBEDTLS_SELF_TEST */
|
||||||
};
|
};
|
||||||
|
|
||||||
utest::v1::status_t test_setup(const size_t num_cases) {
|
utest::v1::status_t test_setup(const size_t num_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(120, "default_auto");
|
GREENTEA_SETUP(120, "default_auto");
|
||||||
return verbose_test_setup_handler(num_cases);
|
return verbose_test_setup_handler(num_cases);
|
||||||
}
|
}
|
||||||
|
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#if defined(MBEDTLS_PLATFORM_C)
|
#if defined(MBEDTLS_PLATFORM_C)
|
||||||
mbedtls_platform_context platform_ctx;
|
mbedtls_platform_context platform_ctx;
|
||||||
if((ret = mbedtls_platform_setup(&platform_ctx))!= 0)
|
if ((ret = mbedtls_platform_setup(&platform_ctx)) != 0) {
|
||||||
{
|
|
||||||
mbedtls_printf("Mbed TLS selftest failed! mbedtls_platform_setup returned %d\n", ret);
|
mbedtls_printf("Mbed TLS selftest failed! mbedtls_platform_setup returned %d\n", ret);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
NetworkInterface *net;
|
NetworkInterface *net;
|
||||||
Timer tc_bucket; // Timer to limit a test cases run time
|
Timer tc_bucket; // Timer to limit a test cases run time
|
||||||
}
|
}
|
||||||
|
@ -43,7 +42,8 @@ NetworkInterface* get_interface()
|
||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drop_bad_packets(TCPSocket& sock, int orig_timeout) {
|
void drop_bad_packets(TCPSocket &sock, int orig_timeout)
|
||||||
|
{
|
||||||
nsapi_error_t err;
|
nsapi_error_t err;
|
||||||
sock.set_timeout(0);
|
sock.set_timeout(0);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -55,19 +55,22 @@ void drop_bad_packets(TCPSocket& sock, int orig_timeout) {
|
||||||
sock.set_timeout(orig_timeout);
|
sock.set_timeout(orig_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ifup() {
|
static void _ifup()
|
||||||
|
{
|
||||||
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
|
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
|
||||||
nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT;
|
nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT;
|
||||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
|
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
|
||||||
printf("MBED: TCPClient IP address is '%s'\n", net->get_ip_address());
|
printf("MBED: TCPClient IP address is '%s'\n", net->get_ip_address());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ifdown() {
|
static void _ifdown()
|
||||||
|
{
|
||||||
net->disconnect();
|
net->disconnect();
|
||||||
printf("MBED: ifdown\n");
|
printf("MBED: ifdown\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket& sock) {
|
nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket &sock)
|
||||||
|
{
|
||||||
SocketAddress tcp_addr;
|
SocketAddress tcp_addr;
|
||||||
|
|
||||||
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
|
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
|
||||||
|
@ -81,7 +84,8 @@ nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket& sock) {
|
||||||
return sock.connect(tcp_addr);
|
return sock.connect(tcp_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket& sock) {
|
nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket &sock)
|
||||||
|
{
|
||||||
SocketAddress tcp_addr;
|
SocketAddress tcp_addr;
|
||||||
|
|
||||||
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
|
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
|
||||||
|
|
|
@ -29,8 +29,7 @@ nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket& sock);
|
||||||
*/
|
*/
|
||||||
int split2half_rmng_tcp_test_time(); // [s]
|
int split2half_rmng_tcp_test_time(); // [s]
|
||||||
|
|
||||||
namespace tcp_global
|
namespace tcp_global {
|
||||||
{
|
|
||||||
static const int TESTS_TIMEOUT = 480;
|
static const int TESTS_TIMEOUT = 480;
|
||||||
static const int TCP_OS_STACK_SIZE = 1024;
|
static const int TCP_OS_STACK_SIZE = 1024;
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
|
|
||||||
|
@ -34,7 +33,8 @@ namespace
|
||||||
static const int PKTS = 22;
|
static const int PKTS = 22;
|
||||||
static const int pkt_sizes[PKTS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \
|
static const int pkt_sizes[PKTS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \
|
||||||
100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, \
|
100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, \
|
||||||
1100,1200};
|
1100, 1200
|
||||||
|
};
|
||||||
TCPSocket sock;
|
TCPSocket sock;
|
||||||
Semaphore tx_sem(0, 1);
|
Semaphore tx_sem(0, 1);
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ namespace
|
||||||
int time_allotted;
|
int time_allotted;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
|
|
||||||
|
@ -34,7 +33,8 @@ namespace
|
||||||
static const int BURST_SIZE = 1220;
|
static const int BURST_SIZE = 1220;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,17 +25,18 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsapi_error_t _tcpsocket_connect_to_daytime_srv(TCPSocket& sock) {
|
static nsapi_error_t _tcpsocket_connect_to_daytime_srv(TCPSocket &sock)
|
||||||
|
{
|
||||||
SocketAddress tcp_addr;
|
SocketAddress tcp_addr;
|
||||||
|
|
||||||
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
|
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
typedef struct TCPSocketItem {
|
typedef struct TCPSocketItem {
|
||||||
TCPSocket *sock;
|
TCPSocket *sock;
|
||||||
TCPSocketItem *next;
|
TCPSocketItem *next;
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 20000; //[ms]
|
static const int SIGIO_TIMEOUT = 20000; //[ms]
|
||||||
}
|
}
|
||||||
|
@ -63,12 +62,13 @@ static nsapi_error_t _tcpsocket_connect_to_chargen_srv(TCPSocket& sock)
|
||||||
static void generate_RFC_864_pattern(size_t offset, uint8_t *buf, size_t len)
|
static void generate_RFC_864_pattern(size_t offset, uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
while (len--) {
|
while (len--) {
|
||||||
if (offset % 74 == 72)
|
if (offset % 74 == 72) {
|
||||||
*buf++ = '\r';
|
*buf++ = '\r';
|
||||||
else if (offset % 74 == 73)
|
} else if (offset % 74 == 73) {
|
||||||
*buf++ = '\n';
|
*buf++ = '\n';
|
||||||
else
|
} else {
|
||||||
*buf++ = ' ' + (offset % 74 + offset / 74) % 95 ;
|
*buf++ = ' ' + (offset % 74 + offset / 74) % 95 ;
|
||||||
|
}
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,8 @@ static void check_RFC_864_pattern(void *rx_buff, const size_t len, const size_t
|
||||||
TEST_ASSERT(match);
|
TEST_ASSERT(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rcv_n_chk_against_rfc864_pattern(TCPSocket& sock) {
|
void rcv_n_chk_against_rfc864_pattern(TCPSocket &sock)
|
||||||
|
{
|
||||||
static const size_t total_size = 1024 * 100;
|
static const size_t total_size = 1024 * 100;
|
||||||
static const size_t buff_size = 1220;
|
static const size_t buff_size = 1220;
|
||||||
uint8_t buff[buff_size];
|
uint8_t buff[buff_size];
|
||||||
|
@ -154,7 +155,8 @@ void rcv_n_chk_against_rfc864_pattern_nonblock(TCPSocket& sock)
|
||||||
printf("MBED: Time taken: %fs\n", timer.read());
|
printf("MBED: Time taken: %fs\n", timer.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO1 = 0x1;
|
static const int SIGNAL_SIGIO1 = 0x1;
|
||||||
static const int SIGNAL_SIGIO2 = 0x2;
|
static const int SIGNAL_SIGIO2 = 0x2;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
|
@ -35,11 +34,13 @@ namespace
|
||||||
volatile bool running = true;
|
volatile bool running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler1(osThreadId id) {
|
static void _sigio_handler1(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO1);
|
osSignalSet(id, SIGNAL_SIGIO1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler2(osThreadId id) {
|
static void _sigio_handler2(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO2);
|
osSignalSet(id, SIGNAL_SIGIO2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
NetworkInterface *net;
|
NetworkInterface *net;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,19 +38,22 @@ NetworkInterface* get_interface()
|
||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ifup() {
|
static void _ifup()
|
||||||
|
{
|
||||||
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
|
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
|
||||||
nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT;
|
nsapi_error_t err = MBED_CONF_APP_CONNECT_STATEMENT;
|
||||||
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
|
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
|
||||||
printf("MBED: UDPClient IP address is '%s'\n", net->get_ip_address());
|
printf("MBED: UDPClient IP address is '%s'\n", net->get_ip_address());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ifdown() {
|
static void _ifdown()
|
||||||
|
{
|
||||||
net->disconnect();
|
net->disconnect();
|
||||||
printf("MBED: ifdown\n");
|
printf("MBED: ifdown\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void drop_bad_packets(UDPSocket& sock, int orig_timeout) {
|
void drop_bad_packets(UDPSocket &sock, int orig_timeout)
|
||||||
|
{
|
||||||
nsapi_error_t err;
|
nsapi_error_t err;
|
||||||
sock.set_timeout(0);
|
sock.set_timeout(0);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
static const int WAIT2RECV_TIMEOUT = 1000; //[ms]
|
static const int WAIT2RECV_TIMEOUT = 1000; //[ms]
|
||||||
|
@ -45,10 +44,12 @@ namespace
|
||||||
static const int PKTS = 22;
|
static const int PKTS = 22;
|
||||||
static const int pkt_sizes[PKTS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \
|
static const int pkt_sizes[PKTS] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, \
|
||||||
100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, \
|
100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, \
|
||||||
1100,1200};
|
1100, 1200
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
static const int RECV_TIMEOUT = 1; //[s]
|
static const int RECV_TIMEOUT = 1; //[s]
|
||||||
|
@ -47,7 +46,8 @@ namespace
|
||||||
char rx_buffer[500] = {0};
|
char rx_buffer[500] = {0};
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare_tx_buffers() {
|
void prepare_tx_buffers()
|
||||||
|
{
|
||||||
// TX buffers to be preserved for comparison
|
// TX buffers to be preserved for comparison
|
||||||
for (int x = 0; x < BURST_PKTS; x++) {
|
for (int x = 0; x < BURST_PKTS; x++) {
|
||||||
tx_buffers[x].len = PKG_SIZES[x];
|
tx_buffers[x].len = PKG_SIZES[x];
|
||||||
|
@ -57,13 +57,15 @@ void prepare_tx_buffers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_tx_buffers() {
|
void free_tx_buffers()
|
||||||
|
{
|
||||||
for (int x = 0; x < BURST_PKTS; x++) {
|
for (int x = 0; x < BURST_PKTS; x++) {
|
||||||
free(tx_buffers[x].payload);
|
free(tx_buffers[x].payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
typedef struct UDPSocketItem {
|
typedef struct UDPSocketItem {
|
||||||
UDPSocket *sock;
|
UDPSocket *sock;
|
||||||
UDPSocketItem *next;
|
UDPSocketItem *next;
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
|
||||||
static const int SIGNAL_SIGIO = 0x1;
|
static const int SIGNAL_SIGIO = 0x1;
|
||||||
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
static const int SIGIO_TIMEOUT = 5000; //[ms]
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sigio_handler(osThreadId id) {
|
static void _sigio_handler(osThreadId id)
|
||||||
|
{
|
||||||
osSignalSet(id, SIGNAL_SIGIO);
|
osSignalSet(id, SIGNAL_SIGIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -550,7 +550,8 @@ void EmacTestMemoryManager::validate_list() const
|
||||||
m_mem_mutex.unlock();
|
m_mem_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
EmacTestMemoryManager &EmacTestMemoryManager::get_instance() {
|
EmacTestMemoryManager &EmacTestMemoryManager::get_instance()
|
||||||
|
{
|
||||||
static EmacTestMemoryManager test_memory_manager;
|
static EmacTestMemoryManager test_memory_manager;
|
||||||
return test_memory_manager;
|
return test_memory_manager;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
// Test setup
|
// Test setup
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
#if !MBED_CONF_APP_ECHO_SERVER
|
#if !MBED_CONF_APP_ECHO_SERVER
|
||||||
GREENTEA_SETUP(600, "default_auto");
|
GREENTEA_SETUP(600, "default_auto");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
utest::v1::status_t test_setup(const size_t number_of_cases) {
|
utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||||
|
{
|
||||||
GREENTEA_SETUP(240, "default_auto");
|
GREENTEA_SETUP(240, "default_auto");
|
||||||
return verbose_test_setup_handler(number_of_cases);
|
return verbose_test_setup_handler(number_of_cases);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +91,7 @@ Case cases[] = {
|
||||||
Specification specification(test_setup, cases);
|
Specification specification(test_setup, cases);
|
||||||
|
|
||||||
// Entry point into the tests
|
// Entry point into the tests
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return !Harness::run(specification);
|
return !Harness::run(specification);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
using namespace utest::v1;
|
using namespace utest::v1;
|
||||||
|
|
||||||
void wifi_constructor() {
|
void wifi_constructor()
|
||||||
|
{
|
||||||
WiFiInterface *wifi = get_interface();
|
WiFiInterface *wifi = get_interface();
|
||||||
TEST_ASSERT(wifi);
|
TEST_ASSERT(wifi);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue