Fix some bashisms
[ltp-debian.git] / pan / ltp-scanner.c
blob20177cf0fd224d59659fa4f1f85a6432cd4402ae
1 /*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
26 * http://www.sgi.com
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
33 /* $Id: ltp-scanner.c,v 1.1 2009/05/19 09:39:11 subrata_modak Exp $ */
35 * An RTS/pan driver output processing program.
37 * This program reads an RTS/pan driver output format file, parses it using lex
38 * and saves the information into an in-memory hierarchical keyword table.
40 * The reporting segment of the program reads that keyword table to produce
41 * it's reports.
43 * Synopsis:
44 * ltp-scanner [ -e ] [ -D area:level ] [ -h ]
46 * Description:
47 * Scanner is part of the RTS 2.0 reporting mechanism or pan.
48 * It processes RTS/pan driver format output and produces a single simple report
49 * of each test tag executed, the TCIDs it executed, and their testcases.
51 * Options:
52 * -e
53 * use an "extended" output format
55 * -D
56 * enable debug statements. Areas are listed in report2.h and levels
57 * are in the code. Must be compiled with "-DDEBUGGING"
59 * -h
60 * print out a command usage statement and exit.
62 * INPUT
63 * The input must conform to the RTS/pan driver format.
65 * Report Format
66 * A single report style is used. It consists of a header made of all
67 * keywords in the rts_keywords fields of the driver output, and the test
68 * information.
69 * interpretation of CUTS "number of testcases" field when there are
70 * multiple TCIDs. It must be the sum of all TCIDs' testcases.
72 * System Configuration:
73 * ARCHITECTURE IOS_MODEL_E CRAY_YMP YMP7XX
74 * CONFIG JOBCNTL AVL BMD EMA HPM SECURE TFM_UDB_6 SDS SSD
75 * RELEASE 82
76 * UNAME sn1703c cool 8.2.0ae d82.25
77 * date 03/24/94
79 * tag tcid testcase status contact
80 * ------------------------------------------------------------------------
82 * When a report is made for only a tag, the TCID and Testcase fields
83 * contain a dash ( "-" ). The intention is that the output be usable
84 * by other Unix programs.
86 * When a report is made for all TCIDs and Testcases, a star ( "*" ) is used.
88 * When in extended mode, an additional output line is produced for each
89 * tag.
91 * This line is identified with a "!" in the TCID and Testcase fields.
93 * It has no minimum and maximum field widths, so the output does not
94 * line up in columns
96 * the "status" field contains the initiation status
98 * the "contact" field does not expand multiple comma-separated contacts
100 * fields:
101 * tag, tcid, testcase, status, contact,
102 * start time, duration, termination type, termination id,
103 * output starting line, output ending line
105 * RELATED DOCUMENTS
106 * Regression Test System Phase 2 Test Result Reporting System
108 * AUTHOR
109 * Glen Overby wrote the code.
111 * Internal Data Format
112 * All data is maintained in a hierarchical key database. While there are
113 * many available databases, this impliments a simple ASCII comma-separated
114 * keyed database.
116 * Key Naming
117 * - The top-level keys are named after the RTS or pan test tags.
118 * - The top-level key named "_RTS" contains the RTS Keywords
119 * - Each tag has a "_keys" tag that contains the key fields from
120 * the TEST_START and EXECUTION_STATUS fields.
122 #include <stdio.h>
123 #include <stdlib.h>
124 #include <malloc.h>
125 #include <unistd.h>
126 #include <stdarg.h>
127 #include <string.h>
128 #include <getopt.h>
129 #include "scan.h"
130 #include "debug.h"
131 #include "reporter.h"
132 #include "symbol.h"
134 char *cnf; /* current filename */
135 int extended=0; /* -e option */
137 int main(int argc, char *argv[])
139 SYM tags; /* tag data */
140 int c;
142 while ((c = getopt(argc, argv, "D:ehi")) != -1) {
143 switch(c) {
144 case 'i':
145 set_iscanner();
146 break;
147 case 'D':
148 set_debug(optarg);
149 break;
150 case 'e':
151 extended++;
152 break;
153 case 'h':
154 fprintf(stderr, "%s [-e] [-i] [ -D area, level ] input-filenames\n",
155 argv[0]);
156 exit(0);
157 default:
158 fprintf(stderr, "invalid argument, %c\n", c);
159 exit(1);
163 lex_files(&argv[optind]); /* I hope that argv[argc+1] == NULL */
164 tags = sym_open(0, 0, 0);
166 scanner(tags);
167 #ifdef DEBUGGING
168 DEBUG(D_INIT, 1)
169 sym_dump_s(tags, 0);
170 #endif
171 reporter(tags);
173 exit(0);