Blame test_utils/test_common.h

Packit Service 1d0348
/*
Packit Service 1d0348
 * Copyright (c) 2003-2017 Tim Kientzle
Packit Service 1d0348
 * All rights reserved.
Packit Service 1d0348
 *
Packit Service 1d0348
 * Redistribution and use in source and binary forms, with or without
Packit Service 1d0348
 * modification, are permitted provided that the following conditions
Packit Service 1d0348
 * are met:
Packit Service 1d0348
 * 1. Redistributions of source code must retain the above copyright
Packit Service 1d0348
 *    notice, this list of conditions and the following disclaimer.
Packit Service 1d0348
 * 2. Redistributions in binary form must reproduce the above copyright
Packit Service 1d0348
 *    notice, this list of conditions and the following disclaimer in the
Packit Service 1d0348
 *    documentation and/or other materials provided with the distribution.
Packit Service 1d0348
 *
Packit Service 1d0348
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
Packit Service 1d0348
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Packit Service 1d0348
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Packit Service 1d0348
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit Service 1d0348
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Packit Service 1d0348
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit Service 1d0348
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit Service 1d0348
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit Service 1d0348
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Packit Service 1d0348
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit Service 1d0348
 *
Packit Service 1d0348
 * $FreeBSD$
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
#ifndef	TEST_COMMON_H
Packit Service 1d0348
#define	TEST_COMMON_H
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * The goal of this file (and the matching test.c) is to
Packit Service 1d0348
 * simplify the very repetitive test-*.c test programs.
Packit Service 1d0348
 */
Packit Service 1d0348
#if defined(HAVE_CONFIG_H)
Packit Service 1d0348
/* Most POSIX platforms use the 'configure' script to build config.h */
Packit Service 1d0348
#include "config.h"
Packit Service 1d0348
#elif defined(__FreeBSD__)
Packit Service 1d0348
/* Building as part of FreeBSD system requires a pre-built config.h. */
Packit Service 1d0348
#include "config_freebsd.h"
Packit Service 1d0348
#elif defined(_WIN32) && !defined(__CYGWIN__)
Packit Service 1d0348
/* Win32 can't run the 'configure' script. */
Packit Service 1d0348
#include "config_windows.h"
Packit Service 1d0348
#else
Packit Service 1d0348
/* Warn if the library hasn't been (automatically or manually) configured. */
Packit Service 1d0348
#error Oops: No config.h and no pre-built configuration in test.h.
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#include <sys/types.h>  /* Windows requires this before sys/stat.h */
Packit Service 1d0348
#include <sys/stat.h>
Packit Service 1d0348
Packit Service 1d0348
#if HAVE_DIRENT_H
Packit Service 1d0348
#include <dirent.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_DIRECT_H
Packit Service 1d0348
#include <direct.h>
Packit Service 1d0348
#define dirent direct
Packit Service 1d0348
#endif
Packit Service 1d0348
#include <errno.h>
Packit Service 1d0348
#include <fcntl.h>
Packit Service 1d0348
#ifdef HAVE_IO_H
Packit Service 1d0348
#include <io.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_STDINT_H
Packit Service 1d0348
#include <stdint.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#include <stdio.h>
Packit Service 1d0348
#include <stdlib.h>
Packit Service 1d0348
#include <string.h>
Packit Service 1d0348
#include <ctype.h>
Packit Service 1d0348
#include <time.h>
Packit Service 1d0348
#ifdef HAVE_UNISTD_H
Packit Service 1d0348
#include <unistd.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#include <wchar.h>
Packit Service 1d0348
#ifdef HAVE_ACL_LIBACL_H
Packit Service 1d0348
#include <acl/libacl.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_SYS_ACL_H
Packit Service 1d0348
#include <sys/acl.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_SYS_RICHACL_H
Packit Service 1d0348
#include <sys/richacl.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
#ifdef HAVE_WINDOWS_H
Packit Service 1d0348
#include <windows.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * System-specific tweaks.  We really want to minimize these
Packit Service 1d0348
 * as much as possible, since they make it harder to understand
