struct stat st;
va_list ap;
ssize_t s;
- int fd;
+ FILE *f;
va_start(ap, f1fmt);
fprintf(stderr, "%s:%d: File not empty: %s\n", test_filename, test_line, f1);
fprintf(stderr, " File size: %d\n", (int)st.st_size);
fprintf(stderr, " Contents:\n");
- fd = open(f1, O_RDONLY | O_BINARY);
- if (fd < 0) {
+ f = fopen(f1, "rb");
+ if (f != NULL) {
fprintf(stderr, " Unable to open %s\n", f1);
} else {
- s = sizeof(buff) < st.st_size ? sizeof(buff) : st.st_size;
- s = read(fd, buff, s);
+ s = ((off_t)sizeof(buff) < st.st_size) ?
+ (ssize_t)sizeof(buff) : (ssize_t)st.st_size;
+ s = fread(buff, 1, s, f);
hexdump(buff, NULL, s, 0);
+ fclose(f);
}
report_failure(NULL);
return (0);
}
+int
+test_assert_non_empty_file(const char *f1fmt, ...)
+{
+ char f1[1024];
+ struct stat st;
+ va_list ap;
+
+
+ va_start(ap, f1fmt);
+ vsprintf(f1, f1fmt, ap);
+ va_end(ap);
+
+ if (stat(f1, &st) != 0) {
+ fprintf(stderr, "%s:%d: Could not stat: %s\n",
+ test_filename, test_line, f1);
+ report_failure(NULL);
+ failures++;
+ return (0);
+ }
+ if (st.st_size != 0)
+ return (1);
+
+ failures ++;
+ if (!verbose && previous_failures(test_filename, test_line, 1))
+ return (0);
+
+ fprintf(stderr, "%s:%d: File empty: %s\n",
+ test_filename, test_line, f1);
+ report_failure(NULL);
+ return (0);
+}
+
/* assertEqualFile() asserts that two files have the same contents. */
/* TODO: hexdump the first bytes that actually differ. */
int
-test_assert_equal_file(const char *f1, const char *f2pattern, ...)
+test_assert_equal_file(const char *fn1, const char *f2pattern, ...)
{
- char f2[1024];
+ char fn2[1024];
va_list ap;
char buff1[1024];
char buff2[1024];
- int fd1, fd2;
+ FILE *f1, *f2;
int n1, n2;
va_start(ap, f2pattern);
- vsprintf(f2, f2pattern, ap);
+ vsprintf(fn2, f2pattern, ap);
va_end(ap);
- fd1 = open(f1, O_RDONLY | O_BINARY);
- fd2 = open(f2, O_RDONLY | O_BINARY);
+ f1 = fopen(fn1, "rb");
+ f2 = fopen(fn2, "rb");
for (;;) {
- n1 = read(fd1, buff1, sizeof(buff1));
- n2 = read(fd2, buff2, sizeof(buff2));
+ n1 = fread(buff1, 1, sizeof(buff1), f1);
+ n2 = fread(buff2, 1, sizeof(buff2), f2);
if (n1 != n2)
break;
- if (n1 == 0 && n2 == 0)
+ if (n1 == 0 && n2 == 0) {
+ fclose(f1);
+ fclose(f2);
return (1);
+ }
if (memcmp(buff1, buff2, n1) != 0)
break;
}
+ fclose(f1);
+ fclose(f2);
failures ++;
if (!verbose && previous_failures(test_filename, test_line, 1))
return (0);
fprintf(stderr, "%s:%d: Files are not identical\n",
test_filename, test_line);
- fprintf(stderr, " file1=\"%s\"\n", f1);
- fprintf(stderr, " file2=\"%s\"\n", f2);
+ fprintf(stderr, " file1=\"%s\"\n", fn1);
+ fprintf(stderr, " file2=\"%s\"\n", fn2);
report_failure(test_extra);
return (0);
}
int
test_assert_file_contents(const void *buff, int s, const char *fpattern, ...)
{
- char f[1024];
+ char fn[1024];
va_list ap;
char *contents;
- int fd;
+ FILE *f;
int n;
va_start(ap, fpattern);
- vsprintf(f, fpattern, ap);
+ vsprintf(fn, fpattern, ap);
va_end(ap);
- fd = open(f, O_RDONLY | O_BINARY);
+ f = fopen(fn, "rb");
+ if (f == NULL) {
+ failures ++;
+ if (!previous_failures(test_filename, test_line, 1)) {
+ fprintf(stderr, "%s:%d: File doesn't exist: %s\n",
+ test_filename, test_line, fn);
+ report_failure(test_extra);
+ }
+ return (0);
+ }
contents = malloc(s * 2);
- n = read(fd, contents, s * 2);
+ n = fread(contents, 1, s * 2, f);
+ fclose(f);
if (n == s && memcmp(buff, contents, s) == 0) {
free(contents);
return (1);
if (!previous_failures(test_filename, test_line, 1)) {
fprintf(stderr, "%s:%d: File contents don't match\n",
test_filename, test_line);
- fprintf(stderr, " file=\"%s\"\n", f);
+ fprintf(stderr, " file=\"%s\"\n", fn);
if (n > 0)
hexdump(contents, buff, n, 0);
else {
va_list ap;
char *p;
ssize_t bytes_read;
- int fd;
+ FILE *f;
int r;
va_start(ap, fmt);
vsprintf(filename, fmt, ap);
va_end(ap);
- fd = open(filename, O_RDONLY | O_BINARY);
- if (fd < 0) {
+ f = fopen(filename, "rb");
+ if (f == NULL) {
/* Note: No error; non-existent file is okay here. */
return (NULL);
}
- r = fstat(fd, &st);
+ r = fstat(fileno(f), &st);
if (r != 0) {
fprintf(stderr, "Can't stat file %s\n", filename);
- close(fd);
+ fclose(f);
return (NULL);
}
p = malloc(st.st_size + 1);
if (p == NULL) {
fprintf(stderr, "Can't allocate %ld bytes of memory to read file %s\n", (long int)st.st_size, filename);
- close(fd);
+ fclose(f);
return (NULL);
}
- bytes_read = read(fd, p, st.st_size);
+ bytes_read = fread(p, 1, st.st_size, f);
if (bytes_read < st.st_size) {
fprintf(stderr, "Can't read file %s\n", filename);
- close(fd);
+ fclose(f);
free(p);
return (NULL);
}
p[st.st_size] = '\0';
if (sizep != NULL)
*sizep = (size_t)st.st_size;
- close(fd);
+ fclose(f);
return (p);
}
#include "list.h"
};
-/*
- * This is well-intentioned, but sometimes the standard libraries
- * leave open file descriptors and expect to be able to come back to
- * them (e.g., for username lookups or logging). Closing these
- * descriptors out from under those libraries creates havoc.
- *
- * Maybe there's some reasonably portable way to tell if a descriptor
- * is open without using close()?
- */
-#if 0
-static void
-close_descriptors(int warn)
-{
- int i;
- int left_open = 0;
-
- for (i = 3; i < 100; ++i) {
- if (close(i) == 0)
- ++left_open;
- }
- if (warn && left_open > 0) {
- fprintf(stderr, " ** %d descriptors unclosed\n", left_open);
- failures += left_open;
- report_failure(NULL);
- }
-}
-#endif
-
/*
* Each test is run in a private work dir. Those work dirs
* do have consistent and predictable names, in case a group
}
/* Explicitly reset the locale before each test. */
setlocale(LC_ALL, "C");
- /* Make sure there are no stray descriptors going into the test. */
- /* TODO: Find a better way to identify file descriptor leaks. */
- //close_descriptors(0);
/* Run the actual test. */
(*tests[i].func)();
- /* Close stray descriptors, record as errors against this test. */
- //close_descriptors(1);
/* Summarize the results of this test. */
summarize();
/* If there were no failures, we can remove the work dir. */
if (failures == failures_before) {
if (!keep_temp_files && chdir(tmpdir) == 0) {
-#if !defined(_WIN32) || defined(__CYGWIN__)
- systemf("rm -rf %s", tests[i].name);
-#else
+#if defined(_WIN32) && !defined(__CYGWIN__)
systemf("rmdir /S /Q %s", tests[i].name);
+#else
+ systemf("rm -rf %s", tests[i].name);
#endif
}
}
}
/* Now, decode the rest and write it. */
/* Not a lot of error checking here; the input better be right. */
- out = fopen(name, "wb");
+ out = fopen(name, "w");
while (fgets(buff, sizeof(buff), in) != NULL) {
char *p = buff;
int bytes;
int i, tests_run = 0, tests_failed = 0, option;
time_t now;
char *refdir_alloc = NULL;
- const char *progname = LIBRARY "_test";
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ char *testprg;
+#endif
+ const char *progname;
const char *tmp, *option_arg, *p;
char tmpdir[256];
char tmpdir_timestamp[256];
_CrtSetReportMode(_CRT_ASSERT, 0);
#endif
+ /*
+ * Name of this program, used to build root of our temp directory
+ * tree.
+ */
+ progname = p = argv[0];
+ while (*p != '\0') {
+ /* Support \ or / dir separators for Windows compat. */
+ if (*p == '/' || *p == '\\')
+ progname = p + 1;
+ ++p;
+ }
+
#ifdef PROGRAM
/* Get the target program from environment, if available. */
testprog = getenv(ENVBASE);
if (testprog == NULL)
usage(progname);
#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /*
+ * command.com cannot accept the command used '/' with drive
+ * name such as c:/xxx/command.exe when use '|' pipe handling.
+ */
+ testprg = strdup(testprog);
+ for (i = 0; testprg[i] != '\0'; i++) {
+ if (testprg[i] == '/')
+ testprg[i] = '\\';
+ }
+ testprog = testprg;
+#endif
/*
* Create a temp directory for the following tests.
#include <locale.h>
#include <stdarg.h>
#include <time.h>
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#if !defined(__GNUC__)
+#include <crtdbg.h>
+#endif
+#include <windows.h>
+#include <winbase.h>
+#endif
/*
* This same file is used pretty much verbatim for all test harnesses.
* The next few lines are the only differences.
*/
#define PROGRAM "bsdtar" /* Name of program being tested. */
+#undef LIBRARY /* Not testing a library. */
#define ENVBASE "BSDTAR" /* Prefix for environment variables. */
#undef EXTRA_DUMP /* How to dump extra data */
/* How to generate extra version info. */
#define EXTRA_VERSION (systemf("%s --version", testprog) ? "" : "")
+#define KNOWNREF "test_patterns_2.tar.uu"
__FBSDID("$FreeBSD: src/usr.bin/tar/test/main.c,v 1.6 2008/11/05 06:40:53 kientzle Exp $");
/*
/* Directory where uuencoded reference files can be found. */
static const char *refdir;
+
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
+
+static void
+invalid_parameter_handler(const wchar_t * expression,
+ const wchar_t * function, const wchar_t * file,
+ unsigned int line, uintptr_t pReserved)
+{
+ /* nop */
+}
+
+#endif
+
/*
* My own implementation of the standard assert() macro emits the
* message in the same format as GCC (file:line: message).
static struct line {
int line;
int count;
+ int critical;
} failed_lines[1000];
+/*
+ * Called at the beginning of each assert() function.
+ */
+static void
+count_assertion(const char *file, int line)
+{
+ (void)file; /* UNUSED */
+ (void)line; /* UNUSED */
+ ++assertions;
+ /* Uncomment to print file:line after every assertion.
+ * Verbose, but occasionally useful in tracking down crashes. */
+ /* printf("Checked %s:%d\n", file, line); */
+}
+
/*
* Count this failure; return the number of previous failures.
*/
static int
-previous_failures(const char *filename, int line)
+previous_failures(const char *filename, int line, int critical)
{
unsigned int i;
int count;
if (failed_lines[i].line == 0) {
failed_lines[i].line = line;
failed_lines[i].count = 1;
+ failed_lines[i].critical = critical;
return (0);
}
}
{
va_list ap;
- if (previous_failures(test_filename, test_line))
+ if (previous_failures(test_filename, test_line, 0))
return;
va_start(ap, fmt);
for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
if (failed_lines[i].line == 0)
break;
- if (failed_lines[i].count > 1)
+ if (failed_lines[i].count > 1 && failed_lines[i].critical)
fprintf(stderr, "%s:%d: Failed %d times\n",
failed_filename, failed_lines[i].line,
failed_lines[i].count);
int
test_assert(const char *file, int line, int value, const char *condition, void *extra)
{
- ++assertions;
+ count_assertion(file, line);
if (value) {
msg[0] = '\0';
return (value);
}
failures ++;
- if (!verbose && previous_failures(file, line))
+ if (!verbose && previous_failures(file, line, 1))
return (value);
fprintf(stderr, "%s:%d: Assertion failed\n", file, line);
fprintf(stderr, " Condition: %s\n", condition);
test_assert_equal_int(const char *file, int line,
int v1, const char *e1, int v2, const char *e2, void *extra)
{
- ++assertions;
+ count_assertion(file, line);
if (v1 == v2) {
msg[0] = '\0';
return (1);
}
failures ++;
- if (!verbose && previous_failures(file, line))
+ if (!verbose && previous_failures(file, line, 1))
return (0);
fprintf(stderr, "%s:%d: Assertion failed: Ints not equal\n",
file, line);
const char *v2, const char *e2,
void *extra)
{
- ++assertions;
+ count_assertion(file, line);
if (v1 == NULL || v2 == NULL) {
if (v1 == v2) {
msg[0] = '\0';
return (1);
}
failures ++;
- if (!verbose && previous_failures(file, line))
+ if (!verbose && previous_failures(file, line, 1))
return (0);
fprintf(stderr, "%s:%d: Assertion failed: Strings not equal\n",
file, line);
const wchar_t *v2, const char *e2,
void *extra)
{
- ++assertions;
+ count_assertion(file, line);
if (v1 == NULL) {
if (v2 == NULL) {
msg[0] = '\0';
return (1);
}
failures ++;
- if (!verbose && previous_failures(file, line))
+ if (!verbose && previous_failures(file, line, 1))
return (0);
fprintf(stderr, "%s:%d: Assertion failed: Unicode strings not equal\n",
file, line);
char sep;
for(i=0; i < l; i+=16) {
- fprintf(stderr, "%04x", (int)(i + offset));
+ fprintf(stderr, "%04x", (unsigned)(i + offset));
sep = ' ';
for (j = 0; j < 16 && i + j < l; j++) {
if (ref != NULL && p[i + j] != ref[i + j])
}
/* assertEqualMem() displays the values of the two memory blocks. */
-/* TODO: For long blocks, hexdump the first bytes that actually differ. */
int
test_assert_equal_mem(const char *file, int line,
- const char *v1, const char *e1,
- const char *v2, const char *e2,
+ const void *_v1, const char *e1,
+ const void *_v2, const char *e2,
size_t l, const char *ld, void *extra)
{
- ++assertions;
+ const char *v1 = (const char *)_v1;
+ const char *v2 = (const char *)_v2;
+ size_t offset;
+
+ count_assertion(file, line);
if (v1 == NULL || v2 == NULL) {
if (v1 == v2) {
msg[0] = '\0';
return (1);
}
failures ++;
- if (!verbose && previous_failures(file, line))
+ if (!verbose && previous_failures(file, line, 1))
return (0);
fprintf(stderr, "%s:%d: Assertion failed: memory not equal\n",
file, line);
fprintf(stderr, " size %s = %d\n", ld, (int)l);
+ /* Dump 48 bytes (3 lines) so that the first difference is
+ * in the second line. */
+ offset = 0;
+ while (l > 64 && memcmp(v1, v2, 32) == 0) {
+ /* The first two lines agree, so step forward one line. */
+ v1 += 16;
+ v2 += 16;
+ l -= 16;
+ offset += 16;
+ }
fprintf(stderr, " Dump of %s\n", e1);
- hexdump(v1, v2, l < 32 ? l : 32, 0);
+ hexdump(v1, v2, l < 64 ? l : 64, offset);
fprintf(stderr, " Dump of %s\n", e2);
- hexdump(v2, v1, l < 32 ? l : 32, 0);
+ hexdump(v2, v1, l < 64 ? l : 64, offset);
fprintf(stderr, "\n");
report_failure(extra);
return (0);
va_end(ap);
if (stat(f1, &st) != 0) {
- fprintf(stderr, "%s:%d: Could not stat: %s\n",
- test_filename, test_line, f1);
- failures ++;
+ fprintf(stderr, "%s:%d: Could not stat: %s\n", test_filename, test_line, f1);
report_failure(NULL);
return (0);
}
return (1);
failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
+ if (!verbose && previous_failures(test_filename, test_line, 1))
return (0);
fprintf(stderr, "%s:%d: File not empty: %s\n", test_filename, test_line, f1);
return (1);
failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
+ if (!verbose && previous_failures(test_filename, test_line, 1))
return (0);
fprintf(stderr, "%s:%d: File empty: %s\n",
fclose(f1);
fclose(f2);
failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
+ if (!verbose && previous_failures(test_filename, test_line, 1))
return (0);
fprintf(stderr, "%s:%d: Files are not identical\n",
test_filename, test_line);
if (!access(f, F_OK))
return (1);
- if (!previous_failures(test_filename, test_line)) {
+ if (!previous_failures(test_filename, test_line, 1)) {
fprintf(stderr, "%s:%d: File doesn't exist\n",
test_filename, test_line);
fprintf(stderr, " file=\"%s\"\n", f);
if (access(f, F_OK))
return (1);
- if (!previous_failures(test_filename, test_line)) {
+ if (!previous_failures(test_filename, test_line, 1)) {
fprintf(stderr, "%s:%d: File exists and shouldn't\n",
test_filename, test_line);
fprintf(stderr, " file=\"%s\"\n", f);
f = fopen(fn, "rb");
if (f == NULL) {
failures ++;
- if (!previous_failures(test_filename, test_line)) {
+ if (!previous_failures(test_filename, test_line, 1)) {
fprintf(stderr, "%s:%d: File doesn't exist: %s\n",
test_filename, test_line, fn);
report_failure(test_extra);
return (1);
}
failures ++;
- if (!previous_failures(test_filename, test_line)) {
+ if (!previous_failures(test_filename, test_line, 1)) {
fprintf(stderr, "%s:%d: File contents don't match\n",
test_filename, test_line);
fprintf(stderr, " file=\"%s\"\n", fn);
fclose(in);
}
+static char *
+get_refdir(const char *d)
+{
+ char tried[512] = { '\0' };
+ char buff[128];
+ char *pwd, *p;
+
+ /* If a dir was specified, try that */
+ if (d != NULL) {
+ pwd = NULL;
+ strcpy(buff, d);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strcat(tried, d);
+ goto failure;
+ }
+
+ /* Get the current dir. */
+ pwd = getcwd(NULL, 0);
+ while (pwd[strlen(pwd) - 1] == '\n')
+ pwd[strlen(pwd) - 1] = '\0';
+ printf("PWD: %s\n", pwd);
+
+ /* Look for a known file. */
+ snprintf(buff, sizeof(buff), "%s", pwd);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ snprintf(buff, sizeof(buff), "%s/test", pwd);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+#if defined(LIBRARY)
+ snprintf(buff, sizeof(buff), "%s/%s/test", pwd, LIBRARY);
+#else
+ snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM);
+#endif
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ if (memcmp(pwd, "/usr/obj", 8) == 0) {
+ snprintf(buff, sizeof(buff), "%s", pwd + 8);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ snprintf(buff, sizeof(buff), "%s/test", pwd + 8);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+ }
+
+failure:
+#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
+ DebugBreak();
+#endif
+ printf("Unable to locate known reference file %s\n", KNOWNREF);
+ printf(" Checked following directories:\n%s\n", tried);
+ exit(1);
+
+success:
+ free(p);
+ free(pwd);
+ return strdup(buff);
+}
int main(int argc, char **argv)
{
static const int limit = sizeof(tests) / sizeof(tests[0]);
- int i, tests_run = 0, tests_failed = 0, opt;
+ int i, tests_run = 0, tests_failed = 0, option;
time_t now;
char *refdir_alloc = NULL;
#if defined(_WIN32) && !defined(__CYGWIN__)
char *testprg;
#endif
- const char *opt_arg, *progname, *p;
- char *tmp;
+ const char *progname;
+ const char *tmp, *option_arg, *p;
char tmpdir[256];
char tmpdir_timestamp[256];
(void)argc; /* UNUSED */
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
+ /* To stop to run the default invalid parameter handler. */
+ _set_invalid_parameter_handler(invalid_parameter_handler);
+ /* for open() to a binary mode. */
+ /* This shouldn't be needed, because all tests should
+ * explicitly use O_BINARY flag to open() and "b" to
+ * fopen(): */
+ /* _set_fmode(_O_BINARY); */
+ /* Disable annoying assertion message box. */
+ _CrtSetReportMode(_CRT_ASSERT, 0);
+#endif
+
/*
* Name of this program, used to build root of our temp directory
* tree.
p = *argv++;
++p; /* Skip '-' */
while (*p != '\0') {
- opt = *p++;
- opt_arg = NULL;
+ option = *p++;
+ option_arg = NULL;
/* If 'opt' takes an argument, parse that. */
- if (opt == 'p' || opt == 'r') {
+ if (option == 'p' || option == 'r') {
if (*p != '\0')
- opt_arg = p;
+ option_arg = p;
else if (*argv == NULL) {
fprintf(stderr,
"Option -%c requires argument.\n",
- opt);
+ option);
usage(progname);
} else
- opt_arg = *argv++;
+ option_arg = *argv++;
p = ""; /* End of this option word. */
}
/* Now, handle the option. */
- switch (opt) {
+ switch (option) {
case 'd':
dump_on_failure = 1;
break;
break;
case 'p':
#ifdef PROGRAM
- testprog = opt_arg;
+ testprog = option_arg;
#else
usage(progname);
#endif
quiet_flag++;
break;
case 'r':
- refdir = opt_arg;
+ refdir = option_arg;
break;
case 'v':
verbose = 1;
break;
- case '?':
default:
usage(progname);
}
/*
* If the user didn't specify a directory for locating
- * reference files, use the current directory for that.
+ * reference files, try to find the reference files in
+ * the "usual places."
*/
- if (refdir == NULL) {
- char *q;
- systemf("/bin/pwd > %s/refdir", tmpdir);
- q = slurpfile(NULL, "%s/refdir", tmpdir);
- refdir = refdir_alloc = q;
- q += strlen(refdir);
- while (q[-1] == '\n') {
- --q;
- *q = '\0';
- }
- systemf("rm %s/refdir", tmpdir);
- }
+ refdir = refdir_alloc = get_refdir(refdir);
/*
* Banner with basic information.
}
} else {
while (*(argv) != NULL) {
- i = atoi(*argv);
- if (**argv < '0' || **argv > '9' || i < 0 || i >= limit) {
- printf("*** INVALID Test %s\n", *argv);
- usage(progname);
+ if (**argv >= '0' && **argv <= '9') {
+ i = atoi(*argv);
+ if (i < 0 || i >= limit) {
+ printf("*** INVALID Test %s\n", *argv);
+ free(refdir_alloc);
+ usage(progname);
+ /* usage() never returns */
+ }
} else {
- if (test_run(i, tmpdir))
- tests_failed++;
- tests_run++;
+ for (i = 0; i < limit; ++i) {
+ if (strcmp(*argv, tests[i].name) == 0)
+ break;
+ }
+ if (i >= limit) {
+ printf("*** INVALID Test ``%s''\n",
+ *argv);
+ free(refdir_alloc);
+ usage(progname);
+ /* usage() never returns */
+ }
}
+ if (test_run(i, tmpdir))
+ tests_failed++;
+ tests_run++;
argv++;
}
}
tests_failed, tests_run);
printf(" Total of %d assertions checked.\n", assertions);
printf(" Total of %d assertions failed.\n", failures);
- printf(" Total of %d assertions skipped.\n", skips);
+ printf(" Total of %d reported skips.\n", skips);
}
free(refdir_alloc);