/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(HAVE_CONFIG_H)
#include "bconfig.h"
#endif
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "dynstr.h"
#include "env.h"
#include "fs.h"
#include "map.h"
#include "sanity.h"
#if defined(HAVE_GNU_GETOPT)
#else
#endif
/* This prototype is provided by macros.h during instantiation of the test
* program, so it can be kept private. Don't know if that's the best idea
* though. */
enum tc_part {
BODY,
};
/* ---------------------------------------------------------------------
* The "usage" and "user" error types.
* --------------------------------------------------------------------- */
struct name ## _error_data { \
char m_what[2048]; \
}; \
\
static \
void \
{ \
\
\
} \
\
static \
{ \
atf_error_t err; \
\
\
\
return err; \
}
/* ---------------------------------------------------------------------
* Printing functions.
* --------------------------------------------------------------------- */
static
void
{
progname);
}
static
void
{
}
/* ---------------------------------------------------------------------
* Options handling.
* --------------------------------------------------------------------- */
struct params {
bool m_do_list;
char *m_tcname;
};
static
{
if (atf_is_error(err))
goto out;
out:
return err;
}
static
{
p->m_do_list = false;
if (atf_is_error(err))
return err;
if (atf_is_error(err)) {
atf_fs_path_fini(&p->m_srcdir);
return err;
}
if (atf_is_error(err)) {
atf_fs_path_fini(&p->m_resfile);
atf_fs_path_fini(&p->m_srcdir);
return err;
}
return err;
}
static
void
{
atf_map_fini(&p->m_config);
atf_fs_path_fini(&p->m_resfile);
atf_fs_path_fini(&p->m_srcdir);
}
static
{
char *split;
goto out;
}
*split = '\0';
split++;
out:
return err;
}
static
{
if (!atf_is_error(err)) {
}
return err;
}
/* ---------------------------------------------------------------------
* Test case listing.
* --------------------------------------------------------------------- */
static
void
{
printf("Content-Type: application/X-atf-tp; version=\"1\"\n\n");
char **ptr;
printf("\n");
break;
}
}
}
}
}
}
/* ---------------------------------------------------------------------
* Main.
* --------------------------------------------------------------------- */
static
{
err = atf_no_error();
err = atf_no_memory_error();
goto out;
}
*delim = '\0';
delim++;
} else {
goto out;
}
}
out:
return err;
}
static
{
int ch;
int old_opterr;
if (atf_is_error(err))
goto out;
old_opterr = opterr;
opterr = 0;
while (!atf_is_error(err) &&
switch (ch) {
case 'l':
p->m_do_list = true;
break;
case 'r':
break;
case 's':
break;
case 'v':
break;
case ':':
break;
case '?':
default:
}
}
/* Clear getopt state just in case the test wants to use it. */
opterr = old_opterr;
optind = 1;
#if defined(HAVE_OPTRESET)
optreset = 1;
#endif
if (!atf_is_error(err)) {
if (p->m_do_list) {
if (argc > 0)
} else {
if (argc == 0)
else if (argc == 1)
else if (argc > 1) {
"name");
}
}
}
if (atf_is_error(err))
params_fini(p);
out:
return err;
}
static
{
if (atf_is_error(err))
goto out;
out:
return err;
}
static
{
bool b;
if (atf_is_error(err))
goto out;
if (!atf_fs_path_is_absolute(&srcdir)) {
if (atf_is_error(err))
goto out_srcdir;
}
if (atf_is_error(err))
goto out_srcdir;
else {
if (libs) {
if (atf_is_error(err))
goto out;
}
}
if (atf_is_error(err))
goto out_srcdir;
if (atf_is_error(err))
goto out_exe;
if (!atf_is_error(err)) {
if (b) {
} else {
}
}
out:
return err;
}
static
{
err = atf_no_error();
goto out;
}
"__RUNNING_INSIDE_ATF_RUN"), "internal-yes-value") != 0)
{
print_warning("Running test cases without atf-run(1) is unsupported");
print_warning("No isolation nor timeout control is being applied; you "
"may get unexpected failures; see atf-test-case(4)");
}
switch (p->m_tcpart) {
case BODY:
if (atf_is_error(err)) {
/* TODO: Handle error */
*exitcode = EXIT_FAILURE;
} else {
*exitcode = EXIT_SUCCESS;
}
break;
case CLEANUP:
if (atf_is_error(err)) {
/* TODO: Handle error */
*exitcode = EXIT_FAILURE;
} else {
*exitcode = EXIT_SUCCESS;
}
break;
default:
}
out:
return err;
}
static
int *exitcode)
{
struct params p;
char **raw_config;
if (atf_is_error(err))
goto out;
err = handle_srcdir(&p);
if (atf_is_error(err))
goto out_p;
if (raw_config == NULL) {
err = atf_no_memory_error();
goto out_p;
}
if (atf_is_error(err))
goto out_p;
if (atf_is_error(err))
goto out_tp;
if (p.m_do_list) {
*exitcode = EXIT_SUCCESS;
} else {
}
atf_tp_fini(&tp);
params_fini(&p);
out:
return err;
}
int
{
int exitcode;
else
progname++;
/* Libtool workaround: if running from within the source tree (binaries
* that are not installed yet), skip the "lt-" prefix added to files in
* the ".libs" directory to show the real (not temporary) name. */
progname += 3;
if (atf_is_error(err)) {
}
return exitcode;
}