Skip to content

Commit 2bbc886

Browse files
authored
Merge pull request #238 from rdkcentral/feature/gh236-add-kvp-profile-macros
Add KVP_PROFILE macros for signed integer APIs (int8, int16, int32, int64)
2 parents e343364 + 82a4388 commit 2bbc886

File tree

6 files changed

+179
-2
lines changed

6 files changed

+179
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ Module.symvers
5959
Mkfile.old
6060
dkms.conf
6161

62+
.variant

include/ut_kvp_profile.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ extern "C"
6262
#define UT_KVP_PROFILE_GET_UINT16(key) ut_kvp_getUInt16Field(ut_kvp_profile_getInstance(), key)
6363
#define UT_KVP_PROFILE_GET_UINT32(key) ut_kvp_getUInt32Field(ut_kvp_profile_getInstance(), key)
6464
#define UT_KVP_PROFILE_GET_UINT64(key) ut_kvp_getUInt64Field(ut_kvp_profile_getInstance(), key)
65+
#define UT_KVP_PROFILE_GET_INT8(key) ut_kvp_getInt8Field(ut_kvp_profile_getInstance(), key)
66+
#define UT_KVP_PROFILE_GET_INT16(key) ut_kvp_getInt16Field(ut_kvp_profile_getInstance(), key)
67+
#define UT_KVP_PROFILE_GET_INT32(key) ut_kvp_getInt32Field(ut_kvp_profile_getInstance(), key)
68+
#define UT_KVP_PROFILE_GET_INT64(key) ut_kvp_getInt64Field(ut_kvp_profile_getInstance(), key)
6569
#define UT_KVP_PROFILE_GET_LIST_COUNT(key) ut_kvp_getListCount(ut_kvp_profile_getInstance(), key)
6670
#define UT_KVP_PROFILE_GET_STRING(key, pszReturnedString ) \
6771
{ \
@@ -85,6 +89,18 @@ extern "C"
8589
/**! Asserts that a UINT64 KVP field matches the expected value. */
8690
#define UT_ASSERT_KVP_EQUAL_PROFILE_UINT64(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_UINT64(key), checkValue);
8791

92+
/**! Asserts that an INT8 KVP field matches the expected value. */
93+
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT8(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT8(key), checkValue);
94+
95+
/**! Asserts that an INT16 KVP field matches the expected value. */
96+
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT16(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT16(key), checkValue);
97+
98+
/**! Asserts that an INT32 KVP field matches the expected value. */
99+
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT32(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT32(key), checkValue);
100+
101+
/**! Asserts that an INT64 KVP field matches the expected value. */
102+
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT64(checkValue, key) UT_ASSERT(UT_KVP_PROFILE_GET_INT64(key) == (checkValue));
103+
88104
/**! Asserts that a KVP list field matches the expected value. */
89105
#define UT_ASSERT_KVP_EQUAL_PROFILE_LIST_COUNT(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_LIST_COUNT(key), checkValue);
90106

tests/src/assets/test_kvp.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
720,
2727
800,
2828
1080
29-
]
29+
],
30+
"checkInt8Positive": 120,
31+
"checkInt8Negative": -120,
32+
"checkInt16Positive": 30000,
33+
"checkInt16Negative": -30000,
34+
"checkInt32Positive": 2000000000,
35+
"checkInt32Negative": -2000000000,
36+
"checkInt64Positive": 9000000000000000000,
37+
"checkInt64Negative": -9000000000000000000
3038
}
3139
}

tests/src/assets/test_kvp.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ decodeTest:
2424
checkUint32List:
2525
- 720
2626
- 800
27-
- 1080
27+
- 1080
28+
checkInt8Positive: 120
29+
checkInt8Negative: -120
30+
checkInt16Positive: 30000
31+
checkInt16Negative: -30000
32+
checkInt32Positive: 2000000000
33+
checkInt32Negative: -2000000000
34+
checkInt64Positive: 9000000000000000000
35+
checkInt64Negative: -9000000000000000000

tests/src/c_source/ut_test_kvp_profile.c

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,74 @@ void test_ut_kvp_profile_list_count(void)
165165
UT_LOG_STEP( "test_ut_kvp_profile_list_count - end" );
166166
}
167167

