Spdk/test/spdk_cunit.h

29 lines
707 B
C
Raw Normal View History

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) Intel Corporation.
* All rights reserved.
*/
#ifndef SPDK_CUNIT_H
#define SPDK_CUNIT_H
#include "spdk/stdinc.h"
#include <CUnit/Basic.h>
/*
* CU_ASSERT_FATAL calls a function that does a longjmp() internally, but only for fatal asserts,
* so the function itself is not marked as noreturn. Add an abort() after the assert to help
* static analyzers figure out that it really doesn't return.
* The abort() will never actually execute.
*/
#define SPDK_CU_ASSERT_FATAL(cond) \
do { \
int result_ = !!(cond); \
CU_ASSERT_FATAL(result_); \
if (!result_) { \
abort(); \
} \
} while (0)
#endif /* SPDK_CUNIT_H */