Packit Service 1d0348
 * the mainline code.
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
/* Windows (including Visual Studio and MinGW but not Cygwin) */
Packit Service 1d0348
#if defined(_WIN32) && !defined(__CYGWIN__)
Packit Service 1d0348
#if !defined(__BORLANDC__)
Packit Service 1d0348
#undef chdir
Packit Service 1d0348
#define chdir _chdir
Packit Service 1d0348
#define strdup _strdup
Packit Service 1d0348
#endif
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Visual Studio */
Packit Service 1d0348
#if defined(_MSC_VER) && _MSC_VER < 1900
Packit Service 1d0348
#define snprintf	sprintf_s
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#if defined(__BORLANDC__)
Packit Service 1d0348
#pragma warn -8068	/* Constant out of range in comparison. */
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Haiku OS and QNX */
Packit Service 1d0348
#if defined(__HAIKU__) || defined(__QNXNTO__)
Packit Service 1d0348
/* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */
Packit Service 1d0348
#include <stdint.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Get a real definition for __FBSDID if we can */
Packit Service 1d0348
#if HAVE_SYS_CDEFS_H
Packit Service 1d0348
#include <sys/cdefs.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* If not, define it so as to avoid dangling semicolons. */
Packit Service 1d0348
#ifndef __FBSDID
Packit Service 1d0348
#define	__FBSDID(a)     struct _undefined_hack
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#ifndef O_BINARY
Packit Service 1d0348
#define	O_BINARY 0
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#include "archive_platform_acl.h"
Packit Service 1d0348
#define	ARCHIVE_TEST_ACL_TYPE_POSIX1E	1
Packit Service 1d0348
#define	ARCHIVE_TEST_ACL_TYPE_NFS4	2
Packit Service 1d0348
Packit Service 1d0348
#include "archive_platform_xattr.h"
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * Redefine DEFINE_TEST for use in defining the test functions.
Packit Service 1d0348
 */
Packit Service 1d0348
#undef DEFINE_TEST
Packit Service 1d0348
#define DEFINE_TEST(name) void name(void); void name(void)
Packit Service 1d0348
Packit Service 1d0348
/* An implementation of the standard assert() macro */
Packit Service 1d0348
#define assert(e)   assertion_assert(__FILE__, __LINE__, (e), #e, NULL)
Packit Service 1d0348
/* chdir() and error if it fails */
Packit Service 1d0348
#define assertChdir(path)  \
Packit Service 1d0348
  assertion_chdir(__FILE__, __LINE__, path)
Packit Service 1d0348
/* Assert two files have the same file flags */
Packit Service 1d0348
#define assertEqualFflags(patha, pathb)	\
Packit Service 1d0348
  assertion_compare_fflags(__FILE__, __LINE__, patha, pathb, 0)
Packit Service 1d0348
/* Assert two integers are the same.  Reports value of each one if not. */
Packit Service 1d0348
#define assertEqualInt(v1,v2) \
Packit Service 1d0348
  assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
Packit Service 1d0348
/* Assert two strings are the same.  Reports value of each one if not. */
Packit Service 1d0348
#define assertEqualString(v1,v2)   \
Packit Service 1d0348
  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 0)
Packit Service 1d0348
#define assertEqualUTF8String(v1,v2)   \
Packit Service 1d0348
  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL, 1)
Packit Service 1d0348
/* As above, but v1 and v2 are wchar_t * */
Packit Service 1d0348
#define assertEqualWString(v1,v2)   \
Packit Service 1d0348
  assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
Packit Service 1d0348
/* As above, but raw blocks of bytes. */
Packit Service 1d0348
#define assertEqualMem(v1, v2, l)	\
Packit Service 1d0348
  assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
