1/* $OpenBSD: util.h,v 1.1 2018/11/06 18:11:11 anton Exp $ */ 2 3/* 4 * Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19#define FAIL(test) do { \ 20 if (test) { \ 21 if (verbose) \ 22 printf("%s: %d: FAIL (%s)\n", \ 23 __func__, __LINE__, #test); \ 24 return -1; \ 25 } \ 26} while (0) 27 28#define SUCCEED do { \ 29 if (verbose) \ 30 printf("SUCCEED\n"); \ 31 return 0; \ 32} while (0) 33 34struct test { 35 int (*testfn)(int); /* function to perform the test */ 36 int intr; /* non-zero if the test interrupts a lock */ 37}; 38 39int make_file(off_t size); 40int safe_waitpid(pid_t pid); 41__dead void usage(void); 42 43extern int verbose; 44