1299425Smm/*- 2299425Smm * Copyright (c) 2003-2007 Tim Kientzle 3299425Smm * All rights reserved. 4299425Smm * 5299425Smm * Redistribution and use in source and binary forms, with or without 6299425Smm * modification, are permitted provided that the following conditions 7299425Smm * are met: 8299425Smm * 1. Redistributions of source code must retain the above copyright 9299425Smm * notice, this list of conditions and the following disclaimer. 10299425Smm * 2. Redistributions in binary form must reproduce the above copyright 11299425Smm * notice, this list of conditions and the following disclaimer in the 12299425Smm * documentation and/or other materials provided with the distribution. 13299425Smm * 14299425Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15299425Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16299425Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17299425Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18299425Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19299425Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20299425Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21299425Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22299425Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23299425Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24299425Smm */ 25299425Smm#include "test.h" 26299425Smm 27299425Smm/* 28299425Smm * This first test does basic sanity checks on the environment. For 29299425Smm * most of these, we just exit on failure. 30299425Smm */ 31299425Smm#if !defined(_WIN32) || defined(__CYGWIN__) 32299425Smm#define DEV_NULL "/dev/null" 33299425Smm#else 34299425Smm#define DEV_NULL "NUL" 35299425Smm#endif 36299425Smm 37299425SmmDEFINE_TEST(test_0) 38299425Smm{ 39299425Smm struct stat st; 40299425Smm 41299425Smm failure("File %s does not exist?!", testprog); 42299425Smm if (!assertEqualInt(0, stat(testprogfile, &st))) { 43299425Smm fprintf(stderr, 44299425Smm "\nFile %s does not exist; aborting test.\n\n", 45299425Smm testprog); 46299425Smm exit(1); 47299425Smm } 48299425Smm 49299425Smm failure("%s is not executable?!", testprog); 50299425Smm if (!assert((st.st_mode & 0111) != 0)) { 51299425Smm fprintf(stderr, 52299425Smm "\nFile %s not executable; aborting test.\n\n", 53299425Smm testprog); 54299425Smm exit(1); 55299425Smm } 56299425Smm 57299425Smm /* 58299425Smm * Try to successfully run the program; this requires that 59299425Smm * we know some option that will succeed. 60299425Smm */ 61299425Smm if (0 != systemf("%s --version >" DEV_NULL, testprog)) { 62358090Smm failure("Unable to successfully run: %s --version\n", testprog); 63299425Smm assert(0); 64299425Smm } 65299425Smm 66299425Smm /* TODO: Ensure that our reference files are available. */ 67299425Smm} 68