2 * Copyright (c) 2000-2001 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: t-exc.c,v 1.18 2001/07/05 22:46:35 gshapiro Exp $")
20 const SM_EXC_TYPE_T EtypeTest1
=
26 "test1 exception argv[0]=%0",
29 const SM_EXC_TYPE_T EtypeTest2
=
35 "test2 exception argv[0]=%0",
47 sm_test_begin(argc
, argv
, "test exception handling");
53 cant
= "can't happen";
80 sm_exc_raisenew_x(&EtypeTest1
, 17);
83 sm_exc_raisenew_x(&EtypeTest2
, 42);
85 SM_EXCEPT(exc
, "E:test2")
86 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
87 "got exception test2: can't happen\n");
88 SM_EXCEPT(exc
, "E:test1")
89 SM_TEST(x
== 2 && exc
->exc_argv
[0].v_int
== 17);
90 if (!(x
== 2 && exc
->exc_argv
[0].v_int
== 17))
92 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
93 "can't happen: x=%d argv[0]=%d\n",
94 x
, exc
->exc_argv
[0].v_int
);
98 unknown
= "unknown exception: ";
99 SM_TEST(strcmp(unknown
, cant
) == 0);
106 sm_exc_raisenew_x(&EtypeTest1
, 94);
109 sm_exc_raisenew_x(&EtypeTest2
, 95);
110 SM_EXCEPT(exc
, "E:test2")
112 unknown
= "got exception test2: ";
113 SM_TEST(strcmp(unknown
, cant
) == 0);
115 SM_EXCEPT(exc
, "E:test1")
116 SM_TEST(x
== 5 && exc
->exc_argv
[0].v_int
== 94);
117 if (!(x
== 5 && exc
->exc_argv
[0].v_int
== 94))
119 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
120 "can't happen: x=%d argv[0]=%d\n",
121 x
, exc
->exc_argv
[0].v_int
);
125 unknown
= "unknown exception: ";
126 SM_TEST(strcmp(unknown
, cant
) == 0);
131 sm_exc_raisenew_x(&SmEtypeErr
, "test %d", 0);
134 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
135 "test 0 got an exception, as expected:\n");
136 sm_exc_print(exc
, smioout
);
138 return sm_test_end();
141 p
= sm_malloc_x((size_t)(-1));
142 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
143 "sm_malloc_x unexpectedly succeeded, returning %p\n", p
);
144 unknown
= "sm_malloc_x unexpectedly succeeded";
145 SM_TEST(strcmp(unknown
, cant
) == 0);
146 return sm_test_end();