Skip to content

Commit adc82f3

Browse files
gilles-peskine-armdgreen-arm
authored andcommitted
Add set+get tests
The tests were not covering get for a symbol with a value. No symbol has an uncommented value in the default config.h. (Actually there's _CRT_SECURE_NO_DEPRECATE, but that's a bit of a hack that this script is not expected to handle, so don't use it). Add tests of "get FOO" after "set FOO" and "set FOO value", so that we have coverage for "get FOO" when "FOO" has a value.
1 parent bc86f99 commit adc82f3

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tests/scripts/test_config_script.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,30 @@ def list_presets(options):
9696
stderr=subprocess.STDOUT).stdout
9797
return guess_presets_from_help(help_text.decode('ascii'))
9898

99-
def run_one(options, args):
99+
def run_one(options, args, stem_prefix='', input_file=None):
100100
"""Run the config script with the given arguments.
101101
102-
Write the following files:
102+
Take the original content from input_file if specified, defaulting
103+
to options.input_file if input_file is None.
104+
105+
Write the following files, where xxx contains stem_prefix followed by
106+
a filename-friendly encoding of args:
103107
* config-xxx.h: modified file.
104108
* config-xxx.out: standard output.
105109
* config-xxx.err: standard output.
106110
* config-xxx.status: exit code.
111+
112+
Return ("xxx+", "path/to/config-xxx.h") which can be used as
113+
stem_prefix and input_file to call this function again with new args.
107114
"""
108-
stem = '-'.join(args)
115+
if input_file is None:
116+
input_file = options.input_file
117+
stem = stem_prefix + '-'.join(args)
109118
data_filename = output_file_name(options.output_directory, stem, 'h')
110119
stdout_filename = output_file_name(options.output_directory, stem, 'out')
111120
stderr_filename = output_file_name(options.output_directory, stem, 'err')
112121
status_filename = output_file_name(options.output_directory, stem, 'status')
113-
shutil.copy(options.input_file, data_filename)
122+
shutil.copy(input_file, data_filename)
114123
# Pass only the file basename, not the full path, to avoid getting the
115124
# directory name in error messages, which would make comparisons
116125
# between output directories more difficult.
@@ -124,6 +133,7 @@ def run_one(options, args):
124133
stdout=out, stderr=err)
125134
with open(status_filename, 'w') as status_file:
126135
status_file.write('{}\n'.format(status))
136+
return stem + "+", data_filename
127137

128138
### A list of symbols to test with.
129139
### This script currently tests what happens when you change a symbol from
@@ -145,9 +155,11 @@ def run_all(options):
145155
run_one(options, [preset])
146156
for symbol in TEST_SYMBOLS:
147157
run_one(options, ['get', symbol])
148-
run_one(options, ['set', symbol])
158+
(stem, filename) = run_one(options, ['set', symbol])
159+
run_one(options, ['get', symbol], stem_prefix=stem, input_file=filename)
149160
run_one(options, ['--force', 'set', symbol])
150-
run_one(options, ['set', symbol, 'value'])
161+
(stem, filename) = run_one(options, ['set', symbol, 'value'])
162+
run_one(options, ['get', symbol], stem_prefix=stem, input_file=filename)
151163
run_one(options, ['--force', 'set', symbol, 'value'])
152164
run_one(options, ['unset', symbol])
153165

0 commit comments

Comments
 (0)