1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HKS_TEST_LOG_H 17 #define HKS_TEST_LOG_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 22 #include "securec.h" 23 24 enum HksLogLevel { 25 HKS_LOG_LEVEL_I, 26 HKS_LOG_LEVEL_E, 27 HKS_LOG_LEVEL_W, 28 HKS_LOG_LEVEL_D, 29 }; 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 void HksTestLog(uint32_t logLevel, const char *funcName, int32_t lineNo, const char *format, ...); 35 void HksAssertLog(bool test); 36 37 #ifdef __cplusplus 38 } 39 #endif 40 41 #ifndef _CUT_LOG_ 42 #define HKS_TEST_LOG_E(...) \ 43 do { \ 44 HksTestLog(HKS_LOG_LEVEL_E, __FUNCTION__, __LINE__, __VA_ARGS__); \ 45 } while (0) 46 47 #define HKS_TEST_LOG_I(...) \ 48 do { \ 49 HksTestLog(HKS_LOG_LEVEL_I, __FUNCTION__, __LINE__, __VA_ARGS__); \ 50 } while (0) 51 52 #define HKS_TEST_LOG_W(...) \ 53 do { \ 54 HksTestLog(HKS_LOG_LEVEL_W, __FUNCTION__, __LINE__, __VA_ARGS__); \ 55 } while (0) 56 57 #define HKS_TEST_LOG_D(...) \ 58 do { \ 59 HksTestLog(HKS_LOG_LEVEL_D, __FUNCTION__, __LINE__, __VA_ARGS__); \ 60 } while (0) 61 #else 62 #define HKS_TEST_LOG_E(...) 63 #define HKS_TEST_LOG_I(...) 64 #define HKS_TEST_LOG_W(...) 65 #define HKS_TEST_LOG_D(...) 66 #endif 67 68 #define HKS_TEST_ASSERT HksAssertLog 69 70 #endif /* HKS_TEST_LOG_H */ 71