Packit Service 1d0348
/* Assert that memory is full of a specified byte */
Packit Service 1d0348
#define assertMemoryFilledWith(v1, l, b)					\
Packit Service 1d0348
  assertion_memory_filled_with(__FILE__, __LINE__, (v1), #v1, (l), #l, (b), #b, NULL)
Packit Service 1d0348
/* Assert two files are the same. */
Packit Service 1d0348
#define assertEqualFile(f1, f2)	\
Packit Service 1d0348
  assertion_equal_file(__FILE__, __LINE__, (f1), (f2))
Packit Service 1d0348
/* Assert that a file is empty. */
Packit Service 1d0348
#define assertEmptyFile(pathname)	\
Packit Service 1d0348
  assertion_empty_file(__FILE__, __LINE__, (pathname))
Packit Service 1d0348
/* Assert that a file is not empty. */
Packit Service 1d0348
#define assertNonEmptyFile(pathname)		\
Packit Service 1d0348
  assertion_non_empty_file(__FILE__, __LINE__, (pathname))
Packit Service 1d0348
#define assertFileAtime(pathname, sec, nsec)	\
Packit Service 1d0348
  assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
Packit Service 1d0348
#define assertFileAtimeRecent(pathname)	\
Packit Service 1d0348
  assertion_file_atime_recent(__FILE__, __LINE__, pathname)
Packit Service 1d0348
#define assertFileBirthtime(pathname, sec, nsec)	\
Packit Service 1d0348
  assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec)
Packit Service 1d0348
#define assertFileBirthtimeRecent(pathname) \
Packit Service 1d0348
  assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
Packit Service 1d0348
/* Assert that a file exists; supports printf-style arguments. */
Packit Service 1d0348
#define assertFileExists(pathname) \
Packit Service 1d0348
  assertion_file_exists(__FILE__, __LINE__, pathname)
Packit Service 1d0348
/* Assert that a file exists. */
Packit Service 1d0348
#define assertFileNotExists(pathname) \
Packit Service 1d0348
  assertion_file_not_exists(__FILE__, __LINE__, pathname)
Packit Service 1d0348
/* Assert that file contents match a string. */
Packit Service 1d0348
#define assertFileContents(data, data_size, pathname) \
Packit Service 1d0348
  assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
Packit Service 1d0348
/* Verify that a file does not contain invalid strings */
Packit Service 1d0348
#define assertFileContainsNoInvalidStrings(pathname, strings) \
Packit Service 1d0348
  assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
Packit Service 1d0348
#define assertFileMtime(pathname, sec, nsec)	\
Packit Service 1d0348
  assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
Packit Service 1d0348
#define assertFileMtimeRecent(pathname) \
Packit Service 1d0348
  assertion_file_mtime_recent(__FILE__, __LINE__, pathname)
Packit Service 1d0348
#define assertFileNLinks(pathname, nlinks)  \
Packit Service 1d0348
  assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
Packit Service 1d0348
#define assertFileSize(pathname, size)  \
Packit Service 1d0348
  assertion_file_size(__FILE__, __LINE__, pathname, size)
Packit Service 1d0348
#define assertFileMode(pathname, mode)  \
Packit Service 1d0348
  assertion_file_mode(__FILE__, __LINE__, pathname, mode)
Packit Service 1d0348
#define assertTextFileContents(text, pathname) \
Packit Service 1d0348
  assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
Packit Service 1d0348
#define assertFileContainsLinesAnyOrder(pathname, lines)	\
Packit Service 1d0348
  assertion_file_contains_lines_any_order(__FILE__, __LINE__, pathname, lines)
Packit Service 1d0348
#define assertIsDir(pathname, mode)		\
Packit Service 1d0348
  assertion_is_dir(__FILE__, __LINE__, pathname, mode)
Packit Service 1d0348
#define assertIsHardlink(path1, path2)	\
Packit Service 1d0348
  assertion_is_hardlink(__FILE__, __LINE__, path1, path2)
Packit Service 1d0348
#define assertIsNotHardlink(path1, path2)	\
Packit Service 1d0348
  assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2)
Packit Service 1d0348
#define assertIsReg(pathname, mode)		\
Packit Service 1d0348
  assertion_is_reg(__FILE__, __LINE__, pathname, mode)
Packit Service 1d0348
#define assertIsSymlink(pathname, contents)	\
Packit Service 1d0348
  assertion_is_symlink(__FILE__, __LINE__, pathname, contents)
Packit Service 1d0348
/* Create a directory, report error if it fails. */
Packit Service 1d0348
#define assertMakeDir(dirname, mode)	\
Packit Service 1d0348
  assertion_make_dir(__FILE__, __LINE__, dirname, mode)
Packit Service 1d0348
#define assertMakeFile(path, mode, contents) \
Packit Service 1d0348
  assertion_make_file(__FILE__, __LINE__, path, mode, -1, contents)
