[6844] | 1 | ''' |
---|
| 2 | Automatic verification that the ANUGA code runs the Patong simulation |
---|
| 3 | and produces the expected output. |
---|
| 4 | |
---|
| 5 | Required files are downloaded from the ANUGA servers if they are |
---|
| 6 | out of date or missing. |
---|
| 7 | ''' |
---|
| 8 | |
---|
| 9 | import sys |
---|
| 10 | import os |
---|
| 11 | import glob |
---|
| 12 | import unittest |
---|
| 13 | import time |
---|
| 14 | import shutil |
---|
| 15 | |
---|
[7544] | 16 | from anuga.utilities.system_tools \ |
---|
| 17 | import get_web_file, untar_file, file_length, get_host_name |
---|
[6844] | 18 | import anuga.utilities.log as log |
---|
| 19 | |
---|
[7567] | 20 | log.log_filename = './validation.log' |
---|
[6844] | 21 | |
---|
[6890] | 22 | # sourceforge download mirror hosts (must end with '/') |
---|
| 23 | # try these in turn for each file |
---|
| 24 | ## NOTE: It would be more reliable if we could somehow 'poll' Sourceforge |
---|
[6931] | 25 | ## for a list of mirrors instead of hard-coding a list here. The only |
---|
| 26 | ## way to do this at the moment is to 'screen-scrape' the data at |
---|
| 27 | ## http://apps.sourceforge.net/trac/sourceforge/wiki/Mirrors |
---|
| 28 | ## but that only gets the main web page for the entity, not the |
---|
| 29 | ## Sourceforge download mirror server. |
---|
[6890] | 30 | MIRRORS = ['http://transact.dl.sourceforge.net/sourceforge/anuga/', # au |
---|
| 31 | 'http://voxel.dl.sourceforge.net/sourceforge/anuga/', # us |
---|
| 32 | 'http://superb-west.dl.sourceforge.net/sourceforge/anuga/', # us |
---|
| 33 | 'http://jaist.dl.sourceforge.net/sourceforge/anuga/', # jp |
---|
| 34 | 'http://dfn.dl.sourceforge.net/sourceforge/anuga/' # de |
---|
| 35 | ] |
---|
[7276] | 36 | |
---|
[6931] | 37 | ### for testing |
---|
[6890] | 38 | ##MIRRORS = ['http://10.7.64.243/patong_validation_data/'] # local linux box |
---|
[6844] | 39 | |
---|
[6890] | 40 | # URL to hand-get data files, if required |
---|
[6931] | 41 | DATA_FILES_URL = ('http://sourceforge.net/project/showfiles.php?' |
---|
| 42 | 'group_id=172848&package_id=319323&release_id=677531') |
---|
[6890] | 43 | |
---|
| 44 | # sequence of mandatory local data objects |
---|
| 45 | Mandatory_Data_Objects = ('data.tgz',) |
---|
| 46 | |
---|
[6903] | 47 | # sequence of optional local data objects. |
---|
| 48 | # these names must be of the form <scene>.sww.<type>.tgz |
---|
| 49 | # as code below depends upon it. |
---|
[7643] | 50 | Optional_Data_Objects = ( |
---|
| 51 | 'patong.sww.TRIAL.tgz', |
---|
| 52 | 'patong.sww.BASIC.tgz', |
---|
| 53 | 'patong.sww.FINAL.tgz' |
---|
| 54 | ) |
---|
[7649] | 55 | Optional_Data_Objects = ('patong.sww.TRIAL.tgz',) |
---|
[6890] | 56 | |
---|
[7649] | 57 | # Associated tolerances to be used in comparisons (would depend on discretisation errors) |
---|
| 58 | epsilon = {'patong.sww.TRIAL.tgz': 1.0e-3, |
---|
| 59 | 'patong.sww.BASIC.tgz': 1.0e-4, |
---|
| 60 | 'patong.sww.FINAL.tgz': 1.0e-5} |
---|
| 61 | |
---|
| 62 | |
---|
[6844] | 63 | # path to the local data directory |
---|
[6890] | 64 | Local_Data_Directory = 'local_data' |
---|
[6844] | 65 | |
---|
| 66 | # path to the remote data directory |
---|
[6890] | 67 | Remote_Data_Directory = 'remote_data' |
---|
[6844] | 68 | |
---|
| 69 | # name of stdout catch file for runmodel.py |
---|
| 70 | RUNMODEL_STDOUT = 'runmodel.stdout' |
---|
| 71 | |
---|
| 72 | # text at start of 'output dir' line in RUNMODEL_STDOUT file |
---|
[7641] | 73 | OUTDIR_PREFIX = 'Output directory: ' |
---|
[6844] | 74 | |
---|
[6906] | 75 | # Name of SWW file produced by run_model.py |
---|
[6844] | 76 | OUTPUT_SWW = 'patong.sww' |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | def setup(): |
---|
[7276] | 80 | '''Prepare for the validation run.''' |
---|
[6844] | 81 | |
---|
| 82 | pass |
---|
| 83 | |
---|
| 84 | |
---|
[6890] | 85 | def refresh_local_data(data_objects, target_dir, mirrors): |
---|
[6844] | 86 | '''Update local data objects from the server. |
---|
| 87 | |
---|
[6890] | 88 | data_objects: list of files to refresh |
---|
| 89 | target_dir: directory in which to put files |
---|
| 90 | mirrors: list of mirror sites to use |
---|
| 91 | |
---|
| 92 | Each file has an associated *.digest file used to decide |
---|
| 93 | if the local file needs refreshing. |
---|
| 94 | |
---|
[6844] | 95 | Return True if all went well, else False. |
---|
| 96 | ''' |
---|
[6890] | 97 | |
---|
| 98 | # decision function to decide if a file contains HTML |
---|
| 99 | def is_html(filename): |
---|
| 100 | '''Decide if given file contains HTML.''' |
---|
| 101 | |
---|
| 102 | fd = open(filename) |
---|
| 103 | data = fd.read(1024) |
---|
| 104 | fd.close() |
---|
| 105 | |
---|
| 106 | if 'DOCTYPE' in data: |
---|
[6906] | 107 | return True |
---|
[6890] | 108 | |
---|
[6906] | 109 | return False |
---|
[6890] | 110 | |
---|
[6844] | 111 | |
---|
[6890] | 112 | # local function to get remote file from one of mirrors |
---|
| 113 | def get_remote_from_mirrors(remote, local, auth, mirrors): |
---|
| 114 | '''Get 'remote' from one of 'mirrors', put in 'local'.''' |
---|
| 115 | |
---|
| 116 | # Get a unique date+time string to defeat caching. The idea is to add |
---|
| 117 | # this to the end of any URL so proxy sees a different request. |
---|
| 118 | cache_defeat = '?' + time.strftime('%Y%m%d%H%M%S') |
---|
| 119 | |
---|
| 120 | # try each mirror when getting file |
---|
| 121 | for mirror in mirrors: |
---|
[6891] | 122 | log.debug('Fetching remote file %s from mirror %s' |
---|
| 123 | % (remote, mirror)) |
---|
[6890] | 124 | |
---|
| 125 | remote_url = mirror + remote + cache_defeat |
---|
[6891] | 126 | (result, auth) = get_web_file(remote_url, local, auth=auth) |
---|
| 127 | if result and is_html(local)==False: |
---|
[6906] | 128 | log.debug('Success fetching file %s' % remote) |
---|
[6891] | 129 | return (True, auth) |
---|
[6906] | 130 | log.debug('Failure fetching from %s' % mirror) |
---|
[7196] | 131 | auth = None |
---|
[6890] | 132 | |
---|
[6906] | 133 | log.debug('Failure fetching file %s' % remote) |
---|
[6891] | 134 | return (False, auth) |
---|
[6890] | 135 | |
---|
| 136 | |
---|
| 137 | # local function to compare contents of two files |
---|
| 138 | def files_same(file_a, file_b): |
---|
| 139 | '''Compare two files to see if contents are the same.''' |
---|
| 140 | |
---|
| 141 | fd = open(file_a, 'r') |
---|
| 142 | data_a = fd.read() |
---|
| 143 | fd.close() |
---|
| 144 | |
---|
| 145 | fd = open(file_b, 'r') |
---|
| 146 | data_b = fd.read() |
---|
| 147 | fd.close() |
---|
| 148 | |
---|
| 149 | return data_a == data_b |
---|
| 150 | |
---|
| 151 | |
---|
[6844] | 152 | # local function to update one data object |
---|
[6890] | 153 | def refresh_object(obj, auth, mirrors): |
---|
[6844] | 154 | '''Update object 'obj' using authentication tuple 'auth'. |
---|
| 155 | |
---|
[6891] | 156 | Return (True, <updated_auth>) if all went well, |
---|
| 157 | else (False, <updated_auth>). |
---|
[6844] | 158 | ''' |
---|
| 159 | |
---|
[6890] | 160 | # create local and remote file paths. |
---|
| 161 | obj_digest = obj + '.digest' |
---|
[6844] | 162 | |
---|
[6890] | 163 | remote_file = os.path.join(Remote_Data_Directory, obj) |
---|
| 164 | remote_digest = remote_file + '.digest' |
---|
| 165 | |
---|
| 166 | local_file = os.path.join(Local_Data_Directory, obj) |
---|
[6844] | 167 | local_digest = local_file + '.digest' |
---|
| 168 | |
---|
| 169 | # see if missing either digest or object .tgz |
---|
| 170 | if not os.path.exists(local_digest) or not os.path.exists(local_file): |
---|
| 171 | # no digest or no object, download both digest and object |
---|
[6891] | 172 | (res, auth) = get_remote_from_mirrors(obj_digest, local_digest, auth, mirrors) |
---|
| 173 | if res: |
---|
| 174 | (res, auth) = get_remote_from_mirrors(obj, local_file, auth, mirrors) |
---|
[6844] | 175 | else: |
---|
| 176 | # download object digest to remote data directory |
---|
[6891] | 177 | (res, auth) = get_remote_from_mirrors(obj_digest, remote_digest, auth, mirrors) |
---|
| 178 | if res: |
---|
[6918] | 179 | if not files_same(local_digest, remote_digest): |
---|
[6890] | 180 | # digests differ, refresh object |
---|
| 181 | shutil.move(remote_digest, local_digest) |
---|
[6891] | 182 | (res, auth) = get_remote_from_mirrors(obj, local_file, auth, mirrors) |
---|
[6903] | 183 | |
---|
[6891] | 184 | return (res, auth) |
---|
[6844] | 185 | |
---|
| 186 | # create local data directory if required |
---|
| 187 | log.debug('Creating local directory: %s' % Local_Data_Directory) |
---|
| 188 | if not os.path.exists(Local_Data_Directory): |
---|
| 189 | os.mkdir(Local_Data_Directory) |
---|
| 190 | |
---|
| 191 | # clean out remote data copy directory |
---|
| 192 | log.debug('Cleaning remote directory: %s' % Remote_Data_Directory) |
---|
| 193 | shutil.rmtree(Remote_Data_Directory, ignore_errors=True) |
---|
| 194 | os.mkdir(Remote_Data_Directory) |
---|
| 195 | |
---|
[6890] | 196 | # success, refresh local files |
---|
[6844] | 197 | auth = None |
---|
[6891] | 198 | result = True |
---|
| 199 | for data_object in data_objects: |
---|
[6903] | 200 | log.info("Refreshing file '%s'" % data_object) |
---|
[6891] | 201 | log.debug('refresh_local_data: getting %s from mirrors, auth=%s' |
---|
| 202 | % (data_object, str(auth))) |
---|
| 203 | (res, auth) = refresh_object(data_object, auth, mirrors) |
---|
| 204 | log.debug('refresh_local_data: returned (res,auth)=%s,%s' |
---|
| 205 | % (str(res), str(auth))) |
---|
| 206 | if res == False: |
---|
[6903] | 207 | log.info('Refresh of file %s failed.' % data_object) |
---|
[6891] | 208 | result = False |
---|
[7196] | 209 | # don't use possibly bad 'auth' again, |
---|
| 210 | # some proxies lock out on repeated failures. |
---|
| 211 | auth = None |
---|
[6844] | 212 | |
---|
[6903] | 213 | if result: |
---|
[6925] | 214 | log.critical('Local data has been refreshed.') |
---|
[6903] | 215 | else: |
---|
[6925] | 216 | log.critical('Local data has been refreshed, with one or more errors.') |
---|
| 217 | log.critical() |
---|
[6891] | 218 | return result |
---|
[6844] | 219 | |
---|
| 220 | |
---|
| 221 | def can_we_run(): |
---|
| 222 | '''Decide if we can run with the files we have. |
---|
| 223 | |
---|
| 224 | Return True if we *can* run, else False. |
---|
| 225 | |
---|
| 226 | Tell user what is happening first, then untar files. |
---|
| 227 | ''' |
---|
| 228 | |
---|
[6890] | 229 | log.critical('Checking if you have the required files to run:') |
---|
[6844] | 230 | |
---|
[6891] | 231 | # get max width of object name string |
---|
[6844] | 232 | max_width = 0 |
---|
[6890] | 233 | for obj in Mandatory_Data_Objects: |
---|
[6844] | 234 | max_width = max(len(obj), max_width) |
---|
[6890] | 235 | for obj in Optional_Data_Objects: |
---|
| 236 | max_width = max(len(obj), max_width) |
---|
[6844] | 237 | |
---|
[6891] | 238 | # if we don't have *all* mandatory object, can't run |
---|
| 239 | have_mandatory_files = True |
---|
[6890] | 240 | for obj in Mandatory_Data_Objects: |
---|
| 241 | obj_path = os.path.join(Local_Data_Directory, obj) |
---|
[6844] | 242 | if os.path.exists(obj_path): |
---|
[6890] | 243 | log.info('\t%s found' % obj.ljust(max_width)) |
---|
[6844] | 244 | else: |
---|
[6890] | 245 | log.info('\t%s MISSING AND REQUIRED!' % obj.ljust(max_width)) |
---|
| 246 | have_mandatory_files = False |
---|
[6844] | 247 | |
---|
[6891] | 248 | # at least *one* of these must exist |
---|
| 249 | have_optional_files = False |
---|
[6890] | 250 | for obj in Optional_Data_Objects: |
---|
| 251 | obj_path = os.path.join(Local_Data_Directory, obj) |
---|
| 252 | if os.path.exists(obj_path): |
---|
[6891] | 253 | have_optional_files = True |
---|
[6890] | 254 | log.info('\t%s found' % obj.ljust(max_width)) |
---|
| 255 | else: |
---|
| 256 | log.info('\t%s MISSING!' % obj.ljust(max_width)) |
---|
| 257 | |
---|
| 258 | if not have_mandatory_files or not have_optional_files: |
---|
[6844] | 259 | log.critical('You must obtain the missing files before you can run ' |
---|
| 260 | 'this validation.') |
---|
| 261 | return False |
---|
| 262 | |
---|
[6925] | 263 | log.critical('You have enough required files to run.') |
---|
| 264 | log.critical() |
---|
[6844] | 265 | |
---|
| 266 | return True |
---|
| 267 | |
---|
| 268 | |
---|
[6891] | 269 | def set_environment(): |
---|
| 270 | # modify environment so we use the local data |
---|
| 271 | new_inundationhome = os.path.join(Local_Data_Directory, '') |
---|
| 272 | os.environ['INUNDATIONHOME'] = new_inundationhome |
---|
| 273 | new_muxhome = os.path.join(Local_Data_Directory, 'data') |
---|
| 274 | os.environ['MUXHOME'] = new_muxhome |
---|
| 275 | |
---|
| 276 | |
---|
[6890] | 277 | def run_simulation(vtype, sim_obj): |
---|
[6891] | 278 | '''Run a simulation. |
---|
| 279 | |
---|
| 280 | Returns True if all went well, else False. |
---|
| 281 | ''' |
---|
[6844] | 282 | |
---|
[6891] | 283 | # untar the object |
---|
[6890] | 284 | tar_path = os.path.join(Local_Data_Directory, sim_obj) |
---|
| 285 | log.info('Untarring %s in directory %s ...' |
---|
| 286 | % (tar_path, Local_Data_Directory)) |
---|
| 287 | untar_file(tar_path, target_dir=Local_Data_Directory) |
---|
| 288 | |
---|
| 289 | # modify project.py template |
---|
[6918] | 290 | log.debug("Creating '%s' version of project.py" % vtype) |
---|
[7267] | 291 | fd = open('project_template.py', 'r') |
---|
[6890] | 292 | project = fd.readlines() |
---|
| 293 | fd.close() |
---|
| 294 | |
---|
| 295 | new_project = [] |
---|
| 296 | for line in project: |
---|
| 297 | new_project.append(line.replace('#!SETUP!#', vtype.lower())) |
---|
| 298 | |
---|
| 299 | fd = open('project.py', 'w') |
---|
| 300 | fd.write(''.join(new_project)) |
---|
| 301 | fd.close() |
---|
| 302 | |
---|
[6891] | 303 | # import new project.py |
---|
[6844] | 304 | import project |
---|
| 305 | |
---|
| 306 | # run the simulation, produce SWW file |
---|
[6925] | 307 | log.info('Running the simulation ...') |
---|
[7276] | 308 | cmd = 'python run_model.py > %s' % RUNMODEL_STDOUT |
---|
[6891] | 309 | log.debug("run_simulation: doing '%s'" % cmd) |
---|
[6844] | 310 | res = os.system(cmd) |
---|
[6891] | 311 | log.debug("run_simulation: res=%d" % res) |
---|
[6844] | 312 | |
---|
[6891] | 313 | # 'unimport' project.py |
---|
| 314 | del project |
---|
| 315 | |
---|
| 316 | # check result |
---|
| 317 | if res != 0: |
---|
| 318 | log.critical('Simulation failed, check log') |
---|
| 319 | |
---|
| 320 | return res == 0 |
---|
| 321 | |
---|
[7649] | 322 | def check_that_output_is_as_expected(expected_sww, valid_sww, epsilon): |
---|
[6844] | 323 | '''Check that validation output is as required.''' |
---|
| 324 | |
---|
| 325 | # get path to expected SWW file |
---|
| 326 | log.critical('Checking that simulation results are as expected ...') |
---|
[6903] | 327 | local_sww = os.path.join(Local_Data_Directory, valid_sww) |
---|
[6844] | 328 | |
---|
| 329 | # get output directory from stdout capture file |
---|
| 330 | try: |
---|
| 331 | fd = open(RUNMODEL_STDOUT, 'r') |
---|
| 332 | except IOError, e: |
---|
| 333 | log.critical("Can't open catch file '%s': %s" |
---|
| 334 | % (RUNMODEL_STDOUT, str(e))) |
---|
| 335 | return 1 |
---|
| 336 | lines = fd.readlines() |
---|
| 337 | fd.close |
---|
| 338 | |
---|
| 339 | output_directory = None |
---|
| 340 | for line in lines: |
---|
| 341 | if line.startswith(OUTDIR_PREFIX): |
---|
| 342 | output_directory = line.replace(OUTDIR_PREFIX, '', 1) |
---|
[7641] | 343 | output_directory = output_directory.strip() |
---|
[6844] | 344 | break |
---|
| 345 | if output_directory is None: |
---|
| 346 | log.critical("Couldn't find line starting with '%s' in file '%s'" |
---|
| 347 | % (OUTDIR_PREFIX, RUNMODEL_STDOUT)) |
---|
| 348 | return 1 |
---|
| 349 | |
---|
[6891] | 350 | log.debug('check_that_output_is_as_expected: output_directory=%s' |
---|
| 351 | % output_directory) |
---|
| 352 | |
---|
[6844] | 353 | # compare SWW files here and there |
---|
[6903] | 354 | new_output_sww = os.path.join(output_directory, expected_sww) |
---|
[7640] | 355 | #cmd = 'python cmpsww.py %s %s > cmpsww.stdout' % (local_sww, new_output_sww) |
---|
[7649] | 356 | cmd = 'python compare_model_timeseries.py %s %s %e > compare_model_timeseries.stdout' %\ |
---|
| 357 | (local_sww, new_output_sww, epsilon) |
---|
[7645] | 358 | print '-------------------------------------' |
---|
| 359 | print cmd |
---|
| 360 | print '-------------------------------------' |
---|
| 361 | |
---|
[6891] | 362 | log.debug("check_that_output_is_as_expected: doing '%s'" % cmd) |
---|
[6844] | 363 | res = os.system(cmd) |
---|
[6891] | 364 | log.debug("check_that_output_is_as_expected: res=%d" % res) |
---|
[6918] | 365 | log.critical() |
---|
[6844] | 366 | if res == 0: |
---|
| 367 | log.info('Simulation results are as expected.') |
---|
| 368 | else: |
---|
| 369 | log.critical('Simulation results are NOT as expected.') |
---|
[7641] | 370 | fd = open('compare_model_timeseries.stdout', 'r') |
---|
[6844] | 371 | cmp_error = fd.readlines() |
---|
| 372 | fd.close() |
---|
[6918] | 373 | log.critical(''.join(cmp_error)) |
---|
[6844] | 374 | |
---|
| 375 | |
---|
| 376 | def teardown(): |
---|
| 377 | '''Clean up after validation run.''' |
---|
[6891] | 378 | |
---|
| 379 | log.debug('teardown: called') |
---|
[6844] | 380 | |
---|
| 381 | # remove remote directory and stdout capture file |
---|
[7641] | 382 | #shutil.rmtree(Remote_Data_Directory, ignore_errors=True) |
---|
| 383 | #try: |
---|
| 384 | # os.remove(RUNMODEL_STDOUT) |
---|
| 385 | #except OSError: |
---|
| 386 | # pass |
---|
[6844] | 387 | |
---|
| 388 | |
---|
| 389 | ################################################################################ |
---|
| 390 | # Mainline - run the simulation, check output. |
---|
| 391 | ################################################################################ |
---|
| 392 | |
---|
| 393 | # set logging levels |
---|
| 394 | log.console_logging_level = log.INFO |
---|
[6891] | 395 | log.log_logging_level = log.DEBUG |
---|
[6918] | 396 | |
---|
[7544] | 397 | log.debug("Machine we are running on is '%s'" % get_host_name()) |
---|
[6844] | 398 | setup() |
---|
| 399 | |
---|
| 400 | # prepare user for what is about to happen |
---|
[7276] | 401 | log.critical(''' |
---|
[7040] | 402 | Please note that this validation test is accurate only on 64bit Linux or |
---|
| 403 | Windows. Running the validation on a 32bit operating system will result in |
---|
| 404 | small differences in the generated mesh which defeats the simplistic test for |
---|
| 405 | equality between the generated and expected SWW files. |
---|
| 406 | |
---|
[6918] | 407 | This validation requires a working internet connection to refresh its files. |
---|
[6890] | 408 | You may still run this validation without an internet connection if you have the |
---|
| 409 | required files. |
---|
| 410 | |
---|
| 411 | If you are behind a proxy server you will need to supply your proxy details |
---|
| 412 | such as the proxy server address and your proxy username and password. These |
---|
| 413 | can be defined in one or more of the environment variables: |
---|
| 414 | HTTP_PROXY |
---|
| 415 | PROXY_USERNAME |
---|
| 416 | PROXY_PASSWORD |
---|
| 417 | if you wish. If not supplied in environment variables you will be prompted for |
---|
| 418 | the information. |
---|
[7276] | 419 | ''') |
---|
[6890] | 420 | |
---|
| 421 | |
---|
[6844] | 422 | # make sure local data is up to date |
---|
[6891] | 423 | all_objects = Mandatory_Data_Objects + Optional_Data_Objects |
---|
| 424 | if not refresh_local_data(all_objects, Local_Data_Directory, MIRRORS): |
---|
[6844] | 425 | if not can_we_run(): |
---|
[6890] | 426 | log.critical("Can't refresh via the internet and you don't have the " |
---|
[6844] | 427 | "required files.") |
---|
| 428 | log.critical('Terminating the validation.') |
---|
| 429 | log.critical('') |
---|
[6890] | 430 | log.critical('If you get the missing files from %s' % DATA_FILES_URL) |
---|
| 431 | log.critical('then you can try to run the validation again. Put the ' |
---|
| 432 | 'files into the directory') |
---|
| 433 | log.critical("%s." % Local_Data_Directory) |
---|
[6844] | 434 | sys.exit(10) |
---|
| 435 | |
---|
[6891] | 436 | # now untar mandatory objects |
---|
| 437 | for obj in Mandatory_Data_Objects: |
---|
| 438 | tar_path = os.path.join(Local_Data_Directory, obj) |
---|
| 439 | log.info('Untarring %s in directory %s ...' |
---|
| 440 | % (tar_path, Local_Data_Directory)) |
---|
| 441 | untar_file(tar_path, target_dir=Local_Data_Directory) |
---|
| 442 | |
---|
| 443 | # set required environment variables |
---|
| 444 | set_environment() |
---|
| 445 | |
---|
[6890] | 446 | # now run what simulations we can and check output is as expected |
---|
| 447 | for odo in Optional_Data_Objects: |
---|
[6918] | 448 | start_time = time.time() |
---|
[7276] | 449 | |
---|
[6890] | 450 | (_, vtype, _) = odo.rsplit('.', 2) |
---|
| 451 | vtype = vtype.lower() |
---|
[6918] | 452 | log.critical('#' * 72) |
---|
[6891] | 453 | log.critical("Running Patong '%s' validation ..." % vtype) |
---|
| 454 | if run_simulation(vtype, odo): |
---|
[6903] | 455 | # get SWW names expected and valid, check 'equal' |
---|
| 456 | (valid_sww, _) = odo.rsplit('.', 1) |
---|
| 457 | (expected_sww, _) = valid_sww.rsplit('.', 1) |
---|
[7649] | 458 | check_that_output_is_as_expected(expected_sww, valid_sww, epsilon[odo]) |
---|
[7276] | 459 | |
---|
[6918] | 460 | stop_time = time.time() |
---|
[7276] | 461 | log.critical("'%s' validation took %.1fs\n\n\n" % (vtype, stop_time - start_time)) |
---|
[6844] | 462 | |
---|
| 463 | # clean up |
---|
[7276] | 464 | log.critical('Tearing down ...') |
---|
[6891] | 465 | teardown() |
---|