mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-06-25 17:31:33 +02:00
fix(modem): Added test injecting unexpected replies
This test exhibits an issue of getting unexpected data just after completing a command. The DTE rewrites the state to TIMEOUT, but the signal has been already triggered, thus results in an unexpected state. Related to Closes https://github.com/espressif/esp-protocols/issues/426
This commit is contained in:
@ -33,6 +33,20 @@ TEST_CASE("DTE command races", "[esp_modem]")
|
||||
// this command should either timeout or finish successfully
|
||||
CHECK((ret == command_result::TIMEOUT || ret == command_result::OK));
|
||||
}
|
||||
|
||||
// Now we test the same, but with some garbage after the expected data and inject the reply in chunks by 3 bytes
|
||||
uint8_t resp2[] = {'O', 'K', '\n', '1', '2', '\n'};
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
loopback->inject(&resp2[0], sizeof(resp2), 3, /* 1ms before injecting reply */0, 0);
|
||||
auto ret = dce->command("check\n", [&](uint8_t *data, size_t len) {
|
||||
if (len > 0 && data[0] == 'O') { // expected reply only when it starts with '0'
|
||||
return command_result::OK;
|
||||
}
|
||||
return esp_modem::command_result::TIMEOUT;
|
||||
}, 1);
|
||||
// this command should either timeout or finish successfully
|
||||
CHECK((ret == command_result::TIMEOUT || ret == command_result::OK));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test polymorphic delete for custom device/dte", "[esp_modem]")
|
||||
|
Reference in New Issue
Block a user