]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libarchive/test/test.h
This commit was generated by cvs2svn to compensate for changes in r168433,
[FreeBSD/FreeBSD.git] / lib / libarchive / test / test.h
1 /*
2  * Copyright (c) 2003-2006 Tim Kientzle
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  */
27
28 /* Every test program should #include "test.h" as the first thing. */
29
30 /*
31  * The goal of this file (and the matching test.c) is to
32  * simplify the very repetitive test-*.c test programs.
33  */
34
35 #define _FILE_OFFSET_BITS 64
36
37 #include <archive.h>
38 #include <archive_entry.h>
39 #include <fcntl.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <sys/stat.h>
44
45 #if defined(HAVE_CONFIG_H)
46 /* Most POSIX platforms use the 'configure' script to build config.h */
47 #include "../../config.h"
48 #elif defined(__FreeBSD__)
49 /* Building as part of FreeBSD system requires a pre-built config.h. */
50 #include "../config_freebsd.h"
51 #elif defined(_WIN32)
52 /* Win32 can't run the 'configure' script. */
53 #include "../config_windows.h"
54 #else
55 /* Warn if the library hasn't been (automatically or manually) configured. */
56 #error Oops: No config.h and no pre-built configuration in test.h.
57 #endif
58
59 /* No non-FreeBSD platform will have __FBSDID, so just define it here. */
60 #ifdef __FreeBSD__
61 #include <sys/cdefs.h>  /* For __FBSDID */
62 #else
63 #define __FBSDID(a)     /* null */
64 #endif
65
66 /*
67  * "list.h" is simply created by "grep DEFINE_TEST"; it has
68  * a line like
69  *      DEFINE_TEST(test_function)
70  * for each test.
71  * Include it here with a suitable DEFINE_TEST to declare all of the
72  * test functions.
73  */
74 #define DEFINE_TEST(name) void name(void);
75 #include "list.h"
76 /*
77  * Redefine DEFINE_TEST for use in defining the test functions.
78  */
79 #undef DEFINE_TEST
80 #define DEFINE_TEST(name) void name(void)
81
82 /* An implementation of the standard assert() macro */
83 #define assert(e)   test_assert(__FILE__, __LINE__, (e), #e, NULL)
84 /* As above, but reports any archive_error found in variable 'a' */
85 #define assertA(e)   test_assert(__FILE__, __LINE__, (e), #e, (a))
86 /* Asserts that two values are the same.  Reports value of each one if not. */
87 #define assertEqualIntA(a,v1,v2)   \
88   test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
89 /* Asserts that two values are the same.  Reports value of each one if not. */
90 #define assertEqualInt(v1,v2)   \
91   test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
92
93 /* Function declarations.  These are defined in test_utility.c. */
94 void failure(const char *fmt, ...);
95 void test_assert(const char *, int, int, const char *, struct archive *);
96 void test_assert_equal_int(const char *, int, int, const char *, int, const char *, struct archive *);
97