From 8e0c7aa7408802684ff9ddce371159858bae3339 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 6 Jan 2022 14:19:41 +0900 Subject: [PATCH] tests: add explicit typecast on expect_check() This suppresses mismatch of check_expected() due to sign-extended integer of cmocka framework on 32bit architecture. Change-Id: Ief1b52513c4d78a6373aaba7a36c97ed687768d0 Signed-off-by: Youngjae Cho --- .../test-device-notifier.c | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/deviced-common-private-test/test-device-notifier.c b/tests/deviced-common-private-test/test-device-notifier.c index 6f882a6..d049317 100644 --- a/tests/deviced-common-private-test/test-device-notifier.c +++ b/tests/deviced-common-private-test/test-device-notifier.c @@ -43,7 +43,7 @@ static void test_device_notify_p1(void **state) retval = register_notifier(DEVICE_NOTIFIER_LCD, notify_callback); assert_int_equal(retval, 0); - expect_value(notify_callback, data, 0x3f3f3f3f); + expect_value(notify_callback, data, (void *)(intptr_t) 0x3f3f3f3f); device_notify(DEVICE_NOTIFIER_LCD, (void *)(intptr_t) 0x3f3f3f3f); } @@ -66,10 +66,10 @@ static void test_device_notify_p2(void **state) assert_in_range(retval, 1, INT_MAX); /* expect invocation of 1st callback and check parameter */ - expect_value(notify_callback, data, notify_data); + expect_value(notify_callback, data, (void *)(intptr_t) notify_data); /* expect invocation of 2nd callback and check parameter */ - expect_value(notify_callback_udata, data, notify_data); - expect_value(notify_callback_udata, udata, udata2); + expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data); + expect_value(notify_callback_udata, udata,(void *)(intptr_t) udata2); device_notify(DEVICE_NOTIFIER_PMQOS, (void *)(intptr_t) notify_data); @@ -80,13 +80,13 @@ static void test_device_notify_p2(void **state) assert_in_range(retval, 1, INT_MAX); /* expect invocation of 1st callback and check parameter */ - expect_value(notify_callback, data, notify_data); + expect_value(notify_callback, data, (void *)(intptr_t) notify_data); /* expect invocation of 2nd callback and check parameter */ - expect_value(notify_callback_udata, data, notify_data); - expect_value(notify_callback_udata, udata, udata2); + expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata2); /* expect invocation of 3rd callback and check parameter */ - expect_value(notify_callback_udata, data, notify_data); - expect_value(notify_callback_udata, udata, udata3); + expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata3); device_notify(DEVICE_NOTIFIER_PMQOS, (void *)(intptr_t) notify_data); } @@ -110,11 +110,11 @@ static void test_device_notify_p3(void **state) assert_in_range(id2, 1, INT_MAX); /* expect invocation of 1st callback and check parameter */ - expect_value(notify_callback_udata, data, notify_data); - expect_value(notify_callback_udata, udata, udata1); + expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata1); /* expect invocation of 2nd callback and check parameter */ - expect_value(notify_callback_udata, data, notify_data); - expect_value(notify_callback_udata, udata, udata2); + expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata2); device_notify(DEVICE_NOTIFIER_POWEROFF, (void *)(intptr_t) notify_data); @@ -124,8 +124,8 @@ static void test_device_notify_p3(void **state) unregister_notifier_udata(id1); /* only expect invocation of 2nd callback and check parameter */ - expect_value(notify_callback_udata, data, notify_data); - expect_value(notify_callback_udata, udata, udata2); + expect_value(notify_callback_udata, data, (void *)(intptr_t) notify_data); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) udata2); device_notify(DEVICE_NOTIFIER_POWEROFF, (void *)(intptr_t) notify_data); } @@ -137,7 +137,7 @@ static void test_device_notify_once_p(void **state) retval = register_notifier(DEVICE_NOTIFIER_LCD_OFF, notify_callback); assert_int_equal(retval, 0); - expect_value(notify_callback, data, 0xabcdabcd); + expect_value(notify_callback, data, (void *)(intptr_t) 0xabcdabcd); device_notify_once(DEVICE_NOTIFIER_LCD_OFF, (void *)(intptr_t) 0xabcdabcd); /* Don't add expect_value() for callback at this time. @@ -147,8 +147,8 @@ static void test_device_notify_once_p(void **state) retval = register_notifier_udata(DEVICE_NOTIFIER_BATTERY_CHARGING, notify_callback_udata, (void *)(intptr_t) 0xfefefefe, NULL); assert_in_range(retval, 1, INT_MAX); - expect_value(notify_callback_udata, data, 0x34343434); - expect_value(notify_callback_udata, udata, 0xfefefefe); + expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x34343434); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0xfefefefe); device_notify_once(DEVICE_NOTIFIER_BATTERY_CHARGING, (void *)(intptr_t) 0x34343434); /* Don't add expect_value() for callback at this time. @@ -164,7 +164,7 @@ static void test_destroy_callback_p1(void **state) (void *)(intptr_t) 0x4848, destroy_callback_udata); assert_in_range(id, 1, INT_MAX); - expect_value(destroy_callback_udata, udata, 0x4848); + expect_value(destroy_callback_udata, udata, (void *)(intptr_t) 0x4848); unregister_notifier_udata(id); } @@ -177,9 +177,9 @@ static void test_destroy_callback_p2(void **state) (void *)(intptr_t) 0x1177, destroy_callback_udata); assert_in_range(id, 1, INT_MAX); - expect_value(notify_callback_udata, data, 0x9a9a9a9a); - expect_value(notify_callback_udata, udata, 0x1177); - expect_value(destroy_callback_udata, udata, 0x1177); + expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x9a9a9a9a); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x1177); + expect_value(destroy_callback_udata, udata, (void *)(intptr_t) 0x1177); device_notify_once(DEVICE_NOTIFIER_LOWBAT, (void *)(intptr_t) 0x9a9a9a9a); } @@ -201,14 +201,14 @@ static void test_device_notify_priority_p1(void **state) assert_in_range(id3, 1, INT_MAX); /* id2 will be invoked first */ - expect_value(notify_callback_udata, data, 0x1234); - expect_value(notify_callback_udata, udata, 0x22222222); + expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x1234); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x22222222); /* id1, id3 invocation follows it, * and those are invoked in the order in which they were registered */ - expect_value(notify_callback_udata, data, 0x1234); - expect_value(notify_callback_udata, udata, 0x11111111); - expect_value(notify_callback_udata, data, 0x1234); - expect_value(notify_callback_udata, udata, 0x33333333); + expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x1234); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x11111111); + expect_value(notify_callback_udata, data, (void *)(intptr_t) 0x1234); + expect_value(notify_callback_udata, udata, (void *)(intptr_t) 0x33333333); device_notify(DEVICE_NOTIFIER_DISPLAY_LOCK, (void *)(intptr_t)0x1234); } -- 2.7.4