Skip to content

Commit

Permalink
prov/efa: Reset g_efa_hmem_info after each test
Browse files Browse the repository at this point in the history
Several tests directly modify g_efa_hmem_info which is only correctly
set once on the first fi_getinfo call

Signed-off-by: Sai Sunku <sunkusa@amazon.com>
  • Loading branch information
sunkuamzn committed Feb 12, 2025
1 parent cf223a7 commit 1ea1b15
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prov/efa/test/efa_unit_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
#include "efa_unit_tests.h"

struct efa_env orig_efa_env = {0};
struct efa_hmem_info g_efa_hmem_info_backup[OFI_HMEM_MAX];

/* Runs once before all tests */
static int efa_unit_test_mocks_group_setup(void **state)
{
struct efa_resource *resource;
struct fi_info *info;
resource = calloc(1, sizeof(struct efa_resource));
*state = resource;

orig_efa_env = efa_env;

/* run fi_getinfo to populate g_efa_hmem_info and copy it */
fi_getinfo(FI_VERSION(2, 0), NULL, NULL, 0, NULL, &info);
memcpy(g_efa_hmem_info_backup, g_efa_hmem_info, sizeof(g_efa_hmem_info));

return 0;
}

Expand Down Expand Up @@ -41,6 +47,9 @@ static int efa_unit_test_mocks_teardown(void **state)
{
struct efa_resource *resource = *state;

/* Reset the contents of g_efa_hmem_info from backup */
memcpy(g_efa_hmem_info, g_efa_hmem_info_backup, sizeof(g_efa_hmem_info));

efa_unit_test_resource_destruct(resource);

efa_ibv_submitted_wr_id_vec_clear();
Expand Down

0 comments on commit 1ea1b15

Please sign in to comment.