Skip to content

Commit

Permalink
TODO Fixup serial test
Browse files Browse the repository at this point in the history
  • Loading branch information
jrvollmer committed Nov 8, 2023
1 parent 3a157fe commit 10e0614
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
21 changes: 19 additions & 2 deletions tests/serialTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@ class SerialTest : public Test {
SerialTest(): Test("serial_basic") {};
private:
bool runTest() {
// Simply pass, as signalStart() and signalEnd() will indicate success or failure
return true;
char buff[25];
// Print multiple messages to the BTF and have the BTF repeat a specific one
// Tests readAll() in BTF
printf("Testing serial communication\n");
printf("Repeat this message\n");
printf("Don't repeat this message\n");
// Wait for BTF timeout to expire
ThisThread::sleep_for(1000ms);
// Read and verify response from BTF test runner
size_t nread = pc.readLine(buff, sizeof(buff));
bool result = strcmp(buff, "Repeat this message") == 0;

// Print a message with a delimiter (STOP)
// Tests readUntil() in BTF
printf("Should only read thisSTOPNot this\n");
// Read and verify response from BTF test runner
nread = pc.readLine(buff, sizeof(buff));

return result && strcmp(buff, "Should only read this") == 0;
}
};

Expand Down
8 changes: 6 additions & 2 deletions tests/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ class Test {
printf("START TEST %s\n", testName.c_str());

// Read response from BTF test runner
size_t nread = pc.readLine(buff, sizeof(buff));
// Give it a generouss 30 seconds to ensure timeout
// is not an issue during normal operation
size_t nread = pc.readLine(buff, sizeof(buff), 30000);

// Set result code
if(nread <= 0) {
Expand All @@ -95,7 +97,9 @@ class Test {
printf("%s\n", r->pass ? "PASS" : "FAIL");

// Read response from BTF test runner
size_t nread = pc.readLine(buff, sizeof(buff));
// Give it a generouss 30 seconds to ensure timeout
// is not an issue during normal operation
size_t nread = pc.readLine(buff, sizeof(buff), 30000);

// Set result code
if(nread <= 0) {
Expand Down

0 comments on commit 10e0614

Please sign in to comment.