1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) International Business Machines Corp., 2001
3*49cdfc7eSAndroid Build Coastguard Worker *
4*49cdfc7eSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify
5*49cdfc7eSAndroid Build Coastguard Worker * it under the terms of the GNU General Public License as published by
6*49cdfc7eSAndroid Build Coastguard Worker * the Free Software Foundation; either version 2 of the License, or
7*49cdfc7eSAndroid Build Coastguard Worker * (at your option) any later version.
8*49cdfc7eSAndroid Build Coastguard Worker *
9*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it will be useful,
10*49cdfc7eSAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12*49cdfc7eSAndroid Build Coastguard Worker * the GNU General Public License for more details.
13*49cdfc7eSAndroid Build Coastguard Worker *
14*49cdfc7eSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License
15*49cdfc7eSAndroid Build Coastguard Worker * along with this program; if not, write to the Free Software
16*49cdfc7eSAndroid Build Coastguard Worker * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*49cdfc7eSAndroid Build Coastguard Worker *
18*49cdfc7eSAndroid Build Coastguard Worker */
19*49cdfc7eSAndroid Build Coastguard Worker
20*49cdfc7eSAndroid Build Coastguard Worker /*
21*49cdfc7eSAndroid Build Coastguard Worker * File: ltpapicmd.c
22*49cdfc7eSAndroid Build Coastguard Worker *
23*49cdfc7eSAndroid Build Coastguard Worker * Description: This program impliments a command line version of some of the
24*49cdfc7eSAndroid Build Coastguard Worker * LTP harness API's. This will enable tests written in shell and
25*49cdfc7eSAndroid Build Coastguard Worker * other scripts to report problems and log results in the LTP
26*49cdfc7eSAndroid Build Coastguard Worker * harness format. The intent is to have a common format in which
27*49cdfc7eSAndroid Build Coastguard Worker * the C tests and tests written in scripts report results in
28*49cdfc7eSAndroid Build Coastguard Worker * a common format.
29*49cdfc7eSAndroid Build Coastguard Worker *
30*49cdfc7eSAndroid Build Coastguard Worker * The following LTP API's are available currently in command line
31*49cdfc7eSAndroid Build Coastguard Worker * form:
32*49cdfc7eSAndroid Build Coastguard Worker * tst_brk - Print result message and break remaining test cases
33*49cdfc7eSAndroid Build Coastguard Worker * tst_brkm - Print result message, including file contents, and
34*49cdfc7eSAndroid Build Coastguard Worker * break remaining test cases
35*49cdfc7eSAndroid Build Coastguard Worker * tst_res - Print result message, including file contents
36*49cdfc7eSAndroid Build Coastguard Worker * tst_resm - Print result message
37*49cdfc7eSAndroid Build Coastguard Worker * tst_exit - Exit test with a meaningful exit value
38*49cdfc7eSAndroid Build Coastguard Worker *
39*49cdfc7eSAndroid Build Coastguard Worker * These are the minimum set of functions or commands required to
40*49cdfc7eSAndroid Build Coastguard Worker * report results.
41*49cdfc7eSAndroid Build Coastguard Worker *
42*49cdfc7eSAndroid Build Coastguard Worker * Exit: All commands exit with
43*49cdfc7eSAndroid Build Coastguard Worker * 0 - on success
44*49cdfc7eSAndroid Build Coastguard Worker * -1 - on failure
45*49cdfc7eSAndroid Build Coastguard Worker *
46*49cdfc7eSAndroid Build Coastguard Worker * History
47*49cdfc7eSAndroid Build Coastguard Worker * Dec 10 2002 - Created - Manoj Iyer [email protected]
48*49cdfc7eSAndroid Build Coastguard Worker * Dec 12 2002 - Modified - Code that checked if the environment variables
49*49cdfc7eSAndroid Build Coastguard Worker * TCID and TST_TOTAL were set did not print usage message.
50*49cdfc7eSAndroid Build Coastguard Worker * Modified code to print usage message in each case.
51*49cdfc7eSAndroid Build Coastguard Worker * Dec 16 2002 - Modified - Code to get the test number, gets environment
52*49cdfc7eSAndroid Build Coastguard Worker * variable TST_COUNT and initializes tst_count.
53*49cdfc7eSAndroid Build Coastguard Worker * Dec 16 2002 - Documentation and comment changes.
54*49cdfc7eSAndroid Build Coastguard Worker * Feb 11 2003 - tst_count was set to -1 during init or setup in the script.
55*49cdfc7eSAndroid Build Coastguard Worker * this was causing tst_resm to issue a warning message.
56*49cdfc7eSAndroid Build Coastguard Worker * This bug is now fixed.
57*49cdfc7eSAndroid Build Coastguard Worker *
58*49cdfc7eSAndroid Build Coastguard Worker */
59*49cdfc7eSAndroid Build Coastguard Worker
60*49cdfc7eSAndroid Build Coastguard Worker #include <sys/socket.h>
61*49cdfc7eSAndroid Build Coastguard Worker #include <stdio.h>
62*49cdfc7eSAndroid Build Coastguard Worker #include <string.h>
63*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
64*49cdfc7eSAndroid Build Coastguard Worker #include <stdint.h>
65*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
66*49cdfc7eSAndroid Build Coastguard Worker #include "usctest.h"
67*49cdfc7eSAndroid Build Coastguard Worker #include "safe_macros.h"
68*49cdfc7eSAndroid Build Coastguard Worker
69*49cdfc7eSAndroid Build Coastguard Worker char *TCID; /* Name of the testcase */
70*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL; /* Total number of testcases */
71*49cdfc7eSAndroid Build Coastguard Worker
72*49cdfc7eSAndroid Build Coastguard Worker static char cmd_name[1024]; /* name by which this program is invoked tst_brk etc */
73*49cdfc7eSAndroid Build Coastguard Worker static char *tst_total; /* total number of tests in the file. */
74*49cdfc7eSAndroid Build Coastguard Worker static char *tst_cntstr; /* sets the value of tst_count with this value */
75*49cdfc7eSAndroid Build Coastguard Worker
76*49cdfc7eSAndroid Build Coastguard Worker
77*49cdfc7eSAndroid Build Coastguard Worker /*
78*49cdfc7eSAndroid Build Coastguard Worker * Function: ident_ttype - Return test result type.
79*49cdfc7eSAndroid Build Coastguard Worker *
80*49cdfc7eSAndroid Build Coastguard Worker * Description: This function will return the test result type, it actually
81*49cdfc7eSAndroid Build Coastguard Worker * the string that is entered by the user to an integer value that
82*49cdfc7eSAndroid Build Coastguard Worker * is understood by the API's.
83*49cdfc7eSAndroid Build Coastguard Worker *
84*49cdfc7eSAndroid Build Coastguard Worker * Return: test type TPASS, TFAIL, TBROK, TCONF, TWARN, or TINFO
85*49cdfc7eSAndroid Build Coastguard Worker * on success
86*49cdfc7eSAndroid Build Coastguard Worker * -1 on failure
87*49cdfc7eSAndroid Build Coastguard Worker */
ident_ttype(char * tstype)88*49cdfc7eSAndroid Build Coastguard Worker int ident_ttype(char *tstype)
89*49cdfc7eSAndroid Build Coastguard Worker {
90*49cdfc7eSAndroid Build Coastguard Worker /* test result type one of TPASS, TFAIL, etc */
91*49cdfc7eSAndroid Build Coastguard Worker if (strcmp(tstype, "TBROK") == 0)
92*49cdfc7eSAndroid Build Coastguard Worker return TBROK;
93*49cdfc7eSAndroid Build Coastguard Worker else if (strcmp(tstype, "TFAIL") == 0)
94*49cdfc7eSAndroid Build Coastguard Worker return TFAIL;
95*49cdfc7eSAndroid Build Coastguard Worker else if (strcmp(tstype, "TPASS") == 0)
96*49cdfc7eSAndroid Build Coastguard Worker return TPASS;
97*49cdfc7eSAndroid Build Coastguard Worker else if (strcmp(tstype, "TCONF") == 0)
98*49cdfc7eSAndroid Build Coastguard Worker return TCONF;
99*49cdfc7eSAndroid Build Coastguard Worker else if (strcmp(tstype, "TWARN") == 0)
100*49cdfc7eSAndroid Build Coastguard Worker return TWARN;
101*49cdfc7eSAndroid Build Coastguard Worker else if (strcmp(tstype, "TINFO") == 0)
102*49cdfc7eSAndroid Build Coastguard Worker return TINFO;
103*49cdfc7eSAndroid Build Coastguard Worker else
104*49cdfc7eSAndroid Build Coastguard Worker return -1;
105*49cdfc7eSAndroid Build Coastguard Worker }
106*49cdfc7eSAndroid Build Coastguard Worker
tst_cat_file(const char * filename)107*49cdfc7eSAndroid Build Coastguard Worker void tst_cat_file(const char *filename)
108*49cdfc7eSAndroid Build Coastguard Worker {
109*49cdfc7eSAndroid Build Coastguard Worker const char *cmd[] = {"cat", filename, NULL};
110*49cdfc7eSAndroid Build Coastguard Worker
111*49cdfc7eSAndroid Build Coastguard Worker tst_cmd(NULL, cmd, NULL, NULL, 0);
112*49cdfc7eSAndroid Build Coastguard Worker }
113*49cdfc7eSAndroid Build Coastguard Worker
apicmd_brk(int argc,char * argv[])114*49cdfc7eSAndroid Build Coastguard Worker void apicmd_brk(int argc, char *argv[])
115*49cdfc7eSAndroid Build Coastguard Worker {
116*49cdfc7eSAndroid Build Coastguard Worker int trestype;
117*49cdfc7eSAndroid Build Coastguard Worker char *file_name;
118*49cdfc7eSAndroid Build Coastguard Worker
119*49cdfc7eSAndroid Build Coastguard Worker if (argc < 5) {
120*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "Usage: %s TTYPE FNAME FUNC STRING\n"
121*49cdfc7eSAndroid Build Coastguard Worker "\tTTYPE - Test Result Type; one of TFAIL, TBROK "
122*49cdfc7eSAndroid Build Coastguard Worker "and TCONF.\n"
123*49cdfc7eSAndroid Build Coastguard Worker "\tFNAME - Print contents of this file after the message\n"
124*49cdfc7eSAndroid Build Coastguard Worker "\tFUNC - Cleanup function (ignored), but MUST be provided\n"
125*49cdfc7eSAndroid Build Coastguard Worker "\tSTRING - Message explaining the test result\n",
126*49cdfc7eSAndroid Build Coastguard Worker cmd_name);
127*49cdfc7eSAndroid Build Coastguard Worker exit(1);
128*49cdfc7eSAndroid Build Coastguard Worker }
129*49cdfc7eSAndroid Build Coastguard Worker trestype = ident_ttype((argv++)[0]);
130*49cdfc7eSAndroid Build Coastguard Worker file_name = (argv++)[0];
131*49cdfc7eSAndroid Build Coastguard Worker tst_cat_file(file_name);
132*49cdfc7eSAndroid Build Coastguard Worker argv++;
133*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(trestype, NULL, "%s", *argv);
134*49cdfc7eSAndroid Build Coastguard Worker
135*49cdfc7eSAndroid Build Coastguard Worker }
136*49cdfc7eSAndroid Build Coastguard Worker
apicmd_res(int argc,char * argv[])137*49cdfc7eSAndroid Build Coastguard Worker void apicmd_res(int argc, char *argv[])
138*49cdfc7eSAndroid Build Coastguard Worker {
139*49cdfc7eSAndroid Build Coastguard Worker int trestype;
140*49cdfc7eSAndroid Build Coastguard Worker char *file_name;
141*49cdfc7eSAndroid Build Coastguard Worker
142*49cdfc7eSAndroid Build Coastguard Worker if (argc < 4) {
143*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "Usage: %s TTYPE FNAME STRING\n"
144*49cdfc7eSAndroid Build Coastguard Worker "\tTTYPE - Test Result Type; one of TFAIL, TBROK "
145*49cdfc7eSAndroid Build Coastguard Worker "and TCONF.\n"
146*49cdfc7eSAndroid Build Coastguard Worker "\tFNAME - Print contents of this file after the message\n"
147*49cdfc7eSAndroid Build Coastguard Worker "\tSTRING - Message explaining the test result\n",
148*49cdfc7eSAndroid Build Coastguard Worker cmd_name);
149*49cdfc7eSAndroid Build Coastguard Worker exit(1);
150*49cdfc7eSAndroid Build Coastguard Worker }
151*49cdfc7eSAndroid Build Coastguard Worker trestype = ident_ttype((argv++)[0]);
152*49cdfc7eSAndroid Build Coastguard Worker file_name = (argv++)[0];
153*49cdfc7eSAndroid Build Coastguard Worker tst_cat_file(file_name);
154*49cdfc7eSAndroid Build Coastguard Worker tst_resm(trestype, "%s", *argv);
155*49cdfc7eSAndroid Build Coastguard Worker }
156*49cdfc7eSAndroid Build Coastguard Worker
apicmd_brkm(int argc,char * argv[])157*49cdfc7eSAndroid Build Coastguard Worker void apicmd_brkm(int argc, char *argv[])
158*49cdfc7eSAndroid Build Coastguard Worker {
159*49cdfc7eSAndroid Build Coastguard Worker int trestype;
160*49cdfc7eSAndroid Build Coastguard Worker
161*49cdfc7eSAndroid Build Coastguard Worker if (argc < 4) {
162*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "Usage: %s TTYPE FUNC STRING\n"
163*49cdfc7eSAndroid Build Coastguard Worker "\tTTYPE - Test Result Type; one of TFAIL, TBROK "
164*49cdfc7eSAndroid Build Coastguard Worker "and TCONF.\n"
165*49cdfc7eSAndroid Build Coastguard Worker "\tFUNC - Cleanup function (ignored), but MUST be provided\n"
166*49cdfc7eSAndroid Build Coastguard Worker "\tSTRING - Message explaining the test result\n",
167*49cdfc7eSAndroid Build Coastguard Worker cmd_name);
168*49cdfc7eSAndroid Build Coastguard Worker exit(1);
169*49cdfc7eSAndroid Build Coastguard Worker }
170*49cdfc7eSAndroid Build Coastguard Worker trestype = ident_ttype((argv++)[0]);
171*49cdfc7eSAndroid Build Coastguard Worker argv++;
172*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(trestype, NULL, "%s", *argv);
173*49cdfc7eSAndroid Build Coastguard Worker }
174*49cdfc7eSAndroid Build Coastguard Worker
apicmd_resm(int argc,char * argv[])175*49cdfc7eSAndroid Build Coastguard Worker void apicmd_resm(int argc, char *argv[])
176*49cdfc7eSAndroid Build Coastguard Worker {
177*49cdfc7eSAndroid Build Coastguard Worker int trestype;
178*49cdfc7eSAndroid Build Coastguard Worker
179*49cdfc7eSAndroid Build Coastguard Worker if (argc < 3) {
180*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "Usage: %s TTYPE STRING\n"
181*49cdfc7eSAndroid Build Coastguard Worker "\tTTYPE - Test Result Type; one of TFAIL, TBROK"
182*49cdfc7eSAndroid Build Coastguard Worker "and TCONF.\n"
183*49cdfc7eSAndroid Build Coastguard Worker "\tSTRING - Message explaining the test result\n",
184*49cdfc7eSAndroid Build Coastguard Worker cmd_name);
185*49cdfc7eSAndroid Build Coastguard Worker exit(1);
186*49cdfc7eSAndroid Build Coastguard Worker }
187*49cdfc7eSAndroid Build Coastguard Worker trestype = ident_ttype((argv++)[0]);
188*49cdfc7eSAndroid Build Coastguard Worker tst_resm(trestype, "%s", *argv);
189*49cdfc7eSAndroid Build Coastguard Worker }
190*49cdfc7eSAndroid Build Coastguard Worker
191*49cdfc7eSAndroid Build Coastguard Worker struct param_pair {
192*49cdfc7eSAndroid Build Coastguard Worker char *cmd;
193*49cdfc7eSAndroid Build Coastguard Worker int value;
194*49cdfc7eSAndroid Build Coastguard Worker };
195*49cdfc7eSAndroid Build Coastguard Worker
apicmd_fs_has_free(int argc,char * argv[])196*49cdfc7eSAndroid Build Coastguard Worker int apicmd_fs_has_free(int argc, char *argv[])
197*49cdfc7eSAndroid Build Coastguard Worker {
198*49cdfc7eSAndroid Build Coastguard Worker if (argc != 3) {
199*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "Usage: tst_fs_has_free path required_bytes\n"
200*49cdfc7eSAndroid Build Coastguard Worker "path: the pathname of the mounted filesystem\n"
201*49cdfc7eSAndroid Build Coastguard Worker "required_bytes: the required free space"
202*49cdfc7eSAndroid Build Coastguard Worker " (supports kB, MB and GB suffixes)\n");
203*49cdfc7eSAndroid Build Coastguard Worker exit(2);
204*49cdfc7eSAndroid Build Coastguard Worker }
205*49cdfc7eSAndroid Build Coastguard Worker
206*49cdfc7eSAndroid Build Coastguard Worker char *endptr;
207*49cdfc7eSAndroid Build Coastguard Worker unsigned int required_kib = strtoull(argv[1], &endptr, 0);
208*49cdfc7eSAndroid Build Coastguard Worker unsigned int mul = TST_BYTES;
209*49cdfc7eSAndroid Build Coastguard Worker
210*49cdfc7eSAndroid Build Coastguard Worker if (*argv[1] == '\0')
211*49cdfc7eSAndroid Build Coastguard Worker goto fs_has_free_err;
212*49cdfc7eSAndroid Build Coastguard Worker
213*49cdfc7eSAndroid Build Coastguard Worker if (*endptr != '\0') {
214*49cdfc7eSAndroid Build Coastguard Worker if (!strcasecmp(endptr, "kB")) {
215*49cdfc7eSAndroid Build Coastguard Worker mul = TST_KB;
216*49cdfc7eSAndroid Build Coastguard Worker } else if (!strcasecmp(endptr, "MB")) {
217*49cdfc7eSAndroid Build Coastguard Worker mul = TST_MB;
218*49cdfc7eSAndroid Build Coastguard Worker } else if (!strcasecmp(endptr, "GB")) {
219*49cdfc7eSAndroid Build Coastguard Worker mul = TST_GB;
220*49cdfc7eSAndroid Build Coastguard Worker } else {
221*49cdfc7eSAndroid Build Coastguard Worker goto fs_has_free_err;
222*49cdfc7eSAndroid Build Coastguard Worker }
223*49cdfc7eSAndroid Build Coastguard Worker }
224*49cdfc7eSAndroid Build Coastguard Worker
225*49cdfc7eSAndroid Build Coastguard Worker exit(!tst_fs_has_free(NULL, argv[0], required_kib, mul));
226*49cdfc7eSAndroid Build Coastguard Worker
227*49cdfc7eSAndroid Build Coastguard Worker fs_has_free_err:
228*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "%s is not a valid size\n", argv[1]);
229*49cdfc7eSAndroid Build Coastguard Worker exit(2);
230*49cdfc7eSAndroid Build Coastguard Worker }
231*49cdfc7eSAndroid Build Coastguard Worker
232*49cdfc7eSAndroid Build Coastguard Worker /*
233*49cdfc7eSAndroid Build Coastguard Worker * Function: main - entry point of this program
234*49cdfc7eSAndroid Build Coastguard Worker *
235*49cdfc7eSAndroid Build Coastguard Worker * Description: Parses the arguments to each command. Most commands have in
236*49cdfc7eSAndroid Build Coastguard Worker * common atlest 2 arguments, type of test result, which is one of
237*49cdfc7eSAndroid Build Coastguard Worker * TPASS, TFAIL, TBROK, TCONF, etc, and a message that describes
238*49cdfc7eSAndroid Build Coastguard Worker * the result. Other arguments are a file, the contents of which
239*49cdfc7eSAndroid Build Coastguard Worker * are printed after the type of test result and associated message
240*49cdfc7eSAndroid Build Coastguard Worker * is printed, also a cleanup function that will be executed.
241*49cdfc7eSAndroid Build Coastguard Worker * Currently this function name is ignored but MUST be provided
242*49cdfc7eSAndroid Build Coastguard Worker * for compatability reasons.
243*49cdfc7eSAndroid Build Coastguard Worker *
244*49cdfc7eSAndroid Build Coastguard Worker * The different commands are actually a hard link to this program
245*49cdfc7eSAndroid Build Coastguard Worker * the program invokes the appropriate function based on the
246*49cdfc7eSAndroid Build Coastguard Worker * command name with which it was invoked.
247*49cdfc7eSAndroid Build Coastguard Worker *
248*49cdfc7eSAndroid Build Coastguard Worker * Set the values for TCID to the name of the test case.
249*49cdfc7eSAndroid Build Coastguard Worker * set the value for TST_TOTAL for total number of tests this is
250*49cdfc7eSAndroid Build Coastguard Worker * required in case one test breaks and all following tests also
251*49cdfc7eSAndroid Build Coastguard Worker * should be reported as broken.
252*49cdfc7eSAndroid Build Coastguard Worker * Set tst_count before every individual test.
253*49cdfc7eSAndroid Build Coastguard Worker *
254*49cdfc7eSAndroid Build Coastguard Worker * Exit: 0 on success
255*49cdfc7eSAndroid Build Coastguard Worker * -1 on failure
256*49cdfc7eSAndroid Build Coastguard Worker */
main(int argc,char * argv[])257*49cdfc7eSAndroid Build Coastguard Worker int main(int argc, char *argv[])
258*49cdfc7eSAndroid Build Coastguard Worker {
259*49cdfc7eSAndroid Build Coastguard Worker strcpy(cmd_name, SAFE_BASENAME(NULL, (argv++)[0]));
260*49cdfc7eSAndroid Build Coastguard Worker
261*49cdfc7eSAndroid Build Coastguard Worker TCID = getenv("TCID");
262*49cdfc7eSAndroid Build Coastguard Worker tst_total = getenv("TST_TOTAL");
263*49cdfc7eSAndroid Build Coastguard Worker tst_cntstr = getenv("TST_COUNT");
264*49cdfc7eSAndroid Build Coastguard Worker if (TCID == NULL || tst_total == NULL || tst_cntstr == NULL) {
265*49cdfc7eSAndroid Build Coastguard Worker if(!strcmp(cmd_name, "tst_fs_has_free")) {
266*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr,
267*49cdfc7eSAndroid Build Coastguard Worker "\nSet variables TCID, TST_TOTAL, and TST_COUNT before each test:\n"
268*49cdfc7eSAndroid Build Coastguard Worker "export TCID=<test name>\n"
269*49cdfc7eSAndroid Build Coastguard Worker "export TST_TOTAL=<Total Number of Tests >\n"
270*49cdfc7eSAndroid Build Coastguard Worker "export TST_COUNT=<Test case number>\n\n");
271*49cdfc7eSAndroid Build Coastguard Worker /* Make sure the user knows there's an error. */
272*49cdfc7eSAndroid Build Coastguard Worker abort();
273*49cdfc7eSAndroid Build Coastguard Worker }
274*49cdfc7eSAndroid Build Coastguard Worker } else {
275*49cdfc7eSAndroid Build Coastguard Worker TST_TOTAL = atoi(tst_total);
276*49cdfc7eSAndroid Build Coastguard Worker tst_count = atoi(tst_cntstr);
277*49cdfc7eSAndroid Build Coastguard Worker if (tst_count > 0)
278*49cdfc7eSAndroid Build Coastguard Worker tst_count--;
279*49cdfc7eSAndroid Build Coastguard Worker
280*49cdfc7eSAndroid Build Coastguard Worker if (strcmp(TCID, " ") == 0) {
281*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr,
282*49cdfc7eSAndroid Build Coastguard Worker "Variable TCID not set, use: TCID=<test name>\n");
283*49cdfc7eSAndroid Build Coastguard Worker exit(1);
284*49cdfc7eSAndroid Build Coastguard Worker }
285*49cdfc7eSAndroid Build Coastguard Worker if (TST_TOTAL <= 0) {
286*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr,
287*49cdfc7eSAndroid Build Coastguard Worker "Variable TST_TOTAL is set to 0, must be "
288*49cdfc7eSAndroid Build Coastguard Worker "greater than zero\n");
289*49cdfc7eSAndroid Build Coastguard Worker exit(1);
290*49cdfc7eSAndroid Build Coastguard Worker }
291*49cdfc7eSAndroid Build Coastguard Worker }
292*49cdfc7eSAndroid Build Coastguard Worker
293*49cdfc7eSAndroid Build Coastguard Worker if (strcmp(cmd_name, "tst_brk") == 0) {
294*49cdfc7eSAndroid Build Coastguard Worker apicmd_brk(argc, argv);
295*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_res") == 0) {
296*49cdfc7eSAndroid Build Coastguard Worker apicmd_res(argc, argv);
297*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_brkm") == 0) {
298*49cdfc7eSAndroid Build Coastguard Worker apicmd_brkm(argc, argv);
299*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_resm") == 0) {
300*49cdfc7eSAndroid Build Coastguard Worker apicmd_resm(argc, argv);
301*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_exit") == 0) {
302*49cdfc7eSAndroid Build Coastguard Worker tst_exit();
303*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_ncpus") == 0) {
304*49cdfc7eSAndroid Build Coastguard Worker printf("%li\n", tst_ncpus());
305*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_ncpus_conf") == 0) {
306*49cdfc7eSAndroid Build Coastguard Worker printf("%li\n", tst_ncpus_conf());
307*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_ncpus_max") == 0) {
308*49cdfc7eSAndroid Build Coastguard Worker printf("%li\n", tst_ncpus_max());
309*49cdfc7eSAndroid Build Coastguard Worker } else if (strcmp(cmd_name, "tst_fs_has_free") == 0) {
310*49cdfc7eSAndroid Build Coastguard Worker apicmd_fs_has_free(argc, argv);
311*49cdfc7eSAndroid Build Coastguard Worker }
312*49cdfc7eSAndroid Build Coastguard Worker
313*49cdfc7eSAndroid Build Coastguard Worker exit(0);
314*49cdfc7eSAndroid Build Coastguard Worker }
315