Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIL: adjust OTA test timing #483

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 10 additions & 12 deletions tests/hil/tests/ota/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
LOG_TAG_DEFINE(test_ota);

static golioth_sys_sem_t connected_sem;
static golioth_sys_sem_t reason_test_sem;
static golioth_sys_sem_t block_test_sem;

#define GOLIOTH_OTA_REASON_CNT 10
#define GOLIOTH_OTA_STATE_CNT 4
Expand All @@ -24,8 +26,6 @@ static golioth_sys_sem_t connected_sem;
#define DUMMY_VER_EXTRA "1.2.5"

static uint8_t callback_arg = 17;
static bool reason_test_pending = false;
static bool block_test_pending = false;
static uint8_t block_buf[GOLIOTH_OTA_BLOCKSIZE];

struct golioth_client *client;
Expand Down Expand Up @@ -95,7 +95,7 @@ static void test_reason_and_state(void)
{
GLTH_LOGE(TAG, "Unable to report ota state: %d", status);
}
golioth_sys_msleep(5000);
golioth_sys_msleep(7000);
}

GLTH_LOGI(TAG, "golioth_ota_get_state: %d", golioth_ota_get_state());
Expand Down Expand Up @@ -215,13 +215,11 @@ static void on_manifest(struct golioth_client *client,
}
else if (strcmp(main->version, DUMMY_VER_SAME) == 0)
{
// Use trigger to avoid deadlock
block_test_pending = true;
golioth_sys_sem_give(block_test_sem);
}
else if (strcmp(main->version, DUMMY_VER_UPDATE) == 0)
{
// Use trigger to avoid deadlock
reason_test_pending = true;
golioth_sys_sem_give(reason_test_sem);
}
}
}
Expand All @@ -239,6 +237,8 @@ static void on_client_event(struct golioth_client *client,
void hil_test_entry(const struct golioth_client_config *config)
{
connected_sem = golioth_sys_sem_create(1, 0);
reason_test_sem = golioth_sys_sem_create(1, 0);
block_test_sem = golioth_sys_sem_create(1, 0);

golioth_debug_set_cloud_log_enabled(false);

Expand All @@ -251,17 +251,15 @@ void hil_test_entry(const struct golioth_client_config *config)

while (1)
{
if (reason_test_pending)
if (golioth_sys_sem_take(reason_test_sem, 0))
{
reason_test_pending = false;
test_reason_and_state();
}
else if (block_test_pending)
if (golioth_sys_sem_take(block_test_sem, 0))
{
block_test_pending = false;
test_block_ops();
}

golioth_sys_msleep(1000);
golioth_sys_msleep(100);
}
}
4 changes: 2 additions & 2 deletions tests/hil/tests/ota/test_ota.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ async def test_reason_and_state(board, device, project, releases):
# Test reason and state code updates

for i, r in enumerate(golioth_ota_reason):
board.wait_for_regex_in_line("Updating status", timeout_s=12)
time.sleep(1.5) # Wait for server to propagate
board.wait_for_regex_in_line("Updating status", timeout_s=20)
time.sleep(3) # Wait for server to propagate

await device.refresh()

Expand Down