mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-06-24 14:20:59 +08:00
Move file backup support to config_common.py
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
f5408f0909
commit
035d7c8cfa
27
tests/scripts/depends.py
Normal file → Executable file
27
tests/scripts/depends.py
Normal file → Executable file
@ -47,7 +47,6 @@ a full config without a couple of slowing down or unnecessary options
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
@ -99,24 +98,6 @@ def log_command(cmd):
|
|||||||
cmd is a list of strings: a command name and its arguments."""
|
cmd is a list of strings: a command name and its arguments."""
|
||||||
log_line(' '.join(cmd), prefix='+')
|
log_line(' '.join(cmd), prefix='+')
|
||||||
|
|
||||||
def backup_config(options):
|
|
||||||
"""Back up the library configuration file (mbedtls_config.h).
|
|
||||||
If the backup file already exists, it is presumed to be the desired backup,
|
|
||||||
so don't make another backup."""
|
|
||||||
if os.path.exists(options.config_backup):
|
|
||||||
options.own_backup = False
|
|
||||||
else:
|
|
||||||
options.own_backup = True
|
|
||||||
shutil.copy(options.config, options.config_backup)
|
|
||||||
|
|
||||||
def restore_config(options):
|
|
||||||
"""Restore the library configuration file (mbedtls_config.h).
|
|
||||||
Remove the backup file if it was saved earlier."""
|
|
||||||
if options.own_backup:
|
|
||||||
shutil.move(options.config_backup, options.config)
|
|
||||||
else:
|
|
||||||
shutil.copy(options.config_backup, options.config)
|
|
||||||
|
|
||||||
def option_exists(conf, option):
|
def option_exists(conf, option):
|
||||||
return option in conf.settings
|
return option in conf.settings
|
||||||
|
|
||||||
@ -463,15 +444,13 @@ def run_tests(options, domain_data, conf):
|
|||||||
domain_data should be a DomainData instance that describes the available
|
domain_data should be a DomainData instance that describes the available
|
||||||
domains and jobs.
|
domains and jobs.
|
||||||
Run the jobs listed in options.tasks."""
|
Run the jobs listed in options.tasks."""
|
||||||
if not hasattr(options, 'config_backup'):
|
|
||||||
options.config_backup = options.config + '.bak'
|
|
||||||
colors = Colors(options)
|
colors = Colors(options)
|
||||||
jobs = []
|
jobs = []
|
||||||
failures = []
|
failures = []
|
||||||
successes = []
|
successes = []
|
||||||
for name in options.tasks:
|
for name in options.tasks:
|
||||||
jobs += domain_data.get_jobs(name)
|
jobs += domain_data.get_jobs(name)
|
||||||
backup_config(options)
|
conf.backup()
|
||||||
try:
|
try:
|
||||||
for job in jobs:
|
for job in jobs:
|
||||||
success = run(options, job, conf, colors=colors)
|
success = run(options, job, conf, colors=colors)
|
||||||
@ -482,13 +461,13 @@ Run the jobs listed in options.tasks."""
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
successes.append(job.name)
|
successes.append(job.name)
|
||||||
restore_config(options)
|
conf.restore()
|
||||||
except:
|
except:
|
||||||
# Restore the configuration, except in stop-on-error mode if there
|
# Restore the configuration, except in stop-on-error mode if there
|
||||||
# was an error, where we leave the failing configuration up for
|
# was an error, where we leave the failing configuration up for
|
||||||
# developer convenience.
|
# developer convenience.
|
||||||
if options.keep_going:
|
if options.keep_going:
|
||||||
restore_config(options)
|
conf.restore()
|
||||||
raise
|
raise
|
||||||
if successes:
|
if successes:
|
||||||
log_line('{} passed'.format(' '.join(successes)), color=colors.bold_green)
|
log_line('{} passed'.format(' '.join(successes)), color=colors.bold_green)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user