/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* diagcode library unit test
*
* usually run from "make test" target. takes a single argument
* which is the directory where the test dictionaries are found.
* this test driver scans the dictionaries for comments of the form:
* #TEST:<routine>:<errno>:<input>:<output>
* and executes that test.
*
* exit 0 and an "All tests passed" message means no failures. otherwise
* error messages are spewed as appropriate and exit value is non-zero.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <alloca.h>
#include <errno.h>
#include <dirent.h>
#include <stdarg.h>
#include <fm/diagcode.h>
static char *Myname;
static char *Dict;
static int Line;
static int Errcount;
/*PRINTFLIKE1*/
static void
{
Errcount++;
}
/* parse an expected errno value from test line (numeric or some symbolic) */
static int
geterrno(const char *s)
{
if (*s == '\0' || isspace(*s))
return (0);
else if (isdigit(*s))
return (atoi(s));
else if (strcmp(s, "EPERM") == 0)
return (EPERM);
else if (strcmp(s, "ENOENT") == 0)
return (ENOENT);
else if (strcmp(s, "ESRCH") == 0)
return (ESRCH);
else if (strcmp(s, "ENOMEM") == 0)
return (ENOMEM);
else if (strcmp(s, "EACCES") == 0)
return (EACCES);
else if (strcmp(s, "EINVAL") == 0)
return (EINVAL);
else if (strcmp(s, "ERANGE") == 0)
return (ERANGE);
else if (strcmp(s, "ENOMSG") == 0)
return (ENOMSG);
else if (strcmp(s, "ENOTSUP") == 0)
return (ENOTSUP);
else {
err("geterrno: don't know errno \"%s\"", s);
Errcount++;
return (0);
}
}
/* call fm_dc_opendict() as part of a test */
static void
{
int reterrno;
int experrno;
if (argc != 2) {
err("argc != 2");
return;
}
else
reterrno = 0;
}
/* call fm_dc_closedict() as part of a test */
static void
{
if (Dhp) {
}
}
/* call fm_dc_codelen() as part of a test */
static void
{
int retcodelen;
int expcodelen;
if (argc != 3) {
err("argc != 3");
return;
}
err("codelen NULL handle");
return;
}
if (retcodelen != expcodelen)
}
/* call fm_dc_maxkey() as part of a test */
static void
{
int retmaxkey;
int expmaxkey;
if (argc != 3) {
err("argc != 3");
return;
}
err("maxkey NULL handle");
return;
}
}
/* call fm_dc_key2code() as part of a test */
static void
{
int reterrno;
int experrno;
int nel;
char *beginp;
char *endp;
if (argc < 3) {
err("argc < 3");
return;
}
if (argc > 4) {
err("argc > 4");
return;
}
/* convert key into array */
nel = 0;
*endp++ = '\0';
} else
break;
}
err("key2code NULL handle");
return;
}
else
reterrno = 0;
return;
}
}
/* call fm_dc_code2key() as part of a test */
static void
{
int reterrno;
int experrno;
int nel;
if (argc < 3) {
err("argc < 3");
return;
}
if (argc > 4) {
err("argc > 4");
return;
}
err("code2key NULL handle");
return;
}
else
reterrno = 0;
return;
}
if (reterrno)
return;
if (argc > 3) {
/* convert key into string */
keystr[0] = '\0';
if (nel)
}
}
}
/* call fm_dc_getprop() as part of a test */
static void
{
int reterrno;
int experrno;
const char *val;
if (argc != 4) {
err("argc != 4");
return;
}
err("getprop NULL handle");
return;
}
else
reterrno = 0;
return;
}
}
/* scan a dictionary, looking for test directives embedded in the comments */
static void
{
Errcount++;
return;
}
Line = 0;
int argc;
char *beginp;
char *endp;
Line++;
continue;
*endp = '\0';
argc = 0;
*endp++ = '\0';
} else
break;
}
else {
Errcount++;
}
}
if (Dhp) {
}
}
/* scan a directory, looking for dictionaries to test against */
int
{
else
Myname++;
if (argc != 2) {
exit(1);
}
exit(1);
}
char *ptr;
continue;
continue;
}
if (Errcount == 0)
return (Errcount);
}