Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ Module.symvers
Mkfile.old
dkms.conf

.variant
16 changes: 16 additions & 0 deletions include/ut_kvp_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ extern "C"
#define UT_KVP_PROFILE_GET_UINT16(key) ut_kvp_getUInt16Field(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_UINT32(key) ut_kvp_getUInt32Field(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_UINT64(key) ut_kvp_getUInt64Field(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_INT8(key) ut_kvp_getInt8Field(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_INT16(key) ut_kvp_getInt16Field(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_INT32(key) ut_kvp_getInt32Field(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_INT64(key) ut_kvp_getInt64Field(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_LIST_COUNT(key) ut_kvp_getListCount(ut_kvp_profile_getInstance(), key)
#define UT_KVP_PROFILE_GET_STRING(key, pszReturnedString ) \
{ \
Expand All @@ -85,6 +89,18 @@ extern "C"
/**! Asserts that a UINT64 KVP field matches the expected value. */
#define UT_ASSERT_KVP_EQUAL_PROFILE_UINT64(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_UINT64(key), checkValue);

/**! Asserts that an INT8 KVP field matches the expected value. */
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT8(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT8(key), checkValue);

/**! Asserts that an INT16 KVP field matches the expected value. */
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT16(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT16(key), checkValue);

/**! Asserts that an INT32 KVP field matches the expected value. */
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT32(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_INT32(key), checkValue);

/**! Asserts that an INT64 KVP field matches the expected value. */
#define UT_ASSERT_KVP_EQUAL_PROFILE_INT64(checkValue, key) UT_ASSERT(UT_KVP_PROFILE_GET_INT64(key) == (checkValue));

/**! Asserts that a KVP list field matches the expected value. */
#define UT_ASSERT_KVP_EQUAL_PROFILE_LIST_COUNT(checkValue, key) UT_ASSERT_EQUAL(UT_KVP_PROFILE_GET_LIST_COUNT(key), checkValue);

Expand Down
10 changes: 9 additions & 1 deletion tests/src/assets/test_kvp.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
720,
800,
1080
]
],
"checkInt8Positive": 120,
"checkInt8Negative": -120,
"checkInt16Positive": 30000,
"checkInt16Negative": -30000,
"checkInt32Positive": 2000000000,
"checkInt32Negative": -2000000000,
"checkInt64Positive": 9000000000000000000,
"checkInt64Negative": -9000000000000000000
}
}
10 changes: 9 additions & 1 deletion tests/src/assets/test_kvp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ decodeTest:
checkUint32List:
- 720
- 800
- 1080
- 1080
checkInt8Positive: 120
checkInt8Negative: -120
checkInt16Positive: 30000
checkInt16Negative: -30000
checkInt32Positive: 2000000000
checkInt32Negative: -2000000000
checkInt64Positive: 9000000000000000000
checkInt64Negative: -9000000000000000000
76 changes: 76 additions & 0 deletions tests/src/c_source/ut_test_kvp_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,74 @@ void test_ut_kvp_profile_list_count(void)
UT_LOG_STEP( "test_ut_kvp_profile_list_count - end" );
}

void test_ut_kvp_profile_int8(void)
{
int8_t checkFieldPositive = 120;
int8_t checkFieldNegative = -120;
int8_t result;
UT_LOG_STEP("test_ut_kvp_profile_int8 - start");
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldPositive, "decodeTest/checkInt8Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldPositive, "decodeTest.checkInt8Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldNegative, "decodeTest/checkInt8Negative" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT8( checkFieldNegative, "decodeTest.checkInt8Negative" );

result = UT_KVP_PROFILE_GET_INT8("decodeTest.checkInt8Positive");
UT_ASSERT_EQUAL(result, checkFieldPositive);

UT_LOG_STEP( "test_ut_kvp_profile_int8 - end" );
}

void test_ut_kvp_profile_int16(void)
{
int16_t checkFieldPositive = 30000;
int16_t checkFieldNegative = -30000;
int16_t result;
UT_LOG_STEP("test_ut_kvp_profile_int16 - start");
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldPositive, "decodeTest/checkInt16Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldPositive, "decodeTest.checkInt16Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldNegative, "decodeTest/checkInt16Negative" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT16( checkFieldNegative, "decodeTest.checkInt16Negative" );

result = UT_KVP_PROFILE_GET_INT16("decodeTest.checkInt16Positive");
UT_ASSERT_EQUAL(result, checkFieldPositive);

UT_LOG_STEP( "test_ut_kvp_profile_int16 - end" );
}

void test_ut_kvp_profile_int32(void)
{
int32_t checkFieldPositive = 2000000000;
int32_t checkFieldNegative = -2000000000;
int32_t result;
UT_LOG_STEP("test_ut_kvp_profile_int32 - start");
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldPositive, "decodeTest/checkInt32Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldPositive, "decodeTest.checkInt32Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldNegative, "decodeTest/checkInt32Negative" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT32( checkFieldNegative, "decodeTest.checkInt32Negative" );

result = UT_KVP_PROFILE_GET_INT32("decodeTest.checkInt32Positive");
UT_ASSERT_EQUAL(result, checkFieldPositive);

UT_LOG_STEP("test_ut_kvp_profile_int32 - end");
}

