Skip to content

Commit

Permalink
Make some tweaks to HIL testing. (#127)
Browse files Browse the repository at this point in the history
- Don't put the MD5 server URL in the log output. We want to keep that private.
- Dynamically computed binary store size based on the MCU being used by the
Notecard (i.e. r5 vs. u5).
- Change timeout in waitForNotecardConnected to 5 minutes instead of 300 ms,
which I believe was a mistake.
  • Loading branch information
haydenroche5 authored Dec 21, 2023
1 parent 2d3f0b1 commit 9f39c48
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
1 change: 0 additions & 1 deletion scripts/run_tunnelmole.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ exec 3< tmole.log
read <&3 output
read <&3 output
MD5SRV_URL=`echo "$output" | grep https | cut -d " " -f1`
echo "MD5SRV_URL=$MD5SRV_URL"
[ -n "$MD5SRV_URL" ] || (echo "Could not fetch tunnelmole URL" && exit 1)
echo "MD5SRV_URL=$MD5SRV_URL" >> $GITHUB_ENV
# Only create tmole_ready once MD5SRV_URL has been set, as the next step in the
Expand Down
37 changes: 34 additions & 3 deletions test/hitl/card.binary/test/test_card_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,50 @@ const BinaryTestArgs* currentTestArgs;
RUN_AUX_SERIAL_ALL_BAUDRATES(imagename, image, LARGE_SIZE, LARGE_SIZE_NAME, testArgs, __VA_ARGS__); \
RUN_AUX_SERIAL_ALL_BAUDRATES(imagename, image, MAX_SIZE, MAX_SIZE_NAME, testArgs, __VA_ARGS__);

static const size_t R5_MAX_BINARY_LENGTH = 130554;
static const size_t U5_MAX_BINARY_LENGTH = 261110;

size_t get_expected_max_binary_length()
{
size_t ret = 0;
J* rsp = NoteRequestResponseWithRetry(NoteNewRequest("card.version"), 10);
if (rsp == nullptr) {
notecard.logDebug("No response to card.version.");
} else {
char *target = JGetString(JGetObject(rsp, "body"), "target");
if (target == nullptr) {
notecard.logDebug("Failed to get target from card.version body.");
} else {
if (strcmp(target, "r5") == 0) {
ret = R5_MAX_BINARY_LENGTH;
} else if (strcmp(target, "u5") == 0) {
ret = U5_MAX_BINARY_LENGTH;
} else {
notecard.logDebugf("Unrecognized target: %s.", target);
}
}
}

const size_t EXPECTED_MAX_BINARY_LENGTH = 130554;
JDelete(rsp);

return ret;
}

/**
* @brief Retrieves the maximum card.binary length.
*/
void test_get_max_binary_length()
{
size_t expected_max_binary_length = 0;
assert_initialize_notecard(NOTECARD_IF_I2C);

AssertNoteBinaryReset();

expected_max_binary_length = get_expected_max_binary_length();
if (expected_max_binary_length == 0) {
TEST_FAIL_MESSAGE("Failed to determine max binary length.");
}

J* rsp = NoteRequestResponseWithRetry(NoteNewRequest("card.binary"), 10);
J* max_item = nullptr;
if (rsp==nullptr || !JIsNullString(rsp, "err") || !JIsNumber(max_item=JGetObjectItem(rsp, "max"))) {
Expand All @@ -324,7 +355,7 @@ void test_get_max_binary_length()
TEST_FAIL_MESSAGE("card.binary max is too small.");
}
max_binary_length = length;
TEST_ASSERT_EQUAL(EXPECTED_MAX_BINARY_LENGTH, max_binary_length);
TEST_ASSERT_EQUAL(expected_max_binary_length, max_binary_length);
}
JDelete(rsp);
}
Expand Down Expand Up @@ -396,7 +427,7 @@ TEST(test_max_length_aux_serial)
void waitForNotecardConnected()
{
// TODO: waitForNotecardConnected takes timeout in milliseconds, so 5*60 seems wrong?
TEST_ASSERT_TRUE_MESSAGE(NotecardBinary::waitForNotecardConnected(5*60), "Notecard not connected");
TEST_ASSERT_TRUE_MESSAGE(NotecardBinary::waitForNotecardConnected(NOT_CONNECTED_TIMEOUT), "Notecard not connected");
}

/**
Expand Down

0 comments on commit 9f39c48

Please sign in to comment.