Packit Service 1d0348
#define assertMakeBinFile(path, mode, csize, contents) \
Packit Service 1d0348
  assertion_make_file(__FILE__, __LINE__, path, mode, csize, contents)
Packit Service 1d0348
#define assertMakeHardlink(newfile, oldfile)	\
Packit Service 1d0348
  assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
Packit Service 1d0348
#define assertMakeSymlink(newfile, linkto)	\
Packit Service 1d0348
  assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
Packit Service 1d0348
#define assertSetNodump(path)	\
Packit Service 1d0348
  assertion_set_nodump(__FILE__, __LINE__, path)
Packit Service 1d0348
#define assertUmask(mask)	\
Packit Service 1d0348
  assertion_umask(__FILE__, __LINE__, mask)
Packit Service 1d0348
/* Assert that two files have unequal file flags */
Packit Service 1d0348
#define assertUnequalFflags(patha, pathb)	\
Packit Service 1d0348
  assertion_compare_fflags(__FILE__, __LINE__, patha, pathb, 1)
Packit Service 1d0348
#define assertUtimes(pathname, atime, atime_nsec, mtime, mtime_nsec)	\
Packit Service 1d0348
  assertion_utimes(__FILE__, __LINE__, pathname, atime, atime_nsec, mtime, mtime_nsec)
Packit Service 1d0348
#ifndef PROGRAM
Packit Service 1d0348
#define assertEntrySetAcls(entry, acls, count) \
Packit Service 1d0348
  assertion_entry_set_acls(__FILE__, __LINE__, entry, acls, count)
Packit Service 1d0348
#define assertEntryCompareAcls(entry, acls, count, type, mode) \
Packit Service 1d0348
  assertion_entry_compare_acls(__FILE__, __LINE__, entry, acls, count, type, mode)
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/*
Packit Service 1d0348
 * This would be simple with C99 variadic macros, but I don't want to
Packit Service 1d0348
 * require that.  Instead, I insert a function call before each
Packit Service 1d0348
 * skipping() call to pass the file and line information down.  Crude,
Packit Service 1d0348
 * but effective.
Packit Service 1d0348
 */
Packit Service 1d0348
#define skipping	\
Packit Service 1d0348
  skipping_setup(__FILE__, __LINE__);test_skipping
Packit Service 1d0348
Packit Service 1d0348
/* Function declarations.  These are defined in test_utility.c. */
Packit Service 1d0348
void failure(const char *fmt, ...);
Packit Service 1d0348
int assertion_assert(const char *, int, int, const char *, void *);
Packit Service 1d0348
int assertion_chdir(const char *, int, const char *);
Packit Service 1d0348
int assertion_compare_fflags(const char *, int, const char *, const char *,
Packit Service 1d0348
    int);
