/** * @file tests/can_rpc.cpp * @brief brief * @date Aug 25, 2015 * @author rheijden * @copyright 2015 Dual Inventive Technology Centre B.V. * * descr */ #define DI_LOG_ENABLE_FROM_DEBUG #define DI_LOG_MODULE DI_LOG_MODULE_LIBDI_TEST #include "tests/can.h" #include #include #include #include #include TEST_CAN_INIT_DECL /** * Verify DI_LOG_* macros send the correct messages with the di_can_log_writer */ void test_can_log_DI_LOG_check_msg(enum di_log_level level); TEST(can_log, DI_LOG) { di_can_callback_set_send(&can_ctx, test_can_send_callback_loopback); di_log_init(DI_LOG_LEVEL_DEBUG, di_can_log_writer, &can_ctx); DI_LOG_CRIT("CAN log msg crit"); test_can_log_DI_LOG_check_msg(DI_LOG_LEVEL_CRIT); DI_LOG_ERROR("CAN log msg error"); test_can_log_DI_LOG_check_msg(DI_LOG_LEVEL_ERROR); DI_LOG_WARN("CAN log msg warn"); test_can_log_DI_LOG_check_msg(DI_LOG_LEVEL_WARN); DI_LOG_INFO("CAN log msg info"); test_can_log_DI_LOG_check_msg(DI_LOG_LEVEL_INFO); DI_LOG_DEBUG("CAN log msg debug"); test_can_log_DI_LOG_check_msg(DI_LOG_LEVEL_DEBUG); } void test_can_log_DI_LOG_check_msg(enum di_log_level level) { struct di_can_msg *msg = di_can_recv(&can_ctx, DI_CAN_MSGTYPE_LOG); ASSERT_NE((void *)NULL, msg); ASSERT_EQ(DI_CAN_MSGTYPE_LOG, DI_CAN_GET_MSGTYPE(msg->canid)); ASSERT_EQ(level, DI_CAN_GET_DATATYPE(msg->canid)); di_can_msg_free(&msg); }