blob: a5902337c96778d52b18def80808818cc20d1c07 [file] [log] [blame]
Evgenii Stepanov68ecec12017-01-31 13:19:30 -08001/*
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 Hughes611019b2024-02-16 00:32:46 +000017#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 Stepanov68ecec12017-01-31 13:19:30 -080022
Ryan Pricharde4912ac2024-03-13 17:07:30 -070023#include <stdio.h>
24#include <stdlib.h>
25
26static 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 Hughesdc0510e2024-03-15 15:23:12 +000029 fflush(NULL);
Ryan Pricharde4912ac2024-03-13 17:07:30 -070030 abort();
31}
Evgenii Stepanov68ecec12017-01-31 13:19:30 -080032
Elliott Hugheseb04ed52017-03-29 13:48:02 -070033#define CHECK(e) \
Ryan Pricharde4912ac2024-03-13 17:07:30 -070034 ((e) ? static_cast<void>(0) : check_failure(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e))