Path: blob/main/contrib/libarchive/tar/test/test_0.c
39507 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2003-2007 Tim Kientzle4* All rights reserved.5*/6#include "test.h"78/*9* This first test does basic sanity checks on the environment. For10* most of these, we just exit on failure.11*/12#if !defined(_WIN32) || defined(__CYGWIN__)13#define DEV_NULL "/dev/null"14#else15#define DEV_NULL "NUL"16#endif1718DEFINE_TEST(test_0)19{20struct stat st;2122failure("File %s does not exist?!", testprog);23if (!assertEqualInt(0, stat(testprogfile, &st))) {24fprintf(stderr,25"\nFile %s does not exist; aborting test.\n\n",26testprog);27exit(1);28}2930failure("%s is not executable?!", testprog);31if (!assert((st.st_mode & 0111) != 0)) {32fprintf(stderr,33"\nFile %s not executable; aborting test.\n\n",34testprog);35exit(1);36}3738/*39* Try to successfully run the program; this requires that40* we know some option that will succeed.41*/42if (0 == systemf("%s --version >" DEV_NULL, testprog)) {43/* This worked. */44} else if (0 == systemf("%s -W version >" DEV_NULL, testprog)) {45/* This worked. */46} else {47failure("Unable to successfully run any of the following:\n"48" * %s --version\n"49" * %s -W version\n",50testprog, testprog);51assert(0);52}5354/* TODO: Ensure that our reference files are available. */55}565758