Skip to content

Commit

Permalink
test: unity: add 64 bit support
Browse files Browse the repository at this point in the history
Add support for 64 bits macros.

Update tests to use TEST_ASSERT_EQUAL_PTR macro
instead of a simple TEST_ASSERT_EQUAL to avoid build warnings.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
  • Loading branch information
lemrey authored and rlubos committed Jul 18, 2023
1 parent a96c8d0 commit d802f0d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void test_enc_cloud_location_empty(void)
ret = cloud_codec_encode_cloud_location(&codec, &data);

TEST_ASSERT_EQUAL(-ENOTSUP, ret);
TEST_ASSERT_EQUAL(NULL, codec.buf);
TEST_ASSERT_EQUAL_PTR(NULL, codec.buf);
TEST_ASSERT_EQUAL(true, data.queued);
}

Expand All @@ -199,7 +199,7 @@ void test_enc_agps_req(void)
ret = cloud_codec_encode_agps_request(&codec, &data);

TEST_ASSERT_EQUAL(-ENOTSUP, ret);
TEST_ASSERT_EQUAL(NULL, codec.buf);
TEST_ASSERT_EQUAL_PTR(NULL, codec.buf);
TEST_ASSERT_EQUAL(false, data.queued);
}

Expand All @@ -211,7 +211,7 @@ void test_enc_pgps_req(void)
ret = cloud_codec_encode_pgps_request(&codec, &data);

TEST_ASSERT_EQUAL(-ENOTSUP, ret);
TEST_ASSERT_EQUAL(NULL, codec.buf);
TEST_ASSERT_EQUAL_PTR(NULL, codec.buf);
TEST_ASSERT_EQUAL(false, data.queued);
}

Expand Down Expand Up @@ -392,7 +392,7 @@ void test_enc_data_empty(void)
&impact_buf,
&bat_buf);
TEST_ASSERT_EQUAL(-ENOTSUP, ret);
TEST_ASSERT_EQUAL(NULL, codec.buf);
TEST_ASSERT_EQUAL_PTR(NULL, codec.buf);
}

/* tests batch encoding zero-length buffers */
Expand All @@ -417,7 +417,7 @@ void test_enc_batch_data_empty(void)
0, 0, 0, 0, 0, 0, 0);

TEST_ASSERT_EQUAL(-ENODATA, ret);
TEST_ASSERT_EQUAL(NULL, codec.buf);
TEST_ASSERT_EQUAL_PTR(NULL, codec.buf);
}

/* tests batch encoding single-element empty buffers */
Expand All @@ -441,7 +441,7 @@ void test_enc_batch_data_single_empty_element(void)
&bat_buf,
1, 1, 1, 1, 1, 1, 1);
TEST_ASSERT_EQUAL(-ENODATA, ret);
TEST_ASSERT_EQUAL(NULL, codec.buf);
TEST_ASSERT_EQUAL_PTR(NULL, codec.buf);
}

/* tests batch encoding typical battery data */
Expand Down
11 changes: 5 additions & 6 deletions tests/lib/qos/src/qos_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ static uint8_t callback_count;
/* Function used to verify internal context variables. */
static void ctx_verify(struct ctx *expected)
{
TEST_ASSERT_EQUAL(ctx.app_evt_handler,
expected->app_evt_handler);
TEST_ASSERT_EQUAL(ctx.timeout_handler_work.work.handler,
expected->timeout_handler_work.work.handler);
TEST_ASSERT_EQUAL(ctx.pending_list.head, expected->pending_list.head);
TEST_ASSERT_EQUAL(ctx.pending_list.tail, expected->pending_list.tail);
TEST_ASSERT_EQUAL_PTR(ctx.app_evt_handler, expected->app_evt_handler);
TEST_ASSERT_EQUAL_PTR(ctx.timeout_handler_work.work.handler,
expected->timeout_handler_work.work.handler);
TEST_ASSERT_EQUAL_PTR(ctx.pending_list.head, expected->pending_list.head);
TEST_ASSERT_EQUAL_PTR(ctx.pending_list.tail, expected->pending_list.tail);
TEST_ASSERT_EQUAL(ctx.initialized, expected->initialized);
TEST_ASSERT_EQUAL(ctx.message_id_next, expected->message_id_next);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void test_azure_iot_hub_dps_device_id_delete(void)
TEST_ASSERT_EQUAL_MEMORY(az_span_ptr(dps_reg_ctx.assigned_device_id),
TEST_EXPECTED_DEVICE_ID, TEST_EXPECTED_DEVICE_ID_LEN);
TEST_ASSERT_EQUAL(0, azure_iot_hub_dps_device_id_delete());
TEST_ASSERT_EQUAL(NULL, az_span_ptr(dps_reg_ctx.assigned_device_id));
TEST_ASSERT_EQUAL_PTR(NULL, az_span_ptr(dps_reg_ctx.assigned_device_id));
TEST_ASSERT_EQUAL(0, az_span_size(dps_reg_ctx.assigned_device_id));
TEST_ASSERT_EQUAL(AZURE_IOT_HUB_DPS_REG_STATUS_NOT_STARTED, dps_reg_ctx.status);
TEST_ASSERT_EQUAL(DPS_STATE_UNINIT, dps_state);
Expand All @@ -254,8 +254,8 @@ void test_azure_iot_hub_dps_reset_connected(void)
TEST_ASSERT_EQUAL_MEMORY(az_span_ptr(dps_reg_ctx.assigned_device_id),
TEST_EXPECTED_DEVICE_ID, TEST_EXPECTED_DEVICE_ID_LEN);
TEST_ASSERT_EQUAL(0, azure_iot_hub_dps_reset());
TEST_ASSERT_EQUAL(NULL, az_span_ptr(dps_reg_ctx.assigned_hub));
TEST_ASSERT_EQUAL(NULL, az_span_ptr(dps_reg_ctx.assigned_device_id));
TEST_ASSERT_EQUAL_PTR(NULL, az_span_ptr(dps_reg_ctx.assigned_hub));
TEST_ASSERT_EQUAL_PTR(NULL, az_span_ptr(dps_reg_ctx.assigned_device_id));
TEST_ASSERT_EQUAL(0, az_span_size(dps_reg_ctx.assigned_hub));
TEST_ASSERT_EQUAL(0, az_span_size(dps_reg_ctx.assigned_device_id));
TEST_ASSERT_EQUAL(AZURE_IOT_HUB_DPS_REG_STATUS_NOT_STARTED, dps_reg_ctx.status);
Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/net/lib/wifi_credentials/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void verify_ssid_cache_cb(void *cb_arg, const char *ssid, size_t ssid_len)
static const char *const ssids[] = {SSID3, SSID2};

TEST_ASSERT_EQUAL(0, strncmp(ssids[call_count++], ssid, ssid_len));
TEST_ASSERT_EQUAL(NULL, cb_arg);
TEST_ASSERT_EQUAL_PTR(NULL, cb_arg);
}

