[PATCH 2/4] lib: Add SBIUnit testing macros and functions
Ivan Orlov
ivan.orlov0322 at gmail.com
Tue Feb 13 06:55:21 PST 2024
On 2/13/24 14:00, Andrew Jones wrote:
> On Mon, Feb 12, 2024 at 10:03:52PM +0000, Ivan Orlov wrote:
>> On 2/12/24 17:36, Andrew Jones wrote:
>>> On Thu, Feb 08, 2024 at 09:50:48AM +0000, Ivan Orlov wrote:
> ...
>>>> +#define SBIUNIT_ASSERT(test, cond) do { \
>>>> + if (!(cond)) { \
>>>> + test->result = 0; \
>>>> + SBIUNIT_INFO(test, "Condition \"" #cond "\" must be true!\n"); \
>>>> + return; \
>>>
>>> Unnecessary 'return'. It's strange that an ASSERT macro doesn't result in
>>> an sbi_panic().
>>>
>>
>> I thought it would be bad if test results in hang, but if it is ok I will
>> rewrite it.
>
> I think an assert should output its message and then stop all execution.
> Asserts should only be used in situations where failures mean the
> test programmer made an improper assumption. If we don't halt the moment
> we determine the assumption is wrong, then we'll potentially generate
> passing test results, but the tests may not be testing what the test
> programmer thought they were.
>
Makes sense, so let's add the sbi_panic in version 2.
Thanks!
--
Kind regards,
Ivan Orlov
More information about the opensbi
mailing list