xref: /freebsd/crypto/krb5/src/lib/krad/t_test.c (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2*7f2fe78bSCy Schubert /* lib/krad/t_test.c - Utility functions for libkrad tests */
3*7f2fe78bSCy Schubert /*
4*7f2fe78bSCy Schubert  * Copyright 2013 Red Hat, Inc.  All rights reserved.
5*7f2fe78bSCy Schubert  *
6*7f2fe78bSCy Schubert  * Redistribution and use in source and binary forms, with or without
7*7f2fe78bSCy Schubert  * modification, are permitted provided that the following conditions are met:
8*7f2fe78bSCy Schubert  *
9*7f2fe78bSCy Schubert  *    1. Redistributions of source code must retain the above copyright
10*7f2fe78bSCy Schubert  *       notice, this list of conditions and the following disclaimer.
11*7f2fe78bSCy Schubert  *
12*7f2fe78bSCy Schubert  *    2. Redistributions in binary form must reproduce the above copyright
13*7f2fe78bSCy Schubert  *       notice, this list of conditions and the following disclaimer in
14*7f2fe78bSCy Schubert  *       the documentation and/or other materials provided with the
15*7f2fe78bSCy Schubert  *       distribution.
16*7f2fe78bSCy Schubert  *
17*7f2fe78bSCy Schubert  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18*7f2fe78bSCy Schubert  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19*7f2fe78bSCy Schubert  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20*7f2fe78bSCy Schubert  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21*7f2fe78bSCy Schubert  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22*7f2fe78bSCy Schubert  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23*7f2fe78bSCy Schubert  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24*7f2fe78bSCy Schubert  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25*7f2fe78bSCy Schubert  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26*7f2fe78bSCy Schubert  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27*7f2fe78bSCy Schubert  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*7f2fe78bSCy Schubert  */
29*7f2fe78bSCy Schubert 
30*7f2fe78bSCy Schubert #include "t_test.h"
31*7f2fe78bSCy Schubert 
32*7f2fe78bSCy Schubert void
noerror_impl(const char * file,int line,const char * cmd,int retval)33*7f2fe78bSCy Schubert noerror_impl(const char *file, int line, const char *cmd, int retval)
34*7f2fe78bSCy Schubert {
35*7f2fe78bSCy Schubert     if (retval == 0)
36*7f2fe78bSCy Schubert         return;
37*7f2fe78bSCy Schubert 
38*7f2fe78bSCy Schubert     fprintf(stderr, "%s:%d: %s:\n\t%s\n", file, line, strerror(retval), cmd);
39*7f2fe78bSCy Schubert     exit(1);
40*7f2fe78bSCy Schubert }
41*7f2fe78bSCy Schubert 
42*7f2fe78bSCy Schubert void
insist_impl(const char * file,int line,const char * cmd,krb5_boolean result)43*7f2fe78bSCy Schubert insist_impl(const char *file, int line, const char *cmd, krb5_boolean result)
44*7f2fe78bSCy Schubert {
45*7f2fe78bSCy Schubert     if (result)
46*7f2fe78bSCy Schubert         return;
47*7f2fe78bSCy Schubert 
48*7f2fe78bSCy Schubert     fprintf(stderr, "%s:%d: insist failed:\n\t%s\n", file, line, cmd);
49*7f2fe78bSCy Schubert     exit(1);
50*7f2fe78bSCy Schubert }
51