/* Verify that wifi_credentials behaves correctly when the storage limit is reached. */
Expand Down
10 changes: 5 additions & 5 deletions tests/subsys/net/lib/wifi_credentials_backend_psa/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ void test_add(void)
TEST_ASSERT_EQUAL(0 + CONFIG_WIFI_CREDENTIALS_BACKEND_PSA_UID_OFFSET,
psa_ps_set_fake.arg0_val);
TEST_ASSERT_EQUAL(sizeof(struct wifi_credentials_personal), psa_ps_set_fake.arg1_val);
TEST_ASSERT_EQUAL(&example1, psa_ps_set_fake.arg2_val);
TEST_ASSERT_EQUAL_PTR(&example1, psa_ps_set_fake.arg2_val);
TEST_ASSERT_EQUAL(0, psa_ps_set_fake.arg3_val);

ret = wifi_credentials_store_entry(1, &example2, sizeof(struct wifi_credentials_personal));
TEST_ASSERT_EQUAL(1 + CONFIG_WIFI_CREDENTIALS_BACKEND_PSA_UID_OFFSET,
psa_ps_set_fake.arg0_val);
TEST_ASSERT_EQUAL(sizeof(struct wifi_credentials_personal), psa_ps_set_fake.arg1_val);
TEST_ASSERT_EQUAL(&example2, psa_ps_set_fake.arg2_val);
TEST_ASSERT_EQUAL(0, psa_ps_set_fake.arg3_val);
TEST_ASSERT_EQUAL_PTR(&example2, psa_ps_set_fake.arg2_val);
TEST_ASSERT_EQUAL_PTR(0, psa_ps_set_fake.arg3_val);
TEST_ASSERT_EQUAL(0, ret);

TEST_ASSERT_EQUAL(2, psa_ps_set_fake.call_count);
Expand All @@ -131,7 +131,7 @@ void test_get(void)
psa_ps_get_fake.arg0_val);
TEST_ASSERT_EQUAL(0, psa_ps_get_fake.arg1_val);
TEST_ASSERT_EQUAL(sizeof(struct wifi_credentials_personal), psa_ps_get_fake.arg2_val);
TEST_ASSERT_EQUAL(buf, psa_ps_get_fake.arg3_val);
TEST_ASSERT_EQUAL_PTR(buf, psa_ps_get_fake.arg3_val);

ret = wifi_credentials_load_entry(1, buf, ARRAY_SIZE(buf));

Expand All @@ -140,7 +140,7 @@ void test_get(void)
psa_ps_get_fake.arg0_val);
TEST_ASSERT_EQUAL(0, psa_ps_get_fake.arg1_val);
TEST_ASSERT_EQUAL(sizeof(struct wifi_credentials_personal), psa_ps_get_fake.arg2_val);
TEST_ASSERT_EQUAL(buf, psa_ps_get_fake.arg3_val);
TEST_ASSERT_EQUAL_PTR(buf, psa_ps_get_fake.arg3_val);

TEST_ASSERT_EQUAL(2, psa_ps_get_fake.call_count);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/unity/unity_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#ifndef UNITY_CONFIG_H__
#define UNITY_CONFIG_H__

#ifdef CONFIG_BOARD_NATIVE_POSIX
#define UNITY_SUPPORT_64 1
#endif

#ifndef CONFIG_BOARD_NATIVE_POSIX
#include <stddef.h>
#include <stdio.h>
Expand Down

0 comments on commit d802f0d

Please sign in to comment.