2 * Copyright (c) 2000-2002 Sendmail, 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.
10 #pragma ident "%Z%%M% %I% %E% SMI"
13 SM_IDSTR(Id
, "@(#)$Id: test.c,v 1.16 2002/01/08 17:54:40 ca Exp $")
16 ** Abstractions for writing libsm test programs.
34 static char Help
[] = "\
35 %s [-h] [-d debugging] [-v]\n\
39 -h Display this help information.\n\
40 -d debugging Set debug activation levels.\n\
44 static char Usage
[] = "\
45 Usage: %s [-h] [-v]\n\
46 Use %s -h for help.\n\
50 ** SM_TEST_BEGIN -- initialize test system.
53 ** argc -- argument counter.
54 ** argv -- argument vector.
55 ** testname -- description of tests.
62 sm_test_begin(argc
, argv
, testname
)
71 SmTestVerbose
= false;
74 while ((c
= getopt(argc
, argv
, "vhd:")) != -1)
82 sm_debug_addsettings_x(optarg
);
85 (void) fprintf(stdout
, Help
, argv
[0], testname
);
88 (void) fprintf(stderr
,
89 "Unknown command line option -%c\n",
91 (void) fprintf(stderr
, Usage
, argv
[0], argv
[0]);
98 ** SM_TEST -- single test.
101 ** success -- did test succeeed?
102 ** expr -- expression that has been evaluated.
103 ** filename -- guess...
104 ** lineno -- line number.
111 sm_test(success
, expr
, filename
, lineno
)
119 (void) fprintf(stderr
, "%d..", SmTestIndex
);
124 (void) fprintf(stderr
, "%d..", SmTestIndex
);
125 (void) fprintf(stderr
, "bad! %s:%d %s\n", filename
, lineno
,
131 (void) fprintf(stderr
, "ok\n");
137 ** SM_TEST_END -- end of test system.
149 (void) fprintf(stderr
, "%d of %d tests completed successfully\n",
150 SmTestIndex
- SmTestNumErrors
, SmTestIndex
);
151 if (SmTestNumErrors
!= 0)
152 (void) fprintf(stderr
, "*** %d error%s in test! ***\n",
154 SmTestNumErrors
> 1 ? "s" : "");
156 return SmTestNumErrors
;