void test_ut_kvp_profile_int64(void)
{
int64_t checkFieldPositive = 9000000000000000000LL;
int64_t checkFieldNegative = -9000000000000000000LL;
int64_t result;
UT_LOG_STEP("test_ut_kvp_profile_int64 - start");
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldPositive, "decodeTest/checkInt64Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldPositive, "decodeTest.checkInt64Positive" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldNegative, "decodeTest/checkInt64Negative" );
UT_ASSERT_KVP_EQUAL_PROFILE_INT64( checkFieldNegative, "decodeTest.checkInt64Negative" );

result = UT_KVP_PROFILE_GET_INT64("decodeTest.checkInt64Positive");
UT_ASSERT(result == checkFieldPositive);

UT_LOG_STEP("test_ut_kvp_profile_int64 - end");
}

void test_ut_kvp_profile_open( void )
{
UT_LOG_STEP( "test_ut_kvp_profile_open - start" );
Expand Down Expand Up @@ -251,6 +319,10 @@ void register_kvp_profile_testing_functions(void)
UT_add_test(gpAssertSuite2, "kvp profile uint16", test_ut_kvp_profile_uint16);
UT_add_test(gpAssertSuite2, "kvp profile uint32", test_ut_kvp_profile_uint32);
UT_add_test(gpAssertSuite2, "kvp profile uint64", test_ut_kvp_profile_uint64);
UT_add_test(gpAssertSuite2, "kvp profile int8", test_ut_kvp_profile_int8);
UT_add_test(gpAssertSuite2, "kvp profile int16", test_ut_kvp_profile_int16);
UT_add_test(gpAssertSuite2, "kvp profile int32", test_ut_kvp_profile_int32);
UT_add_test(gpAssertSuite2, "kvp profile int64", test_ut_kvp_profile_int64);
UT_add_test(gpAssertSuite2, "kvp profile string", test_ut_kvp_profile_string);
UT_add_test(gpAssertSuite2, "kvp profile bool", test_ut_kvp_profile_bool);
UT_add_test(gpAssertSuite2, "kvp profile list count", test_ut_kvp_profile_list_count);
Expand All @@ -264,6 +336,10 @@ void register_kvp_profile_testing_functions(void)
UT_add_test(gpAssertSuite3, "kvp profile uint16", test_ut_kvp_profile_uint16);
UT_add_test(gpAssertSuite3, "kvp profile uint32", test_ut_kvp_profile_uint32);
UT_add_test(gpAssertSuite3, "kvp profile uint64", test_ut_kvp_profile_uint64);
UT_add_test(gpAssertSuite3, "kvp profile int8", test_ut_kvp_profile_int8);
UT_add_test(gpAssertSuite3, "kvp profile int16", test_ut_kvp_profile_int16);
UT_add_test(gpAssertSuite3, "kvp profile int32", test_ut_kvp_profile_int32);
UT_add_test(gpAssertSuite3, "kvp profile int64", test_ut_kvp_profile_int64);
UT_add_test(gpAssertSuite3, "kvp profile string", test_ut_kvp_profile_string);
UT_add_test(gpAssertSuite3, "kvp profile bool", test_ut_kvp_profile_bool);
UT_add_test(gpAssertSuite3, "kvp profile list count", test_ut_kvp_profile_list_count);
Expand Down
68 changes: 68 additions & 0 deletions tests/src_weak/ut_test_weak_kvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,74 @@ uint64_t __attribute__((weak)) ut_kvp_getUInt64Field(ut_kvp_instance_t *pInstanc
return 0;
}

/**
* @brief Weak implementation of ut_kvp_getInt8Field.
*
* Always returns 0.
*
* @param[in] pInstance - Handle to the KVP instance.
* @param[in] pszKey - Key to search for.
* @returns 0.
*/
int8_t __attribute__((weak)) ut_kvp_getInt8Field(ut_kvp_instance_t *pInstance, const char *pszKey)
{
(void)pInstance;
(void)pszKey;
printf("Weak implementation of [%s]", __func__);
return 0;
}

/**
* @brief Weak implementation of ut_kvp_getInt16Field.
*
* Always returns 0.
*
* @param[in] pInstance - Handle to the KVP instance.
* @param[in] pszKey - Key to search for.
* @returns 0.
*/
int16_t __attribute__((weak)) ut_kvp_getInt16Field(ut_kvp_instance_t *pInstance, const char *pszKey)
{
(void)pInstance;
(void)pszKey;
printf("Weak implementation of [%s]", __func__);
return 0;
}

/**
* @brief Weak implementation of ut_kvp_getInt32Field.
*
* Always returns 0.
*
* @param[in] pInstance - Handle to the KVP instance.
* @param[in] pszKey - Key to search for.
* @returns 0.
*/
int32_t __attribute__((weak)) ut_kvp_getInt32Field(ut_kvp_instance_t *pInstance, const char *pszKey)
{
(void)pInstance;
(void)pszKey;
printf("Weak implementation of [%s]", __func__);
return 0;
}

/**
* @brief Weak implementation of ut_kvp_getInt64Field.
*
* Always returns 0.
*
* @param[in] pInstance - Handle to the KVP instance.
* @param[in] pszKey - Key to search for.
* @returns 0.
*/
int64_t __attribute__((weak)) ut_kvp_getInt64Field(ut_kvp_instance_t *pInstance, const char *pszKey)
{
(void)pInstance;
(void)pszKey;
printf("Weak implementation of [%s]", __func__);
return 0;
}

/**
* @brief Weak implementation of ut_kvp_getStringField.
*
Expand Down
Loading