538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore/*
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * This file and its contents are supplied under the terms of the
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * Common Development and Distribution License ("CDDL"), version 1.0.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * You may only use this file in accordance with the terms of version
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * 1.0 of the CDDL.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore *
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * A full copy of the text of the CDDL should have accompanied this
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * source. A copy of the CDDL is also available via the Internet at
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * http://www.illumos.org/license/CDDL.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore */
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore/*
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore */
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore/*
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore * Common handling for test programs.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore */
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#ifndef _TEST_COMMON_H
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#define _TEST_COMMON_H
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#ifdef __cplusplus
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern "C" {
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#endif
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretypedef struct test *test_t;
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoretypedef void (*test_func_t)(test_t, void *);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern void test_set_debug(void);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern void test_set_force(void);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern test_t test_start(const char *name, ...);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern void test_failed(test_t, const char *format, ...);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern void test_passed(test_t);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern void test_debugf(test_t, const char *format, ...);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amoreextern void test_run(int nthr, test_func_t, void *arg, const char *, ...);
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amoreextern void test_summary(void);
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amore
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amoreextern void test_trim(char **);
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amore
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amoretypedef int (*test_cfg_func_t)(char **fields, int nfields, char **err);
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amore
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amore/*
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amore * Args list is array of pairs of const char *keyword, test_config_func_t,
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amore * terminated by NULL.
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amore */
de572d98af8238405c5d1292a788b1a85b0c68ebGarrett D'Amoreextern int test_load_config(test_t, const char *, ...);
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#ifdef __cplusplus
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore}
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#endif
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore#endif /* _TEST_COMMON_H */