Evgenii Stepanov | 68ecec1 | 2017-01-31 13:19:30 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Elliott Hughes | 611019b | 2024-02-16 00:32:46 +0000 | [diff] [blame] | 17 | #pragma once |
| 18 | |
| 19 | // Tests proper can use libbase, but libraries for testing dlopen() |
| 20 | // should probably avoid dependencies other than ones we're specifically |
| 21 | // trying to test. |
Evgenii Stepanov | 68ecec1 | 2017-01-31 13:19:30 -0800 | [diff] [blame] | 22 | |
Ryan Prichard | e4912ac | 2024-03-13 17:07:30 -0700 | [diff] [blame] | 23 | #include <stdio.h> |
| 24 | #include <stdlib.h> |
| 25 | |
| 26 | static inline void check_failure(const char* file, int line, const char* function, |
| 27 | const char* failed_expression) { |
| 28 | fprintf(stderr, "%s:%d: %s: assertion \"%s\" failed\n", file, line, function, failed_expression); |
Elliott Hughes | dc0510e | 2024-03-15 15:23:12 +0000 | [diff] [blame] | 29 | fflush(NULL); |
Ryan Prichard | e4912ac | 2024-03-13 17:07:30 -0700 | [diff] [blame] | 30 | abort(); |
| 31 | } |
Evgenii Stepanov | 68ecec1 | 2017-01-31 13:19:30 -0800 | [diff] [blame] | 32 | |
Elliott Hughes | eb04ed5 | 2017-03-29 13:48:02 -0700 | [diff] [blame] | 33 | #define CHECK(e) \ |
Ryan Prichard | e4912ac | 2024-03-13 17:07:30 -0700 | [diff] [blame] | 34 | ((e) ? static_cast<void>(0) : check_failure(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e)) |