1344500Sdes/*-
2344500Sdes * Copyright (c) 2019 Dag-Erling Sm��rgrav
3344500Sdes * All rights reserved.
4344500Sdes *
5344500Sdes * Redistribution and use in source and binary forms, with or without
6344500Sdes * modification, are permitted provided that the following conditions
7344500Sdes * are met:
8344500Sdes * 1. Redistributions of source code must retain the above copyright
9344500Sdes *    notice, this list of conditions and the following disclaimer.
10344500Sdes * 2. Redistributions in binary form must reproduce the above copyright
11344500Sdes *    notice, this list of conditions and the following disclaimer in the
12344500Sdes *    documentation and/or other materials provided with the distribution.
13344500Sdes * 3. The name of the author may not be used to endorse or promote
14344500Sdes *    products derived from this software without specific prior written
15344500Sdes *    permission.
16344500Sdes *
17344500Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18344500Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19344500Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20344500Sdes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21344500Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22344500Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23344500Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24344500Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25344500Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26344500Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27344500Sdes * SUCH DAMAGE.
28344500Sdes *
29344500Sdes * $OpenPAM$
30344500Sdes */
31344500Sdes
32344500Sdes#ifdef HAVE_CONFIG_H
33344500Sdes# include "config.h"
34344500Sdes#endif
35344500Sdes
36344500Sdes#include <stdint.h>
37344500Sdes#include <unistd.h>
38344500Sdes
39344500Sdes#include <cryb/test.h>
40344500Sdes
41344500Sdes#include <security/pam_appl.h>
42344500Sdes#include <security/openpam.h>
43344500Sdes
44344500Sdes#include "openpam_impl.h"
45344500Sdes
46344500Sdes#include "t_pam_err.h"
47344500Sdes
48344500Sdesint
49344500Sdest_compare_pam_err(int expected, int received)
50344500Sdes{
51344500Sdes
52344500Sdes	if (expected == received)
53344500Sdes		return (1);
54344500Sdes	if (expected >= 0 && expected < PAM_NUM_ERRORS)
55344500Sdes		t_printv("expected %s, ", pam_err_name[expected]);
56344500Sdes	else
57344500Sdes		t_printv("expected %d, ", expected);
58344500Sdes	if (received >= 0 && received < PAM_NUM_ERRORS)
59344500Sdes		t_printv("received %s\n", pam_err_name[received]);
60344500Sdes	else
61344500Sdes		t_printv("received %d\n", received);
62344500Sdes	return (0);
63344500Sdes}
64