#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <err.h>
#include "config.h"
#include "test.h"
////////////////////////////////////////////////////////////
static
int
finderror(int rv, int error)
{
if (rv==-1) {
return error;
}
else {
return 0;
}
}
void
report_survival(int rv, int error, const char *desc)
{
/* allow any error as long as we survive */
errno = finderror(rv, error);
warn("passed: %s", desc);
}
void
report_test(int rv, int error, int right_error, const char *desc)
{
int goterror = finderror(rv, error);
if (goterror == right_error) {
warnx("passed: %s", desc);
}
else if (goterror == EUNIMP || goterror == ENOSYS) {
warnx("------: %s (unimplemented)", desc);
}
else {
errno = goterror;
warn("FAILURE: %s", desc);
}
}
void
report_test2(int rv, int error, int okerr1, int okerr2, const char *desc)
{
int goterror = finderror(rv, error);
if (goterror == okerr1 || goterror == okerr2) {
warnx("passed: %s", desc);
}
else if (goterror == EUNIMP || goterror == ENOSYS) {
This
preview
has intentionally blurred sections.
Sign up to view the full version.
warnx("------: %s (unimplemented)", desc);
}
else {
errno = goterror;
warn("FAILURE: %s", desc);
}
}
////////////////////////////////////////////////////////////
int
open_testfile(const char *string)
{
int fd, rv;
size_t len;
fd = open(TESTFILE, O_RDWR|O_CREAT|O_TRUNC);
if (fd<0) {

This is the end of the preview.
Sign up
to
access the rest of the document.
- Spring '09
- Lums
- Void type, #include, #define, warnx
-
Click to edit the document details