187dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller/* 287dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * Copyright (C) 2010 The Android Open Source Project 387dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * 487dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * Licensed under the Apache License, Version 2.0 (the "License"); 587dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * you may not use this file except in compliance with the License. 687dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * You may obtain a copy of the License at 787dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * 887dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * http://www.apache.org/licenses/LICENSE-2.0 987dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * 1087dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * Unless required by applicable law or agreed to in writing, software 1187dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * distributed under the License is distributed on an "AS IS" BASIS, 1287dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1387dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * See the License for the specific language governing permissions and 1487dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * limitations under the License. 1587dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller * 1687dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller */ 1787dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 1887dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#ifndef _TESTUTIL_H_ 1987dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#define _TESTUTIL_H_ 2087dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 2187dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#include <stdint.h> 2287dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#include <stdio.h> 2387dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#include <sys/time.h> 2487dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 25d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemiller__BEGIN_DECLS 2687dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 2787dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller// Time Utilities 2887dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemillerstruct timespec double2ts(double amt); 29d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemillerstruct timeval double2tv(double amt); 30d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemillerdouble ts2double(const struct timespec *val); 31d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemillerdouble tv2double(const struct timeval *val); 32d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemillerstruct timespec tsDelta(const struct timespec *first, 33d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemiller const struct timespec *second); 3487dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemillerstruct timeval tvDelta(const struct timeval *first, 3587dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller const struct timeval *second); 36d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemiller 37a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemillervoid testDelay(float amt); 38f3df372c18c3baf9c0c9c93bce7622818ae6a8a1Louis Huemillervoid testDelaySpin(float amt); 3987dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 4087dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller// Pseudo Random Utilities 4187dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemillerint testRandBool(void); 428eea4fcdf2a829e01e8114a9572573cae98f2a6eLouis Huemilleruint32_t testRand(void); 438eea4fcdf2a829e01e8114a9572573cae98f2a6eLouis Huemilleruint32_t testRandMod(uint32_t mod); 44a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemillerdouble testRandFract(void); 4587dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 4687dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller// Testcase Output 4787dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemillervoid testSetLogCatTag(const char *tag); 4887dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemillerconst char *testGetLogCatTag(void); 4987dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemillervoid testPrint(FILE *stream, const char *fmt, ...); 5087dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#define testPrintI(...) do { \ 5187dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller testPrint(stdout, __VA_ARGS__); \ 5287dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller } while (0) 5387dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#define testPrintE(...) do { \ 5487dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller testPrint(stderr, __VA_ARGS__); \ 5587dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller } while (0) 5687dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 57a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemiller// Hex Dump 58a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemillervoid testXDump(const void *buf, size_t size); 59a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemillervoid testXDumpSetIndent(uint8_t indent); 60a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemilleruint8_t testXDumpGetIndent(void); 61a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemillervoid testXDumpSetOffset(uint64_t offset); 62a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemilleruint64_t testXDumpGetOffset(void); 63a31faf1b7edb5c20d3a8949ba3ca767b4f0a4a7dLouis Huemiller 648eea4fcdf2a829e01e8114a9572573cae98f2a6eLouis Huemiller// Command Execution 658eea4fcdf2a829e01e8114a9572573cae98f2a6eLouis Huemillervoid testExecCmd(const char *cmd); 668eea4fcdf2a829e01e8114a9572573cae98f2a6eLouis Huemiller 67d2447fd2505466a8c30cdca247325f79ba95be34Louis Huemiller__END_DECLS 6887dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller 6987dd9e92610d5e7552f5cdb6ab2578035e2210f5Louis Huemiller#endif 70