• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#
3#    Script for determining items missing from LTP install based on the output
4#    log provided by runltp[lite.sh].
5#
6#    Copyright (C) 2009, Cisco Systems Inc.
7#
8#    This program is free software; you can redistribute it and/or modify
9#    it under the terms of the GNU General Public License as published by
10#    the Free Software Foundation; either version 2 of the License, or
11#    (at your option) any later version.
12#
13#    This program is distributed in the hope that it will be useful,
14#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#    GNU General Public License for more details.
17#
18#    You should have received a copy of the GNU General Public License along
19#    with this program; if not, write to the Free Software Foundation, Inc.,
20#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21#
22# Ngie Cooper, July 2009
23#
24# Please invoke this script with --help to determine usage.
25#
26
27from optparse import OptionParser
28import os, re, sys
29
30parser = OptionParser(usage='usage: %prog [options] logfile ...')
31
32parser.add_option('-v', '--verbose', action='store_true', default=False,
33                  dest='verbose', help=('print out successful results as '
34                                        'well as failures'))
35
36opts, logfiles = parser.parse_args()
37
38if not len(logfiles):
39    parser.print_help()
40
41for logfile in logfiles:
42    if not os.access(logfile, os.R_OK):
43        sys.exit("%s not readable" % logfile)
44
45todo_res = [
46    re.compile("""initiation_status="pan\(\d+\): execvp of '(?P<app>.+)' \(tag (?P<tag>\w+)\) failed.+errno:2\s+No such file or directory"""),
47    re.compile("(?P<tag>\S+): line \d+: (?P<app>\S+): No such file or directory"),
48    re.compile("(?P<caller>\S+): (?P<app>\s+): No such file or directory"),
49    re.compile("""tag=(?P<tag>\w+) [\w=]+
50cmdline=.+
51contacts=.+
52analysis=.+
53<<<test_output>>>
54(\S+): (?P<app>\w+): command not found
55<<<execution_status>>>
56initiation_status=.+
57.+termination_id=127.+""")
58]
59
60for logfile in logfiles:
61    fd = open(logfile)
62
63    # Case 1:
64
65    # initiation_status="pan(9908): execvp of 'fs_perms_simpletest.sh' (tag fs_perms) failed.  errno:2  No such file or directory"
66
67    # Case 2:
68
69    # /scratch/ltp-install4/testcases/bin/test_controllers.sh: line 109: /scratch/ltp-install4/testcases/bin/run_cpuset_test.sh: No such file or directory
70
71    # Case 3:
72
73    # gcc: /scratch/ltp-install4/testcases/bin/nmfile2.c: No such file or directory
74
75    # Case 4:
76
77    # <<<test_start>>>
78    # tag=iogen01 stime=1248638309
79    # cmdline="export LTPROOT; rwtest -N iogen01 -i 120s -s read,write -Da -Dv -n 2 500b:doio.f1.$$ 1000b:doio.f2.$$"
80    # contacts=""
81    # analysis=exit
82    # <<<test_output>>>
83    # sh: rwtest: command not found
84    # <<<execution_status>>>
85    # initiation_status="ok"
86    # duration=0 termination_type=exited termination_id=127 corefile=no
87
88    missing_ents = []
89
90    try:
91
92        lines = fd.readlines()
93
94        for line in lines:
95
96            for todo_re in todo_res[:-1]:
97
98                m = todo_re.match(line)
99                if m:
100                    missing_ent = " ".join([m.group(1), m.group('app')])
101                    if missing_ent not in missing_ents:
102                        missing_ents.append(missing_ent)
103                    break
104
105        for m in todo_res[2].finditer("".join(lines)):
106            missing_ent = " ".join([m.group('tag'), m.group('app')])
107            if missing_ent not in missing_ents:
108                missing_ents.append(missing_ent)
109
110    finally:
111        fd.close()
112
113    if len(missing_ents):
114        print "\n".join(["%s: %s" % (os.path.basename(logfile), i) for i in ["Tag | App"] + missing_ents])
115    elif opts.verbose:
116        print "%s: CONGRATULATIONS -- no missing files found!" % os.path.basename(logfile)
117