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