2 * Copyright (c) 2000-2002 Proofpoint, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
11 SM_IDSTR(Id, "@(#)$Id: test.c,v 1.17 2013-11-22 20:51:44 ca Exp $")
14 ** Abstractions for writing libsm test programs.
32 static char Help[] = "\
33 %s [-h] [-d debugging] [-v]\n\
37 -h Display this help information.\n\
38 -d debugging Set debug activation levels.\n\
42 static char Usage[] = "\
43 Usage: %s [-h] [-v]\n\
44 Use %s -h for help.\n\
48 ** SM_TEST_BEGIN -- initialize test system.
51 ** argc -- argument counter.
52 ** argv -- argument vector.
53 ** testname -- description of tests.
60 sm_test_begin(argc, argv, testname)
69 SmTestVerbose = false;
72 while ((c = getopt(argc, argv, "vhd:")) != -1)
80 sm_debug_addsettings_x(optarg);
83 (void) fprintf(stdout, Help, argv[0], testname);
86 (void) fprintf(stderr,
87 "Unknown command line option -%c\n",
89 (void) fprintf(stderr, Usage, argv[0], argv[0]);
96 ** SM_TEST -- single test.
99 ** success -- did test succeeed?
100 ** expr -- expression that has been evaluated.
101 ** filename -- guess...
102 ** lineno -- line number.
109 sm_test(success, expr, filename, lineno)
117 (void) fprintf(stderr, "%d..", SmTestIndex);
122 (void) fprintf(stderr, "%d..", SmTestIndex);
123 (void) fprintf(stderr, "bad! %s:%d %s\n", filename, lineno,
129 (void) fprintf(stderr, "ok\n");
135 ** SM_TEST_END -- end of test system.
147 (void) fprintf(stderr, "%d of %d tests completed successfully\n",
148 SmTestIndex - SmTestNumErrors, SmTestIndex);
149 if (SmTestNumErrors != 0)
150 (void) fprintf(stderr, "*** %d error%s in test! ***\n",
152 SmTestNumErrors > 1 ? "s" : "");
154 return SmTestNumErrors;