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.
11 SM_IDSTR(id
, "@(#)$Id: t-exc.c,v 1.20 2001/09/11 04:04:49 gshapiro Exp $")
18 const SM_EXC_TYPE_T EtypeTest1
=
24 "test1 exception argv[0]=%0",
27 const SM_EXC_TYPE_T EtypeTest2
=
33 "test2 exception argv[0]=%0",
45 sm_test_begin(argc
, argv
, "test exception handling");
51 cant
= "can't happen";
78 sm_exc_raisenew_x(&EtypeTest1
, 17);
81 sm_exc_raisenew_x(&EtypeTest2
, 42);
83 SM_EXCEPT(exc
, "E:test2")
84 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
85 "got exception test2: can't happen\n");
86 SM_EXCEPT(exc
, "E:test1")
87 SM_TEST(x
== 2 && exc
->exc_argv
[0].v_int
== 17);
88 if (!(x
== 2 && exc
->exc_argv
[0].v_int
== 17))
90 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
91 "can't happen: x=%d argv[0]=%d\n",
92 x
, exc
->exc_argv
[0].v_int
);
96 unknown
= "unknown exception: ";
97 SM_TEST(strcmp(unknown
, cant
) == 0);
104 sm_exc_raisenew_x(&EtypeTest1
, 94);
107 sm_exc_raisenew_x(&EtypeTest2
, 95);
108 SM_EXCEPT(exc
, "E:test2")
110 unknown
= "got exception test2: ";
111 SM_TEST(strcmp(unknown
, cant
) == 0);
113 SM_EXCEPT(exc
, "E:test1")
114 SM_TEST(x
== 5 && exc
->exc_argv
[0].v_int
== 94);
115 if (!(x
== 5 && exc
->exc_argv
[0].v_int
== 94))
117 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
118 "can't happen: x=%d argv[0]=%d\n",
119 x
, exc
->exc_argv
[0].v_int
);
123 unknown
= "unknown exception: ";
124 SM_TEST(strcmp(unknown
, cant
) == 0);
129 sm_exc_raisenew_x(&SmEtypeErr
, "test %d", 0);
132 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
133 "test 0 got an exception, as expected:\n");
134 sm_exc_print(exc
, smioout
);
136 return sm_test_end();
139 p
= sm_malloc_x((size_t)(-1));
140 (void) sm_io_fprintf(smioout
, SM_TIME_DEFAULT
,
141 "sm_malloc_x unexpectedly succeeded, returning %p\n", p
);
142 unknown
= "sm_malloc_x unexpectedly succeeded";
143 SM_TEST(strcmp(unknown
, cant
) == 0);
144 return sm_test_end();