/*-1* Copyright 2018 Aniket Pandey2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND13* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE14* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE15* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE16* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL17* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS18* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* SUCH DAMAGE.23*/242526#ifndef _UTILS_H_27#define _UTILS_H_2829#include <poll.h>30#include <stdio.h>31#include <stdbool.h>32#include <bsm/audit.h>3334void check_audit(struct pollfd [], const char *, FILE *);35FILE *setup(struct pollfd [], const char *);36void cleanup(void);37void skip_if_extattr_not_supported(const char *);3839#define REQUIRE_EXTATTR_SUCCESS(call) \40({ \41errno = 0; /* Reset errno before call */ \42ssize_t result = (call); \43if (result == -1) { \44atf_tc_fail_requirement(__FILE__, __LINE__, \45"%s failed with errno %d (%s)", #call, errno, \46strerror(errno)); \47} \48result; \49})5051#define REQUIRE_EXTATTR_RESULT(_expected, expr) \52do { \53ssize_t expected = (_expected); \54ssize_t _result = REQUIRE_EXTATTR_SUCCESS(expr); \55ATF_REQUIRE_EQ_MSG(expected, _result, "%s: %zd != %zd", #expr, \56expected, _result); \57} while (0)5859#endif /* _SETUP_H_ */606162