| Louis Huemiller | 87dd9e9 | 2010-08-30 17:15:49 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2010 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 |  | 
 | 18 | #ifndef _TESTUTIL_H_ | 
 | 19 | #define _TESTUTIL_H_ | 
 | 20 |  | 
 | 21 | #include <stdint.h> | 
 | 22 | #include <stdio.h> | 
 | 23 | #include <sys/time.h> | 
 | 24 |  | 
| Louis Huemiller | d2447fd | 2010-10-14 17:52:13 -0700 | [diff] [blame] | 25 | __BEGIN_DECLS | 
| Louis Huemiller | 87dd9e9 | 2010-08-30 17:15:49 -0700 | [diff] [blame] | 26 |  | 
 | 27 | // Time Utilities | 
| Louis Huemiller | 87dd9e9 | 2010-08-30 17:15:49 -0700 | [diff] [blame] | 28 | struct timespec double2ts(double amt); | 
| Louis Huemiller | d2447fd | 2010-10-14 17:52:13 -0700 | [diff] [blame] | 29 | struct timeval  double2tv(double amt); | 
 | 30 | double ts2double(const struct timespec *val); | 
 | 31 | double tv2double(const struct timeval  *val); | 
 | 32 | struct timespec tsDelta(const struct timespec *first, | 
 | 33 |     const struct timespec *second); | 
| Louis Huemiller | 87dd9e9 | 2010-08-30 17:15:49 -0700 | [diff] [blame] | 34 | struct timeval tvDelta(const struct timeval *first, | 
 | 35 |     const struct timeval *second); | 
| Louis Huemiller | d2447fd | 2010-10-14 17:52:13 -0700 | [diff] [blame] | 36 |  | 
| Louis Huemiller | 87dd9e9 | 2010-08-30 17:15:49 -0700 | [diff] [blame] | 37 | void delay(float amt); | 
 | 38 |  | 
 | 39 | // Pseudo Random Utilities | 
 | 40 | int testRandBool(void); | 
 | 41 |  | 
 | 42 | // Testcase Output | 
 | 43 | void testSetLogCatTag(const char *tag); | 
 | 44 | const char *testGetLogCatTag(void); | 
 | 45 | void testPrint(FILE *stream, const char *fmt, ...); | 
 | 46 | #define testPrintI(...) do { \ | 
 | 47 |         testPrint(stdout, __VA_ARGS__); \ | 
 | 48 |     } while (0) | 
 | 49 | #define testPrintE(...) do { \ | 
 | 50 |         testPrint(stderr, __VA_ARGS__); \ | 
 | 51 |     } while (0) | 
 | 52 |  | 
| Louis Huemiller | d2447fd | 2010-10-14 17:52:13 -0700 | [diff] [blame] | 53 | __END_DECLS | 
| Louis Huemiller | 87dd9e9 | 2010-08-30 17:15:49 -0700 | [diff] [blame] | 54 |  | 
 | 55 | #endif |