1 /* 2 * Copyright (C) 2022 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 NDKTEST_LOG_H 17 #define NDKTEST_LOG_H 18 19 #include <stdio.h> 20 21 #define RET_FAIL (-1) 22 #define RET_OK 0 23 24 #define NDK_CHECK_AND_RETURN_RET_LOG(cond, ret, fmt, ...) \ 25 do { \ 26 if (!(cond)) { \ 27 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 28 return ret; \ 29 } \ 30 } while (0) 31 32 #define NDK_CHECK_AND_RETURN_LOG(cond, fmt, ...) \ 33 do { \ 34 if (!(cond)) { \ 35 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 36 return; \ 37 } \ 38 } while (0) 39 40 #define NDK_CHECK_AND_BREAK_LOG(cond, fmt, ...) \ 41 if (!(cond)) { \ 42 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 43 break; \ 44 } 45 46 #define NDK_CHECK_AND_CONTINUE_LOG(cond, fmt, ...) \ 47 if (!(cond)) { \ 48 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 49 continue; \ 50 } 51 52 #define NDK_CHECK_AND_LOG(cond, fmt, ...) \ 53 if (!(cond)) { \ 54 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 55 } 56 #endif // NDKTEST_LOG_H