• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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.
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 
check_failure(const char * file,int line,const char * function,const char * failed_expression)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);
29   fflush(NULL);
30   abort();
31 }
32 
33 #define CHECK(e) \
34   ((e) ? static_cast<void>(0) : check_failure(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e))
35