CernVM-FS
2.13.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
spec_test.py
Go to the documentation of this file.
1
#
2
# This file is part of the CernVM File System.
3
#
4
5
import
argparse
6
import
csv
7
8
def
get_parent
(path):
9
pos = path.rfind(
"/"
)
10
return
path[:pos]
if
pos>0
else
""
11
class
TraceParser
:
12
def
__init__
(self, args):
13
print(
"Parsing file: "
+ args.infile)
14
print(
"Output file: "
+ args.outfile)
15
print(
"Filters: "
+ (
","
.join(args.filters)
if
len(args.filters) > 0
else
"None"
))
16
self.
inputName
= args.infile
17
self.
outputName
= args.outfile
18
self.
filters
= { (f+
"()"
):
True
for
f
in
args.filters}
19
def
read_log
(self):
20
error =
False
21
pathsIncluded = {}
22
with open(self.
outputName
,
"
r") as logFile:
23
for
curLine
in
logFile:
24
#print(curLine)
25
pathsIncluded[curLine.strip()] =
True
26
#quit()
27
with open(self.
inputName
,
"
r") as logFile:
28
csvLogReader = csv.reader(logFile, delimiter=
','
, quotechar=
'"'
)
29
for
row
in
[r
30
for
r
in
csvLogReader
31
if
r[3]
not
in
self.
filters
and
int(r[1])>=0
32
and
r[2]
not
in
TraceParser.blacklist]:
33
# Iterate over not filtered elements
34
path = row[2]
if
row[2] !=
""
else
"/"
35
if
row[3] ==
"opendir()"
:
36
if
(
"^"
+row[2]+
"/*"
)
not
in
pathsIncluded:
37
error=
True
38
print(
"ERROR: "
+path+
" not included in spec! Searched for:"
)
39
print(
"^"
+path+
"/*"
)
40
elif
(
"^"
+path)
not
in
pathsIncluded\
41
and
(
"^"
+
get_parent
(path)+
"/*"
)
not
in
pathsIncluded\
42
and
(
"^"
+path+
"/*"
)
not
in
pathsIncluded:
43
error=
True
44
print(
"ERROR: "
+path+
" not included in spec! Searched for:"
)
45
print(
"^"
+path)
46
print(
"^"
+
get_parent
(path)+
"/*"
)
47
if
not
error:
48
print(
"SUCCESS"
)
49
quit(0)
50
else
:
51
print(
"ERROR"
)
52
quit(-1)
53
54
TraceParser.blacklist = [
"/.Trash"
,
"/.Trash-1000"
]
55
56
def
parse_args
():
57
argparser = argparse.ArgumentParser()
58
59
argparser.add_argument(
"infile"
,
60
type=str,
61
help=
"The trace log file"
)
62
63
argparser.add_argument(
"outfile"
,
64
type=str,
65
help=
"The output file"
)
66
67
argparser.add_argument(
"--filters"
,
68
required=
False
,
69
default=
""
,
70
nargs=
"+"
,
71
choices=[
"open"
,
"opendir"
,
"lookup"
,
"statfs"
,
"getattr"
,
"listxattr"
,
"getxattr"
,
"readlink"
],
72
help=
"Calls which should be filtered"
)
73
return
argparser.parse_args()
74
75
def
main
():
76
args =
parse_args
()
77
traceParser =
TraceParser
(args)
78
traceParser.read_log()
79
80
if
__name__ ==
"__main__"
:
81
main
()
spec_test.TraceParser.__init__
def __init__
Definition:
spec_test.py:12
spec_test.main
def main
Definition:
spec_test.py:75
spec_test.parse_args
def parse_args
Definition:
spec_test.py:56
spec_test.TraceParser.filters
filters
Definition:
spec_test.py:18
spec_test.get_parent
def get_parent
Definition:
spec_test.py:8
spec_test.TraceParser.read_log
def read_log
Definition:
spec_test.py:19
spec_test.TraceParser
Definition:
spec_test.py:11
spec_test.TraceParser.outputName
outputName
Definition:
spec_test.py:17
spec_test.TraceParser.inputName
inputName
Definition:
spec_test.py:16
cvmfs
cvmfs
shrinkwrap
scripts
spec_test.py
Generated on Sun Apr 20 2025 00:18:12 for CernVM-FS by
1.8.5