4 from AthenaCommon
import ChapPy
6 from future
import standard_library
7 standard_library.install_aliases()
16 if 'ATN_WORK_AREA' in os.environ:
17 workArea = os.environ[
'ATN_WORK_AREA']
19 workArea =
"tmp-pythinning"
21 if not os.path.exists(workArea):
23 return os.path.join( workArea, fileName )
26 def doValidation( validationName, refFileName, chkFileName, chkFilter ):
27 print (
"## Validation of [%s]" % validationName)
28 print (
"## ref: %s" % refFileName)
29 print (
"## chk: %s" % chkFileName)
30 print (
"## filter: [%s]" % chkFilter)
31 sc, out = subprocess.getstatusoutput(
"cat %s | %s | diff -u %s -" % \
32 ( chkFileName, chkFilter,
34 if sc == 0
and len(out) == 0:
print (
"==> Validation [OK]")
35 else:
print (
"==> Validation [ERROR]\n",
41 for refFile
in fileNames:
42 for fileName
in [ refFile,
workDir(refFile) ]:
43 if os.path.exists(fileName):
45 sc,out = subprocess.getstatusoutput(
"get_files %s" % refFile )
47 print (
"## ERROR: could not retrieve [%s]" % refFile)
48 print (
"## reason:\n",out)
50 if os.path.exists(refFile)
and \
51 os.path.exists(
workDir(refFile))
and \
52 os.path.samefile( refFile,
workDir(refFile) ):
53 print (
" -%s" %
workDir(refFile))
55 sc,out = subprocess.getstatusoutput(
"mv %s %s" % ( refFile,
58 print (
"## ERROR: could not install [%s] into [%s]" %
60 print (
"## reason:\n",out)
63 print (
" -%s" %
workDir(refFile))
68 print (
"## testing Thinning exercize...")
69 print (
"## installing reference files...")
71 "pyWriteThinnedData.ref",
72 "ReadThinnedData.ref",
73 "ReadNonThinnedData.ref",
79 print (
"## Preparing input data...")
81 ChapPy.JobOptionsCmd(
"OUTPUT=\"%s\"" %
workDir(
"my.pydata.tothin.pool") ),
82 ChapPy.JobOptions(
"AthExThinning/AthExThinning_makeData.py" ),
85 athena = ChapPy.Athena( jobOptions = jobOptions,
86 logFile =
workDir(
"my.pydata.tothin.pool.log" ),
88 athena.EvtMax = EVTMAX
95 workDir(
"AthExThinning_makeData.ref"),
96 workDir(
"my.pydata.tothin.pool.log"),
97 "grep '^CreateData' | grep INFO " )
99 raise SystemExit(
"ERROR")
104 print (
"## Testing [writing thinned data]...")
106 ChapPy.JobOptionsCmd(
"INPUT=[\"%s\"]" %
workDir(
"my.pydata.tothin.pool") ),
107 ChapPy.JobOptionsCmd(
"OUTPUT=\"%s\"" %
workDir(
"pythinned.data.pool") ),
108 ChapPy.JobOptionsCmd(
"ALGMODE=\"py\"" ),
109 ChapPy.JobOptions(
"AthExThinning/WriteThinnedData_jobOptions.py" ),
112 athena = ChapPy.Athena( jobOptions = jobOptions,
113 logFile =
workDir(
"pythinned.data.pool.log"),
122 workDir(
"pyWriteThinnedData.ref"),
123 workDir(
"pythinned.data.pool.log"),
124 "grep \"^Py:WriteThinnedData \"" )
126 raise SystemExit(
"ERROR")
131 print (
"## Testing [reading thinned data]...")
133 ChapPy.JobOptionsCmd(
"INPUT=[\"%s\"]" %
workDir(
"pythinned.data.pool") ),
134 ChapPy.JobOptionsCmd(
"OUTPUT=\"%s\"" %
workDir(
"reaccessed.pythinned.data.pool") ),
135 ChapPy.JobOptions(
"AthExThinning/ReadThinnedData_jobOptions.py" ),
138 athena = ChapPy.Athena( jobOptions = jobOptions,
139 logFile =
workDir(
"reaccessed.pythinned.data.pool.log"),
148 workDir(
"ReadThinnedData.ref"),
149 workDir(
"reaccessed.pythinned.data.pool.log"),
150 "grep \"^ReadThinnedData \" | grep -v \"Property update for OutputLevel\" | grep -v \"input handles\" | grep -v \"output handles\" | grep -v \"Data Deps for\"" )
152 raise SystemExit(
"ERROR")
158 print (
"## Testing [reading non-thinned data]...")
160 ChapPy.JobOptionsCmd(
"INPUT=[\"%s\"]" %
workDir(
"non.pythinned.data.pool") ),
161 ChapPy.JobOptionsCmd(
"OUTPUT=\"%s\"" %
workDir(
"reaccessed.non.pythinned.data.pool") ),
162 ChapPy.JobOptions(
"AthExThinning/ReadNonThinnedData_jobOptions.py" ),
165 athena = ChapPy.Athena( jobOptions = jobOptions,
166 logFile =
workDir(
"reaccessed.non.pythinned.data.pool.log"),
175 workDir(
"ReadNonThinnedData.ref"),
176 workDir(
"reaccessed.non.pythinned.data.pool.log"),
177 "grep \"^Py:ReadNonThinnedData \"" )
179 raise SystemExit(
"ERROR")
182 print (
"## [All tests completed]")