168+
void test_ut_kvp_profile_int8(void)
169+
{
170+
int8_t checkFieldPositive = 120;
171+
int8_t checkFieldNegative = -120;
172+
int8_t result;
173+
UT_LOG_STEP("test_ut_kvp_profile_int8 - start");
174+
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldPositive, "decodeTest/checkInt8Positive" );
175+
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldPositive, "decodeTest.checkInt8Positive" );
176+
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldNegative, "decodeTest/checkInt8Negative" );
177+
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldNegative, "decodeTest.checkInt8Negative" );
178+
179+
result = UT_KVP_PROFILE_GET_INT8("decodeTest.checkInt8Positive");
180+
UT_ASSERT_EQUAL(result, checkFieldPositive);
181+
182+
UT_LOG_STEP( "test_ut_kvp_profile_int8 - end" );
183+
}
184+
185+
void test_ut_kvp_profile_int16(void)
186+
{
187+
int16_t checkFieldPositive = 30000;
188+
int16_t checkFieldNegative = -30000;
189+
int16_t result;
190+
UT_LOG_STEP("test_ut_kvp_profile_int16 - start");
191+
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldPositive, "decodeTest/checkInt16Positive" );
192+
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldPositive, "decodeTest.checkInt16Positive" );
193+
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldNegative, "decodeTest/checkInt16Negative" );
194+
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldNegative, "decodeTest.checkInt16Negative" );
195+
196+
result = UT_KVP_PROFILE_GET_INT16("decodeTest.checkInt16Positive");
197+
UT_ASSERT_EQUAL(result, checkFieldPositive);
198+
199+
UT_LOG_STEP( "test_ut_kvp_profile_int16 - end" );
200+
}
201+
202+
void test_ut_kvp_profile_int32(void)
203+
{
204+
int32_t checkFieldPositive = 2000000000;
205+
int32_t checkFieldNegative = -2000000000;
206+
int32_t result;
207+
UT_LOG_STEP("test_ut_kvp_profile_int32 - start");
208+
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldPositive, "decodeTest/checkInt32Positive" );
209+
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldPositive, "decodeTest.checkInt32Positive" );
210+
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldNegative, "decodeTest/checkInt32Negative" );
211+
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldNegative, "decodeTest.checkInt32Negative" );
212+
213+
result = UT_KVP_PROFILE_GET_INT32("decodeTest.checkInt32Positive");
214+
UT_ASSERT_EQUAL(result, checkFieldPositive);
215+
216+
UT_LOG_STEP("test_ut_kvp_profile_int32 - end");
217+
}
218+
219+
void test_ut_kvp_profile_int64(void)
220+
{
221+
int64_t checkFieldPositive = 9000000000000000000LL;
222+
int64_t checkFieldNegative = -9000000000000000000LL;
223+
int64_t result;
224+
UT_LOG_STEP("test_ut_kvp_profile_int64 - start");
225+
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldPositive, "decodeTest/checkInt64Positive" );
226+
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldPositive, "decodeTest.checkInt64Positive" );
227+
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldNegative, "decodeTest/checkInt64Negative" );
228+
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldNegative, "decodeTest.checkInt64Negative" );
229+
230+
result = UT_KVP_PROFILE_GET_INT64("decodeTest.checkInt64Positive");
231+
UT_ASSERT(result == checkFieldPositive);
232+
233+
UT_LOG_STEP("test_ut_kvp_profile_int64 - end");
234+
}
235+
168236
void test_ut_kvp_profile_open( void )
169237
{
170238
UT_LOG_STEP( "test_ut_kvp_profile_open - start" );
@@ -251,6 +319,10 @@ void register_kvp_profile_testing_functions(void)
251319
UT_add_test(gpAssertSuite2, "kvp profile uint16", test_ut_kvp_profile_uint16);
252320
UT_add_test(gpAssertSuite2, "kvp profile uint32", test_ut_kvp_profile_uint32);
253321
UT_add_test(gpAssertSuite2, "kvp profile uint64", test_ut_kvp_profile_uint64);
322+
UT_add_test(gpAssertSuite2, "kvp profile int8", test_ut_kvp_profile_int8);
323+
UT_add_test(gpAssertSuite2, "kvp profile int16", test_ut_kvp_profile_int16);
324+
UT_add_test(gpAssertSuite2, "kvp profile int32", test_ut_kvp_profile_int32);
325+
UT_add_test(gpAssertSuite2, "kvp profile int64", test_ut_kvp_profile_int64);
254326
UT_add_test(gpAssertSuite2, "kvp profile string", test_ut_kvp_profile_string);
255327
UT_add_test(gpAssertSuite2, "kvp profile bool", test_ut_kvp_profile_bool);
256328
UT_add_test(gpAssertSuite2, "kvp profile list count", test_ut_kvp_profile_list_count);
@@ -264,6 +336,10 @@ void register_kvp_profile_testing_functions(void)
264336
UT_add_test(gpAssertSuite3, "kvp profile uint16", test_ut_kvp_profile_uint16);
265337
UT_add_test(gpAssertSuite3, "kvp profile uint32", test_ut_kvp_profile_uint32);
266338
UT_add_test(gpAssertSuite3, "kvp profile uint64", test_ut_kvp_profile_uint64);
339+
UT_add_test(gpAssertSuite3, "kvp profile int8", test_ut_kvp_profile_int8);
340+
UT_add_test(gpAssertSuite3, "kvp profile int16", test_ut_kvp_profile_int16);
341+
UT_add_test(gpAssertSuite3, "kvp profile int32", test_ut_kvp_profile_int32);
342+
UT_add_test(gpAssertSuite3, "kvp profile int64", test_ut_kvp_profile_int64);
267343
UT_add_test(gpAssertSuite3, "kvp profile string", test_ut_kvp_profile_string);
268344
UT_add_test(gpAssertSuite3, "kvp profile bool", test_ut_kvp_profile_bool);
269345
UT_add_test(gpAssertSuite3, "kvp profile list count", test_ut_kvp_profile_list_count);

tests/src_weak/ut_test_weak_kvp.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,74 @@ uint64_t __attribute__((weak)) ut_kvp_getUInt64Field(ut_kvp_instance_t *pInstanc
174174
return 0;
175175
}
176176

177+
/**
178+
* @brief Weak implementation of ut_kvp_getInt8Field.
179+
*
180+
* Always returns 0.
181+
*
182+
* @param[in] pInstance - Handle to the KVP instance.
183+
* @param[in] pszKey - Key to search for.
184+
* @returns 0.
185+
*/
186+
int8_t __attribute__((weak)) ut_kvp_getInt8Field(ut_kvp_instance_t *pInstance, const char *pszKey)
187+
{
188+
(void)pInstance;
189+
(void)pszKey;
190+
printf("Weak implementation of [%s]", __func__);
191+
return 0;
192+
}
193+
194+
/**
195+
* @brief Weak implementation of ut_kvp_getInt16Field.
196+
*
197+
* Always returns 0.
198+
*
199+
* @param[in] pInstance - Handle to the KVP instance.
200+
* @param[in] pszKey - Key to search for.
201+
* @returns 0.
202+
*/
203+
int16_t __attribute__((weak)) ut_kvp_getInt16Field(ut_kvp_instance_t *pInstance, const char *pszKey)
204+
{
205+
(void)pInstance;
206+
(void)pszKey;
207+
printf("Weak implementation of [%s]", __func__);
208+
return 0;
209+
}
210+
211+
/**
212+
* @brief Weak implementation of ut_kvp_getInt32Field.
213+
*
214+
* Always returns 0.
215+
*
216+
* @param[in] pInstance - Handle to the KVP instance.
217+
* @param[in] pszKey - Key to search for.
218+
* @returns 0.
219+
*/
220+
int32_t __attribute__((weak)) ut_kvp_getInt32Field(ut_kvp_instance_t *pInstance, const char *pszKey)
221+
{
222+
(void)pInstance;
223+
(void)pszKey;
224+
printf("Weak implementation of [%s]", __func__);
225+
return 0;
226+
}
227+
228+
/**
229+
* @brief Weak implementation of ut_kvp_getInt64Field.
230+
*
231+
* Always returns 0.
232+
*
233+
* @param[in] pInstance - Handle to the KVP instance.
234+
* @param[in] pszKey - Key to search for.
235+
* @returns 0.
236+
*/
237+
int64_t __attribute__((weak)) ut_kvp_getInt64Field(ut_kvp_instance_t *pInstance, const char *pszKey)
238+
{
239+
(void)pInstance;
240+
(void)pszKey;
241+
printf("Weak implementation of [%s]", __func__);
242+
return 0;
243+
}
244+
177245
/**
178246
* @brief Weak implementation of ut_kvp_getStringField.
179247
*

0 commit comments

Comments
 (0)