xref: /freebsd/contrib/libarchive/cat/test/test_0.c (revision 06690044dac183ea1d93c2ae227e261da3bdca2a)
1  /*-
2   * SPDX-License-Identifier: BSD-2-Clause
3   *
4   * Copyright (c) 2003-2007 Tim Kientzle
5   * All rights reserved.
6   */
7  #include "test.h"
8  
9  /*
10   * This first test does basic sanity checks on the environment.  For
11   * most of these, we just exit on failure.
12   */
13  #if !defined(_WIN32) || defined(__CYGWIN__)
14  #define DEV_NULL "/dev/null"
15  #else
16  #define DEV_NULL "NUL"
17  #endif
18  
19  DEFINE_TEST(test_0)
20  {
21  	struct stat st;
22  
23  	failure("File %s does not exist?!", testprog);
24  	if (!assertEqualInt(0, stat(testprogfile, &st))) {
25  		fprintf(stderr,
26  		    "\nFile %s does not exist; aborting test.\n\n",
27  		    testprog);
28  		exit(1);
29  	}
30  
31  	failure("%s is not executable?!", testprog);
32  	if (!assert((st.st_mode & 0111) != 0)) {
33  		fprintf(stderr,
34  		    "\nFile %s not executable; aborting test.\n\n",
35  		    testprog);
36  		exit(1);
37  	}
38  
39  	/*
40  	 * Try to successfully run the program; this requires that
41  	 * we know some option that will succeed.
42  	 */
43  	if (0 != systemf("%s --version >" DEV_NULL, testprog)) {
44  		failure("Unable to successfully run: %s --version\n", testprog);
45  		assert(0);
46  	}
47  
48  	/* TODO: Ensure that our reference files are available. */
49  }
50