Packit Service 1d0348
int assertion_empty_file(const char *, int, const char *);
Packit Service 1d0348
int assertion_equal_file(const char *, int, const char *, const char *);
Packit Service 1d0348
int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
Packit Service 1d0348
int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
Packit Service 1d0348
int assertion_memory_filled_with(const char *, int, const void *, const char *, size_t, const char *, char, const char *, void *);
Packit Service 1d0348
int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *, int);
Packit Service 1d0348
int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
Packit Service 1d0348
int assertion_file_atime(const char *, int, const char *, long, long);
Packit Service 1d0348
int assertion_file_atime_recent(const char *, int, const char *);
Packit Service 1d0348
int assertion_file_birthtime(const char *, int, const char *, long, long);
Packit Service 1d0348
int assertion_file_birthtime_recent(const char *, int, const char *);
Packit Service 1d0348
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
Packit Service 1d0348
int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
Packit Service 1d0348
int assertion_file_contents(const char *, int, const void *, int, const char *);
Packit Service 1d0348
int assertion_file_exists(const char *, int, const char *);
Packit Service 1d0348
int assertion_file_mode(const char *, int, const char *, int);
Packit Service 1d0348
int assertion_file_mtime(const char *, int, const char *, long, long);
Packit Service 1d0348
int assertion_file_mtime_recent(const char *, int, const char *);
Packit Service 1d0348
int assertion_file_nlinks(const char *, int, const char *, int);
Packit Service 1d0348
int assertion_file_not_exists(const char *, int, const char *);
Packit Service 1d0348
int assertion_file_size(const char *, int, const char *, long);
Packit Service 1d0348
int assertion_is_dir(const char *, int, const char *, int);
Packit Service 1d0348
int assertion_is_hardlink(const char *, int, const char *, const char *);
Packit Service 1d0348
int assertion_is_not_hardlink(const char *, int, const char *, const char *);
Packit Service 1d0348
int assertion_is_reg(const char *, int, const char *, int);
Packit Service 1d0348
int assertion_is_symlink(const char *, int, const char *, const char *);
Packit Service 1d0348
int assertion_make_dir(const char *, int, const char *, int);
Packit Service 1d0348
int assertion_make_file(const char *, int, const char *, int, int, const void *);
Packit Service 1d0348
int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
Packit Service 1d0348
int assertion_make_symlink(const char *, int, const char *newpath, const char *);
Packit Service 1d0348
int assertion_non_empty_file(const char *, int, const char *);
Packit Service 1d0348
int assertion_set_nodump(const char *, int, const char *);
Packit Service 1d0348
int assertion_text_file_contents(const char *, int, const char *buff, const char *f);
Packit Service 1d0348
int assertion_umask(const char *, int, int);
Packit Service 1d0348
int assertion_utimes(const char *, int, const char *, long, long, long, long );
Packit Service 1d0348
int assertion_version(const char*, int, const char *, const char *);
Packit Service 1d0348
Packit Service 1d0348
void skipping_setup(const char *, int);
Packit Service 1d0348
void test_skipping(const char *fmt, ...);
Packit Service 1d0348
Packit Service 1d0348
/* Like sprintf, then system() */
Packit Service 1d0348
int systemf(const char * fmt, ...);
Packit Service 1d0348
Packit Service 1d0348
/* Delay until time() returns a value after this. */
Packit Service 1d0348
void sleepUntilAfter(time_t);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can create symlinks. */
Packit Service 1d0348
int canSymlink(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "bzip2" program. */
Packit Service 1d0348
int canBzip2(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "grzip" program. */
Packit Service 1d0348
int canGrzip(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "gzip" program. */
Packit Service 1d0348
int canGzip(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the specified command. */
Packit Service 1d0348
int canRunCommand(const char *);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "lrzip" program. */
Packit Service 1d0348
int canLrzip(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "lz4" program. */
Packit Service 1d0348
int canLz4(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "zstd" program. */
Packit Service 1d0348
int canZstd(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "lzip" program. */
Packit Service 1d0348
int canLzip(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "lzma" program. */
Packit Service 1d0348
int canLzma(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "lzop" program. */
Packit Service 1d0348
int canLzop(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this platform can run the "xz" program. */
Packit Service 1d0348
int canXz(void);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if this filesystem can handle nodump flags. */
Packit Service 1d0348
int canNodump(void);
Packit Service 1d0348
Packit Service 1d0348
/* Set test ACLs */
Packit Service 1d0348
int setTestAcl(const char *path);
Packit Service 1d0348
Packit Service 1d0348
/* Get extended attribute */
Packit Service 1d0348
void *getXattr(const char *, const char *, size_t *);
Packit Service 1d0348
Packit Service 1d0348
/* Set extended attribute */
Packit Service 1d0348
int setXattr(const char *, const char *, const void *, size_t);
Packit Service 1d0348
Packit Service 1d0348
/* Return true if the file has large i-node number(>0xffffffff). */
Packit Service 1d0348
int is_LargeInode(const char *);
Packit Service 1d0348
Packit Service 1d0348
#if ARCHIVE_ACL_SUNOS
Packit Service 1d0348
/* Fetch ACLs on Solaris using acl() or facl() */
Packit Service 1d0348
void *sunacl_get(int cmd, int *aclcnt, int fd, const char *path);
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
/* Suck file into string allocated via malloc(). Call free() when done. */
Packit Service 1d0348
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
Packit Service 1d0348
char *slurpfile(size_t *, const char *fmt, ...);
Packit Service 1d0348
Packit Service 1d0348
/* Dump block of bytes to a file. */
Packit Service 1d0348
void dumpfile(const char *filename, void *, size_t);
Packit Service 1d0348
Packit Service 1d0348
/* Extracts named reference file to the current directory. */
Packit Service 1d0348
void extract_reference_file(const char *);
Packit Service 1d0348
/* Copies named reference file to the current directory. */
Packit Service 1d0348
void copy_reference_file(const char *);
Packit Service 1d0348
Packit Service 1d0348
/* Extracts a list of files to the current directory.
Packit Service 1d0348
 * List must be NULL terminated.
Packit Service 1d0348
 */
Packit Service 1d0348
void extract_reference_files(const char **);
Packit Service 1d0348
Packit Service 1d0348
/* Subtract umask from mode */
Packit Service 1d0348
mode_t umasked(mode_t expected_mode);
Packit Service 1d0348
Packit Service 1d0348
/* Path to working directory for current test */
Packit Service 1d0348
extern const char *testworkdir;
Packit Service 1d0348
Packit Service 1d0348
#ifndef PROGRAM
Packit Service 1d0348
/*
Packit Service 1d0348
 * Special interfaces for libarchive test harness.
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
#include "archive.h"
Packit Service 1d0348
#include "archive_entry.h"
Packit Service 1d0348
Packit Service 1d0348
/* ACL structure */
Packit Service 1d0348
struct archive_test_acl_t {
Packit Service 1d0348
	int type;  /* Type of ACL */
Packit Service 1d0348
	int permset; /* Permissions for this class of users. */
Packit Service 1d0348
	int tag; /* Owner, User, Owning group, group, other, etc. */
Packit Service 1d0348
	int qual; /* GID or UID of user/group, depending on tag. */
Packit Service 1d0348
	const char *name; /* Name of user/group, depending on tag. */
Packit Service 1d0348
};
Packit Service 1d0348
Packit Service 1d0348
/* Set ACLs */
Packit Service 1d0348
int assertion_entry_set_acls(const char *, int, struct archive_entry *,
Packit Service 1d0348
    struct archive_test_acl_t *, int);
Packit Service 1d0348
Packit Service 1d0348
/* Compare ACLs */
Packit Service 1d0348
int assertion_entry_compare_acls(const char *, int, struct archive_entry *,
Packit Service 1d0348
    struct archive_test_acl_t *, int, int, int);
Packit Service 1d0348
Packit Service 1d0348
/* Special customized read-from-memory interface. */
Packit Service 1d0348
int read_open_memory(struct archive *, const void *, size_t, size_t);
Packit Service 1d0348
/* _minimal version exercises a slightly different set of libarchive APIs. */
Packit Service 1d0348
int read_open_memory_minimal(struct archive *, const void *, size_t, size_t);
Packit Service 1d0348
/* _seek version produces a seekable file. */
Packit Service 1d0348
int read_open_memory_seek(struct archive *, const void *, size_t, size_t);
Packit Service 1d0348
Packit Service 1d0348
/* Versions of above that accept an archive argument for additional info. */
Packit Service 1d0348
#define assertA(e)   assertion_assert(__FILE__, __LINE__, (e), #e, (a))
Packit Service 1d0348
#define assertEqualIntA(a,v1,v2)   \
Packit Service 1d0348
  assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
Packit Service 1d0348
#define assertEqualStringA(a,v1,v2)   \
Packit Service 1d0348
  assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a), 0)
Packit Service 1d0348
Packit Service 1d0348
#else	/* defined(PROGRAM) */
Packit Service 1d0348
/*
Packit Service 1d0348
 * Special interfaces for program test harness.
Packit Service 1d0348
 */
Packit Service 1d0348
Packit Service 1d0348
/* Pathname of exe to be tested. */
Packit Service 1d0348
extern const char *testprogfile;
Packit Service 1d0348
/* Name of exe to use in printf-formatted command strings. */
Packit Service 1d0348
/* On Windows, this includes leading/trailing quotes. */
Packit Service 1d0348
extern const char *testprog;
Packit Service 1d0348
Packit Service 1d0348
void assertVersion(const char *prog, const char *base);
Packit Service 1d0348
Packit Service 1d0348
#endif	/* defined(PROGRAM) */
Packit Service 1d0348
Packit Service 1d0348
#ifdef USE_DMALLOC
Packit Service 1d0348
#include <dmalloc.h>
Packit Service 1d0348
#endif
Packit Service 1d0348
Packit Service 1d0348
#endif	/* TEST_COMMON_H */