Skip to content

Ticker test fails when run under Greentea on NUCLEO_F070RB #5004

Closed
@maciejbocianski

Description

@maciejbocianski

Below code fails when run under greentea environment
When comiled and run manually (mbed compile -vv -t ARM -m nucleo_f070rb) without greentea works fine

Description

  • Type: Bug
  • Priority: Major

Bug

Target
only NUCLEO_F070RB

Toolchain:
all

Expected behavior
Both counters are equal to 16
Actual behavior
Only first counter is equal to 16 second one (multi_counter2) has random value below 16
Steps to reproduce
paste below code into ticker test and run below code
mbed test -t ARM -m nucleo_f070rb -n tests-mbed_drivers-ticker -vv


Question

Any ideas why below test run under greentea fails?

Fails in line:
// (2) TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter2);

#include "mbed.h"

#define TICKER_COUNT 16
volatile uint32_t multi_counter1;
volatile uint32_t multi_counter2;

void wait_callback_multi1(void)
{
    multi_counter1++;
}

void wait_callback_multi2(void)
{
    multi_counter2++;
}

/** Test many tickers run simultaneously

    Given an 16 tickers
    When schedule them
    Then tickers properly execute callback
 */
void test_multi_ticker(void)
{
    Ticker ticker[TICKER_COUNT];

    multi_counter1 = 0;
    for(int i = 0; i < TICKER_COUNT; i++) {
        ticker[i].attach_us(callback(wait_callback_multi1), 100 * 1000 + i * 15);
    }

    Thread::wait(110);
    for(int i = 0; i < TICKER_COUNT; i++) {
            ticker[i].detach();
    }

    // (1) TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter1);
    printf("(1) expected: %d was: %d\r\n", TICKER_COUNT, multi_counter1);

    multi_counter2 = 0;
    for(int i = 0; i < TICKER_COUNT; i++) {
        ticker[i].attach_us(callback(wait_callback_multi2), 100 * 1000);
    }

    Thread::wait(110);
    for(int i = 0; i < TICKER_COUNT; i++) {
            ticker[i].detach();
    }

    // (2) TEST_ASSERT_EQUAL(TICKER_COUNT, multi_counter2);
    printf("(2) expected: %d was: %d\r\n", TICKER_COUNT, multi_counter2);
}

int main() {
    test_multi_ticker();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions