Issue 187 enable skipped ztest suites (#189)
* Fix some ztests that were skipped * Expose bacapp_same_value() * Fix bacapp, ptransfer tests * Fix bugs in Load_Control object & tests * refactor days functions from datetime module * fix legacy ctests * Add bacnet/basic/sys/days.[ch] to Zephyr build * Update ztest to match from Zephyr v2.6.0; update ringbuf, datetime to build * Fixup ztest test for object/acc * Fix bvlc_address_from_ascii; enable/fix bvlc test * Comment cleanup * test/bacnet/basic/object/lc partially enabled * Fix bacapp_decode_data_len return status on erroneous input * fix ztest include fatal error * fix ztest strsignal reference fatal error * fix zassert_mem_equal reference syntax error * fix zassert_mem_equal reference syntax error Co-authored-by: Gregory Shue <gregory.shue@legrand.us> Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
* @brief Ztest mocking support
|
||||
*/
|
||||
|
||||
#ifndef __ZTEST_MOCK_H__
|
||||
#define __ZTEST_MOCK_H__
|
||||
#ifndef ZEPHYR_TESTSUITE_ZTEST_MOCK_H_
|
||||
#define ZEPHYR_TESTSUITE_ZTEST_MOCK_H_
|
||||
|
||||
/**
|
||||
* @defgroup ztest_mock Ztest mocking support
|
||||
@@ -33,9 +33,9 @@
|
||||
* @param param Parameter for which the value should be set
|
||||
* @param value Value for @a param
|
||||
*/
|
||||
#define ztest_expect_value(func, param, value) \
|
||||
z_ztest_expect_value(STRINGIFY(func), STRINGIFY(param), \
|
||||
(uintptr_t)(value))
|
||||
#define ztest_expect_value(func, param, value) \
|
||||
z_ztest_expect_value(STRINGIFY(func), STRINGIFY(param), \
|
||||
(uintptr_t)(value))
|
||||
|
||||
/**
|
||||
* @brief If @a param doesn't match the value set by ztest_expect_value(),
|
||||
@@ -48,17 +48,75 @@
|
||||
*
|
||||
* @param param Parameter to check
|
||||
*/
|
||||
#define ztest_check_expected_value(param) \
|
||||
z_ztest_check_expected_value(__func__, STRINGIFY(param), \
|
||||
(uintptr_t)(param))
|
||||
#define ztest_check_expected_value(param) \
|
||||
z_ztest_check_expected_value(__func__, STRINGIFY(param), \
|
||||
(uintptr_t)(param))
|
||||
|
||||
/**
|
||||
* @brief Tell function @a func to expect the data @a data for @a param
|
||||
*
|
||||
* When using ztest_check_expected_data(), the data pointed to by
|
||||
* @a param should be same @a data in this function. Only data pointer is stored
|
||||
* by this function, so it must still be valid when ztest_check_expected_data is
|
||||
* called.
|
||||
*
|
||||
* @param func Function in question
|
||||
* @param param Parameter for which the data should be set
|
||||
* @param data pointer for the data for parameter @a param
|
||||
*/
|
||||
#define ztest_expect_data(func, param, data) \
|
||||
z_ztest_expect_data(STRINGIFY(func), STRINGIFY(param), (void *)(data))
|
||||
|
||||
/**
|
||||
* @brief If data pointed by @a param don't match the data set by
|
||||
* ztest_expect_data(), fail the test
|
||||
*
|
||||
* This will first check that @a param is expected to be null or non-null and
|
||||
* then check whether the data pointed by parameter is equal to expected data.
|
||||
* If either of these checks fail, the current test will fail. This
|
||||
* must be called from the called function.
|
||||
*
|
||||
* @param param Parameter to check
|
||||
* @param length Length of the data to compare
|
||||
*/
|
||||
#define ztest_check_expected_data(param, length) \
|
||||
z_ztest_check_expected_data(__func__, STRINGIFY(param), \
|
||||
(void *)(param), (length))
|
||||
|
||||
/**
|
||||
* @brief Tell function @a func to return the data @a data for @a param
|
||||
*
|
||||
* When using ztest_return_data(), the data pointed to by @a param should be
|
||||
* same @a data in this function. Only data pointer is stored by this function,
|
||||
* so it must still be valid when ztest_copy_return_data is called.
|
||||
*
|
||||
* @param func Function in question
|
||||
* @param param Parameter for which the data should be set
|
||||
* @param data pointer for the data for parameter @a param
|
||||
*/
|
||||
#define ztest_return_data(func, param, data) \
|
||||
z_ztest_return_data(STRINGIFY(func), STRINGIFY(param), (void *)(data))
|
||||
|
||||
/**
|
||||
* @brief Copy the data set by ztest_return_data to the memory pointed by
|
||||
* @a param
|
||||
*
|
||||
* This will first check that @a param is not null and then copy the data.
|
||||
* This must be called from the called function.
|
||||
*
|
||||
* @param param Parameter to return data for
|
||||
* @param length Length of the data to return
|
||||
*/
|
||||
#define ztest_copy_return_data(param, length) \
|
||||
z_ztest_copy_return_data(__func__, STRINGIFY(param), \
|
||||
(void *)(param), (length))
|
||||
/**
|
||||
* @brief Tell @a func that it should return @a value
|
||||
*
|
||||
* @param func Function that should return @a value
|
||||
* @param value Value to return from @a func
|
||||
*/
|
||||
#define ztest_returns_value(func, value) \
|
||||
#define ztest_returns_value(func, value) \
|
||||
z_ztest_returns_value(STRINGIFY(func), (uintptr_t)(value))
|
||||
|
||||
/**
|
||||
@@ -69,8 +127,7 @@
|
||||
*
|
||||
* @returns The value the current function should return
|
||||
*/
|
||||
#define ztest_get_return_value() \
|
||||
z_ztest_get_return_value(__func__)
|
||||
#define ztest_get_return_value() z_ztest_get_return_value(__func__)
|
||||
|
||||
/**
|
||||
* @brief Get the return value as a pointer for current function
|
||||
@@ -80,7 +137,7 @@
|
||||
*
|
||||
* @returns The value the current function should return as a `void *`
|
||||
*/
|
||||
#define ztest_get_return_value_ptr() \
|
||||
#define ztest_get_return_value_ptr() \
|
||||
((void *)z_ztest_get_return_value(__func__))
|
||||
|
||||
/**
|
||||
@@ -100,7 +157,15 @@ int z_cleanup_mock(void);
|
||||
|
||||
void z_ztest_expect_value(const char *fn, const char *name, uintptr_t value);
|
||||
void z_ztest_check_expected_value(const char *fn, const char *param,
|
||||
uintptr_t value);
|
||||
uintptr_t value);
|
||||
|
||||
void z_ztest_expect_data(const char *fn, const char *name, void *val);
|
||||
void z_ztest_check_expected_data(const char *fn, const char *name, void *data,
|
||||
uint32_t length);
|
||||
|
||||
void z_ztest_return_data(const char *fn, const char *name, void *val);
|
||||
void z_ztest_copy_return_data(const char *fn, const char *name, void *data,
|
||||
uint32_t length);
|
||||
|
||||
void z_ztest_returns_value(const char *fn, uintptr_t value);
|
||||
uintptr_t z_ztest_get_return_value(const char *fn);
|
||||
@@ -114,6 +179,6 @@ uintptr_t z_ztest_get_return_value(const char *fn);
|
||||
#define z_init_mock()
|
||||
#define z_cleanup_mock() 0
|
||||
|
||||
#endif /* CONFIG_ZTEST_MOCKING */
|
||||
#endif /* CONFIG_ZTEST_MOCKING */
|
||||
|
||||
#endif /* __ZTEST_H__ */
|
||||
#endif /* ZEPHYR_TESTSUITE_ZTEST_MOCK_H_ */
|
||||
|
||||
Reference in New Issue
Block a user