Skip to content

Commit 1fef536

Browse files
committed
resilient-test-helper: Add --no-backward-deployment flag
This is used when the application changes in an incompatible way.
1 parent c2a38c1 commit 1fef536

File tree

1 file changed

+51
-36
lines changed

1 file changed

+51
-36
lines changed

utils/rth

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def verbose_print_command(command):
2626

2727
class ResilienceTest(object):
2828
def __init__(self, target_build_swift, target_run, tmp_dir, test_dir,
29-
test_src, additional_compile_flags_library):
29+
test_src, additional_compile_flags_library,
30+
no_backward_deployment):
3031
self.target_build_swift = shlex.split(target_build_swift)
3132
self.target_run = shlex.split(target_run)
3233
self.tmp_dir = tmp_dir
@@ -44,6 +45,8 @@ class ResilienceTest(object):
4445
self.lib_obj_name = self.lib_src_name[:-6] + '.o'
4546
self.lib_src = os.path.join(self.test_dir, 'Inputs', self.lib_src_name)
4647

48+
self.no_backward_deployment = no_backward_deployment
49+
4750
def run(self):
4851
self.set_up()
4952
self.compile_library()
@@ -73,44 +76,53 @@ class ResilienceTest(object):
7376

7477
def compile_main(self):
7578
for config in self.config_dir_map:
76-
output_obj = os.path.join(self.config_dir_map[config], 'main.o')
77-
compiler_flags = ['-D', config, '-c', self.test_src, '-I',
78-
self.config_dir_map[config], '-o', output_obj]
79-
command = self.target_build_swift + compiler_flags
80-
verbose_print_command(command)
81-
returncode = subprocess.call(command)
82-
assert returncode == 0, str(command)
83-
84-
def link(self):
79+
output_obj = os.path.join(self.config_dir_map[config], 'main.o')
80+
compiler_flags = ['-D', config, '-c', self.test_src, '-I',
81+
self.config_dir_map[config], '-o', output_obj]
82+
command = self.target_build_swift + compiler_flags
83+
verbose_print_command(command)
84+
returncode = subprocess.call(command)
85+
assert returncode == 0, str(command)
86+
87+
def configs(self):
8588
for config1 in self.config_dir_map:
8689
for config2 in self.config_dir_map:
87-
config1_lower = config1.lower()
88-
config2_lower = config2.lower()
89-
output_obj = os.path.join(self.tmp_dir,
90-
config1_lower + '_' + config2_lower)
91-
compiler_flags = [
92-
os.path.join(self.config_dir_map[config1],
93-
self.lib_obj_name),
94-
os.path.join(self.config_dir_map[config2],
95-
'main.o'),
96-
'-o', output_obj
97-
]
98-
command = self.target_build_swift + compiler_flags
99-
verbose_print_command(command)
100-
returncode = subprocess.call(command)
101-
assert returncode == 0, str(command)
90+
# --no-backward-deployment skips testing a new application
91+
# linked against an old library.
92+
if config1 == "BEFORE" and config2 == "AFTER" and \
93+
self.no_backward_deployment:
94+
continue
95+
96+
yield (config1, config2)
97+
98+
def link(self):
99+
for config1, config2 in self.configs():
100+
config1_lower = config1.lower()
101+
config2_lower = config2.lower()
102+
output_obj = os.path.join(self.tmp_dir,
103+
config1_lower + '_' + config2_lower)
104+
compiler_flags = [
105+
os.path.join(self.config_dir_map[config1],
106+
self.lib_obj_name),
107+
os.path.join(self.config_dir_map[config2],
108+
'main.o'),
109+
'-o', output_obj
110+
]
111+
command = self.target_build_swift + compiler_flags
112+
verbose_print_command(command)
113+
returncode = subprocess.call(command)
114+
assert returncode == 0, str(command)
102115

103116
def execute(self):
104-
for config1 in self.config_dir_map:
105-
for config2 in self.config_dir_map:
106-
config1_lower = config1.lower()
107-
config2_lower = config2.lower()
108-
output_obj = os.path.join(self.tmp_dir,
109-
config1_lower + '_' + config2_lower)
110-
command = self.target_run + [output_obj]
111-
verbose_print_command(command)
112-
returncode = subprocess.call(command)
113-
assert returncode == 0, str(command)
117+
for config1, config2 in self.configs():
118+
config1_lower = config1.lower()
119+
config2_lower = config2.lower()
120+
output_obj = os.path.join(self.tmp_dir,
121+
config1_lower + '_' + config2_lower)
122+
command = self.target_run + [output_obj]
123+
verbose_print_command(command)
124+
returncode = subprocess.call(command)
125+
assert returncode == 0, str(command)
114126

115127
def main():
116128
parser = argparse.ArgumentParser(description='Resilience test helper')
@@ -120,12 +132,15 @@ def main():
120132
parser.add_argument('--S', required=True)
121133
parser.add_argument('--s', required=True)
122134
parser.add_argument('--additional-compile-flags-library', default='')
135+
parser.add_argument('--no-backward-deployment', default=False,
136+
action='store_true')
123137

124138
args = parser.parse_args()
125139

126140
resilience_test = ResilienceTest(args.target_build_swift, args.target_run,
127141
args.t, args.S, args.s,
128-
args.additional_compile_flags_library)
142+
args.additional_compile_flags_library,
143+
args.no_backward_deployment)
129144

130145
return resilience_test.run()
131146

0 commit comments

Comments
 (0)