1*2305Sstevel /*
2*2305Sstevel  * CDDL HEADER START
3*2305Sstevel  *
4*2305Sstevel  * The contents of this file are subject to the terms of the
5*2305Sstevel  * Common Development and Distribution License, Version 1.0 only
6*2305Sstevel  * (the "License").  You may not use this file except in compliance
7*2305Sstevel  * with the License.
8*2305Sstevel  *
9*2305Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*2305Sstevel  * or http://www.opensolaris.org/os/licensing.
11*2305Sstevel  * See the License for the specific language governing permissions
12*2305Sstevel  * and limitations under the License.
13*2305Sstevel  *
14*2305Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
15*2305Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*2305Sstevel  * If applicable, add the following below this CDDL HEADER, with the
17*2305Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
18*2305Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
19*2305Sstevel  *
20*2305Sstevel  * CDDL HEADER END
21*2305Sstevel  */
22*2305Sstevel /*
23*2305Sstevel  * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
24*2305Sstevel  * All rights reserved.
25*2305Sstevel  */
26*2305Sstevel 
27*2305Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*2305Sstevel 
29*2305Sstevel #include <stddef.h>
30*2305Sstevel #include <stdlib.h>
31*2305Sstevel #include <sys/param.h>
32*2305Sstevel #include <config_admin.h>
33*2305Sstevel #include <memory.h>
34*2305Sstevel #include "mema_test.h"
35*2305Sstevel 
36*2305Sstevel extern mtest_func_t memory_test_normal;
37*2305Sstevel extern mtest_func_t memory_test_quick;
38*2305Sstevel extern mtest_func_t memory_test_extended;
39*2305Sstevel 
40*2305Sstevel /*
41*2305Sstevel  * Default test is first entry in the table (MTEST_DEFAULT_TEST).
42*2305Sstevel  */
43*2305Sstevel struct mtest_table_ent mtest_table[] = {
44*2305Sstevel 	{"normal",	memory_test_normal},
45*2305Sstevel 	{"quick",	memory_test_quick},
46*2305Sstevel 	{"extended",	memory_test_extended},
47*2305Sstevel };
48*2305Sstevel 
49*2305Sstevel static char **opt_array;
50*2305Sstevel 
51*2305Sstevel char **
mtest_build_opts(int * maxerr_idx)52*2305Sstevel mtest_build_opts(int *maxerr_idx)
53*2305Sstevel {
54*2305Sstevel 	if (opt_array == NULL) {
55*2305Sstevel 		int nopts;
56*2305Sstevel 		/*
57*2305Sstevel 		 * Test "type" options here, max_errors should be the
58*2305Sstevel 		 * last one.
59*2305Sstevel 		 */
60*2305Sstevel 		nopts = sizeof (mtest_table) / sizeof (mtest_table[0]);
61*2305Sstevel 		*maxerr_idx = nopts;
62*2305Sstevel 
63*2305Sstevel 		/*
64*2305Sstevel 		 * One extra option for "max_errors"
65*2305Sstevel 		 */
66*2305Sstevel 		opt_array = (char **)malloc((nopts + 2) * sizeof (*opt_array));
67*2305Sstevel 		if (opt_array != NULL) {
68*2305Sstevel 			int i;
69*2305Sstevel 
70*2305Sstevel 			for (i = 0; i < nopts; i++)
71*2305Sstevel 				opt_array[i] = (char *)mtest_table[i].test_name;
72*2305Sstevel 
73*2305Sstevel 			opt_array[nopts] = "max_errors";
74*2305Sstevel 			opt_array[nopts + 1] = NULL;
75*2305Sstevel 		}
76*2305Sstevel 	}
77*2305Sstevel 	*maxerr_idx = sizeof (mtest_table) / sizeof (mtest_table[0]);
78*2305Sstevel 	return (opt_array);
79*2305Sstevel }
80