testUtil.h revision 87dd9e92610d5e7552f5cdb6ab2578035e2210f5
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 25#ifdef __cplusplus 26extern "C" { 27#endif 28 29// Time Utilities 30double tv2double(const struct timeval *val); 31struct timespec double2ts(double amt); 32struct timeval tvDelta(const struct timeval *first, 33 const struct timeval *second); 34void delay(float amt); 35 36// Pseudo Random Utilities 37int testRandBool(void); 38 39// Testcase Output 40void testSetLogCatTag(const char *tag); 41const char *testGetLogCatTag(void); 42void testPrint(FILE *stream, const char *fmt, ...); 43#define testPrintI(...) do { \ 44 testPrint(stdout, __VA_ARGS__); \ 45 } while (0) 46#define testPrintE(...) do { \ 47 testPrint(stderr, __VA_ARGS__); \ 48 } while (0) 49 50#ifdef __cplusplus 51} 52#endif 53 54#endif 55