alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 3 | * |
| 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. |
| 7 | * |
| 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. |
| 11 | * |
| 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. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
Wanlong Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame] | 20 | * with this program; if not, write the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 22 | * |
| 23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 24 | * Mountain View, CA 94043, or: |
| 25 | * |
| 26 | * http://www.sgi.com |
| 27 | * |
| 28 | * For further information regarding this notice, see: |
| 29 | * |
| 30 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 31 | * |
| 32 | */ |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 33 | /* $Id: ltp-scanner.c,v 1.1 2009/05/19 09:39:11 subrata_modak Exp $ */ |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 34 | /* |
| 35 | * An RTS/pan driver output processing program. |
| 36 | * |
| 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. |
| 39 | * |
| 40 | * The reporting segment of the program reads that keyword table to produce |
Garrett Cooper | 1e6f5a6 | 2010-12-19 09:58:10 -0800 | [diff] [blame] | 41 | * it's reports. |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 42 | * |
| 43 | * Synopsis: |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 44 | * ltp-scanner [ -e ] [ -D area:level ] [ -h ] |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 45 | * |
| 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. |
| 50 | * |
| 51 | * Options: |
| 52 | * -e |
| 53 | * use an "extended" output format |
| 54 | * |
| 55 | * -D |
| 56 | * enable debug statements. Areas are listed in report2.h and levels |
| 57 | * are in the code. Must be compiled with "-DDEBUGGING" |
| 58 | * |
| 59 | * -h |
| 60 | * print out a command usage statement and exit. |
| 61 | * |
| 62 | * INPUT |
| 63 | * The input must conform to the RTS/pan driver format. |
| 64 | * |
| 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. |
| 71 | * |
| 72 | * System Configuration: |
Garrett Cooper | 1e6f5a6 | 2010-12-19 09:58:10 -0800 | [diff] [blame] | 73 | * ARCHITECTURE IOS_MODEL_E CRAY_YMP YMP7XX |
| 74 | * CONFIG JOBCNTL AVL BMD EMA HPM SECURE TFM_UDB_6 SDS SSD |
| 75 | * RELEASE 82 |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 76 | * UNAME sn1703c cool 8.2.0ae d82.25 |
| 77 | * date 03/24/94 |
| 78 | * |
| 79 | * tag tcid testcase status contact |
| 80 | * ------------------------------------------------------------------------ |
| 81 | * |
| 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. |
| 85 | * |
| 86 | * When a report is made for all TCIDs and Testcases, a star ( "*" ) is used. |
| 87 | * |
| 88 | * When in extended mode, an additional output line is produced for each |
| 89 | * tag. |
| 90 | * |
| 91 | * This line is identified with a "!" in the TCID and Testcase fields. |
| 92 | * |
| 93 | * It has no minimum and maximum field widths, so the output does not |
| 94 | * line up in columns |
| 95 | * |
| 96 | * the "status" field contains the initiation status |
| 97 | * |
| 98 | * the "contact" field does not expand multiple comma-separated contacts |
| 99 | * |
| 100 | * fields: |
| 101 | * tag, tcid, testcase, status, contact, |
| 102 | * start time, duration, termination type, termination id, |
| 103 | * output starting line, output ending line |
| 104 | * |
| 105 | * RELATED DOCUMENTS |
| 106 | * Regression Test System Phase 2 Test Result Reporting System |
| 107 | * |
| 108 | * AUTHOR |
| 109 | * Glen Overby wrote the code. |
| 110 | * |
| 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. |
| 115 | * |
| 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. |
| 121 | */ |
Garrett Cooper | 6ea8c5b | 2011-02-23 00:14:59 -0800 | [diff] [blame] | 122 | |
| 123 | #include <getopt.h> |
| 124 | #include <stdarg.h> |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 125 | #include <stdio.h> |
| 126 | #include <stdlib.h> |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 127 | #include <string.h> |
Garrett Cooper | 6ea8c5b | 2011-02-23 00:14:59 -0800 | [diff] [blame] | 128 | #include <unistd.h> |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 129 | #include "scan.h" |
| 130 | #include "debug.h" |
| 131 | #include "reporter.h" |
| 132 | #include "symbol.h" |
| 133 | |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 134 | char *cnf; /* current filename */ |
| 135 | int extended = 0; /* -e option */ |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 136 | |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 137 | int main(int argc, char *argv[]) |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 138 | { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 139 | SYM tags; /* tag data */ |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 140 | int c; |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 141 | |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 142 | while ((c = getopt(argc, argv, "D:ehi")) != -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 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, |
| 155 | "%s [-e] [-i] [ -D area, level ] input-filenames\n", |
| 156 | argv[0]); |
| 157 | exit(0); |
| 158 | default: |
| 159 | fprintf(stderr, "invalid argument, %c\n", c); |
| 160 | exit(1); |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 161 | } |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 162 | } |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 163 | |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 164 | lex_files(&argv[optind]); /* I hope that argv[argc+1] == NULL */ |
| 165 | tags = sym_open(0, 0, 0); |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 166 | |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 167 | scanner(tags); |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 168 | #ifdef DEBUGGING |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 169 | DEBUG(D_INIT, 1) |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 170 | sym_dump_s(tags, 0); |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 171 | #endif |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 172 | reporter(tags); |
alaffin | f558990 | 2000-09-21 21:35:06 +0000 | [diff] [blame] | 173 | |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 174 | exit(0); |
Garrett Cooper | 6ea8c5b | 2011-02-23 00:14:59 -0800 | [diff] [blame] | 175 | } |