mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Use unique identifiers in conformtest.
This patch makes tests in conformtest use unique identifiers, in preparation for trying to cover more tests in a single compilation to speed up these tests as suggested in <https://sourceware.org/ml/libc-alpha/2018-11/msg00229.html>. Tests are assigned a number, used in generating identifiers; where a single call to a run method does multiple compilations (sharing that number), identifiers are changed as needed to avoid duplication between those compilations, so they can be combined in future. Large numbers of positional arguments to format strings make the code harder to follow, and using the test numbers serves to increase the number of arguments to such format strings, so the code is generally changed to use %(name)s where all the arguments come from attributes of the test object and so vars(self) is sufficient to provide all those names for the format string. Cases where some arguments aren't attributes of self still use positional format arguments. Tested for x86_64, and with build-many-glibcs.py. * conform/conformtest.py (ElementTest.run): Use unique identifiers in tests. Use names for format arguments. (ConstantTest.run): Likewise. (SymbolTest.run): Likewise. (TypeTest.run): Likewise. (TagTest.run): Likewise. (FunctionTest.run): Likewise. (VariableTest.run): Likewise. (MacroFunctionTest.run): Likewise. (MacroStrTest.run): Likewise. (HeaderTests.__init__): Set self.num_tests. (HeaderTests.handle_test_line): Set test.num. Increment self.num_tests.
This commit is contained in:
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
|||||||
|
2018-11-20 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
* conform/conformtest.py (ElementTest.run): Use unique identifiers
|
||||||
|
in tests. Use names for format arguments.
|
||||||
|
(ConstantTest.run): Likewise.
|
||||||
|
(SymbolTest.run): Likewise.
|
||||||
|
(TypeTest.run): Likewise.
|
||||||
|
(TagTest.run): Likewise.
|
||||||
|
(FunctionTest.run): Likewise.
|
||||||
|
(VariableTest.run): Likewise.
|
||||||
|
(MacroFunctionTest.run): Likewise.
|
||||||
|
(MacroStrTest.run): Likewise.
|
||||||
|
(HeaderTests.__init__): Set self.num_tests.
|
||||||
|
(HeaderTests.handle_test_line): Set test.num. Increment
|
||||||
|
self.num_tests.
|
||||||
|
|
||||||
2018-11-19 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
2018-11-19 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||||
|
|
||||||
* sysdeps/mach/hurd/f_setlk.c: Include <unistd.h>.
|
* sysdeps/mach/hurd/f_setlk.c: Include <unistd.h>.
|
||||||
|
@ -41,24 +41,24 @@ class ElementTest(object):
|
|||||||
|
|
||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run an ElementTest."""
|
"""Run an ElementTest."""
|
||||||
text = ('%s a;\n'
|
text = ('%(type_name)s a_%(num)d;\n'
|
||||||
'%s b;\n'
|
'%(type_name)s b_%(num)d;\n'
|
||||||
'extern void xyzzy (__typeof__ (&b.%s), __typeof__ (&a.%s), '
|
'extern void xyzzy_%(num)d '
|
||||||
'unsigned);\n'
|
'(__typeof__ (&b_%(num)d.%(member_name)s), '
|
||||||
'void foobarbaz (void) {\n'
|
'__typeof__ (&a_%(num)d.%(member_name)s), unsigned);\n'
|
||||||
'xyzzy (&a.%s, &b.%s, sizeof (a.%s));\n'
|
'void foobarbaz_%(num)d (void) {\n'
|
||||||
|
'xyzzy_%(num)d (&a_%(num)d.%(member_name)s, '
|
||||||
|
'&b_%(num)d.%(member_name)s, '
|
||||||
|
'sizeof (a_%(num)d.%(member_name)s));\n'
|
||||||
'}\n'
|
'}\n'
|
||||||
% (self.type_name, self.type_name,
|
% vars(self))
|
||||||
self.member_name, self.member_name,
|
|
||||||
self.member_name, self.member_name, self.member_name))
|
|
||||||
header_tests.compile_test('Availability of member %s'
|
header_tests.compile_test('Availability of member %s'
|
||||||
% self.member_name,
|
% self.member_name,
|
||||||
text)
|
text)
|
||||||
text = ('%s a;\n'
|
text = ('%(type_name)s a2_%(num)d;\n'
|
||||||
'extern %s b%s;\n'
|
'extern %(member_type)s b2_%(num)d%(rest)s;\n'
|
||||||
'extern __typeof__ (a.%s) b;\n'
|
'extern __typeof__ (a2_%(num)d.%(member_name)s) b2_%(num)d;\n'
|
||||||
% (self.type_name, self.member_type, self.rest,
|
% vars(self))
|
||||||
self.member_name))
|
|
||||||
header_tests.compile_test('Type of member %s' % self.member_name,
|
header_tests.compile_test('Type of member %s' % self.member_name,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -85,69 +85,73 @@ class ConstantTest(object):
|
|||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run a ConstantTest."""
|
"""Run a ConstantTest."""
|
||||||
if 'macro' in self.symbol_type:
|
if 'macro' in self.symbol_type:
|
||||||
text = ('#ifndef %s\n'
|
text = ('#ifndef %(symbol)s\n'
|
||||||
'# error "Macro %s not defined"\n'
|
'# error "Macro %(symbol)s not defined"\n'
|
||||||
'#endif\n'
|
'#endif\n'
|
||||||
% (self.symbol, self.symbol))
|
% vars(self))
|
||||||
header_tests.compile_test('Availability of macro %s'
|
header_tests.compile_test('Availability of macro %s'
|
||||||
% self.symbol,
|
% self.symbol,
|
||||||
text)
|
text)
|
||||||
if 'constant' in self.symbol_type:
|
if 'constant' in self.symbol_type:
|
||||||
text = ('__typeof__ (%s) a = %s;\n'
|
text = ('__typeof__ (%(symbol)s) a_%(num)d = %(symbol)s;\n'
|
||||||
% (self.symbol, self.symbol))
|
% vars(self))
|
||||||
header_tests.compile_test('Availability of constant %s'
|
header_tests.compile_test('Availability of constant %s'
|
||||||
% self.symbol,
|
% self.symbol,
|
||||||
text)
|
text)
|
||||||
if self.symbol_type == 'macro-int-constant':
|
if self.symbol_type == 'macro-int-constant':
|
||||||
sym_bits_def_neg = ''.join(
|
sym_bits_def_neg = ''.join(
|
||||||
'# if %s & (1LL << %d)\n'
|
'# if %s & (1LL << %d)\n'
|
||||||
'# define conformtest_bit_%d 0LL\n'
|
'# define conformtest_%d_bit_%d 0LL\n'
|
||||||
'# else\n'
|
'# else\n'
|
||||||
'# define conformtest_bit_%d (1LL << %d)\n'
|
'# define conformtest_%d_bit_%d (1LL << %d)\n'
|
||||||
'# endif\n'
|
'# endif\n'
|
||||||
% (self.symbol, i, i, i, i) for i in range(63))
|
% (self.symbol, i, self.num, i, self.num, i, i)
|
||||||
sym_bits_or_neg = '|'.join('conformtest_bit_%d' % i
|
for i in range(63))
|
||||||
|
sym_bits_or_neg = '|'.join('conformtest_%d_bit_%d' % (self.num, i)
|
||||||
for i in range(63))
|
for i in range(63))
|
||||||
sym_bits_def_pos = ''.join(
|
sym_bits_def_pos = ''.join(
|
||||||
'# if %s & (1ULL << %d)\n'
|
'# if %s & (1ULL << %d)\n'
|
||||||
'# define conformtest_bit_%d (1ULL << %d)\n'
|
'# define conformtest_%d_bit_%d (1ULL << %d)\n'
|
||||||
'# else\n'
|
'# else\n'
|
||||||
'# define conformtest_bit_%d 0ULL\n'
|
'# define conformtest_%d_bit_%d 0ULL\n'
|
||||||
'# endif\n'
|
'# endif\n'
|
||||||
% (self.symbol, i, i, i, i) for i in range(64))
|
% (self.symbol, i, self.num, i, i, self.num, i)
|
||||||
sym_bits_or_pos = '|'.join('conformtest_bit_%d' % i
|
for i in range(64))
|
||||||
|
sym_bits_or_pos = '|'.join('conformtest_%d_bit_%d' % (self.num, i)
|
||||||
for i in range(64))
|
for i in range(64))
|
||||||
text = ('#if %s < 0\n'
|
text = ('#if %s < 0\n'
|
||||||
'# define conformtest_negative 1\n'
|
'# define conformtest_%d_negative 1\n'
|
||||||
'%s'
|
'%s'
|
||||||
'# define conformtest_value ~(%s)\n'
|
'# define conformtest_%d_value ~(%s)\n'
|
||||||
'#else\n'
|
'#else\n'
|
||||||
'# define conformtest_negative 0\n'
|
'# define conformtest_%d_negative 0\n'
|
||||||
'%s'
|
'%s'
|
||||||
'# define conformtest_value (%s)\n'
|
'# define conformtest_%d_value (%s)\n'
|
||||||
'#endif\n'
|
'#endif\n'
|
||||||
'_Static_assert (((%s < 0) == conformtest_negative) '
|
'_Static_assert (((%s < 0) == conformtest_%d_negative) '
|
||||||
'&& (%s == conformtest_value), '
|
'&& (%s == conformtest_%d_value), '
|
||||||
'"value match inside and outside #if");\n'
|
'"value match inside and outside #if");\n'
|
||||||
% (self.symbol, sym_bits_def_neg, sym_bits_or_neg,
|
% (self.symbol, self.num, sym_bits_def_neg, self.num,
|
||||||
sym_bits_def_pos, sym_bits_or_pos,
|
sym_bits_or_neg, self.num, sym_bits_def_pos, self.num,
|
||||||
self.symbol, self.symbol))
|
sym_bits_or_pos, self.symbol, self.num, self.symbol,
|
||||||
|
self.num))
|
||||||
header_tests.compile_test('#if usability of symbol %s'
|
header_tests.compile_test('#if usability of symbol %s'
|
||||||
% self.symbol,
|
% self.symbol,
|
||||||
text)
|
text)
|
||||||
if self.c_type is not None:
|
if self.c_type is not None:
|
||||||
if self.c_type.startswith('promoted:'):
|
if self.c_type.startswith('promoted:'):
|
||||||
c_type = self.c_type[len('promoted:'):]
|
c_type = self.c_type[len('promoted:'):]
|
||||||
text = ('__typeof__ ((%s) 0 + (%s) 0) a;\n'
|
text = ('__typeof__ ((%s) 0 + (%s) 0) a2_%d;\n'
|
||||||
% (c_type, c_type))
|
% (c_type, c_type, self.num))
|
||||||
else:
|
else:
|
||||||
text = '__typeof__ ((%s) 0) a;\n' % self.c_type
|
text = '__typeof__ ((%s) 0) a2_%d;\n' % (self.c_type, self.num)
|
||||||
text += 'extern __typeof__ (%s) a;\n' % self.symbol
|
text += 'extern __typeof__ (%s) a2_%d;\n' % (self.symbol, self.num)
|
||||||
header_tests.compile_test('Type of symbol %s' % self.symbol,
|
header_tests.compile_test('Type of symbol %s' % self.symbol,
|
||||||
text)
|
text)
|
||||||
if self.op is not None:
|
if self.op is not None:
|
||||||
text = ('_Static_assert (%s %s %s, "value constraint");\n'
|
text = ('_Static_assert (%(symbol)s %(op)s %(value)s, '
|
||||||
% (self.symbol, self.op, self.value))
|
'"value constraint");\n'
|
||||||
|
% vars(self))
|
||||||
header_tests.compile_test('Value of symbol %s' % self.symbol,
|
header_tests.compile_test('Value of symbol %s' % self.symbol,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -163,16 +167,16 @@ class SymbolTest(object):
|
|||||||
|
|
||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run a SymbolTest."""
|
"""Run a SymbolTest."""
|
||||||
text = ('void foobarbaz (void) {\n'
|
text = ('void foobarbaz_%(num)d (void) {\n'
|
||||||
'__typeof__ (%s) a = %s;\n'
|
'__typeof__ (%(symbol)s) a_%(num)d = %(symbol)s;\n'
|
||||||
'}\n'
|
'}\n'
|
||||||
% (self.symbol, self.symbol))
|
% vars(self))
|
||||||
header_tests.compile_test('Availability of symbol %s'
|
header_tests.compile_test('Availability of symbol %s'
|
||||||
% self.symbol,
|
% self.symbol,
|
||||||
text)
|
text)
|
||||||
if self.value is not None:
|
if self.value is not None:
|
||||||
text = ('int main (void) { return %s != %s; }\n'
|
text = ('int main (void) { return %(symbol)s != %(symbol)s; }\n'
|
||||||
% (self.symbol, self.value))
|
% vars(self))
|
||||||
header_tests.execute_test('Value of symbol %s' % self.symbol,
|
header_tests.execute_test('Value of symbol %s' % self.symbol,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -195,8 +199,8 @@ class TypeTest(object):
|
|||||||
|
|
||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run a TypeTest."""
|
"""Run a TypeTest."""
|
||||||
text = ('%s %sa;\n'
|
text = ('%s %sa_%d;\n'
|
||||||
% (self.type_name, '*' if self.maybe_opaque else ''))
|
% (self.type_name, '*' if self.maybe_opaque else '', self.num))
|
||||||
header_tests.compile_test('Availability of type %s' % self.type_name,
|
header_tests.compile_test('Availability of type %s' % self.type_name,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -218,9 +222,9 @@ class TagTest(object):
|
|||||||
"""Run a TagTest."""
|
"""Run a TagTest."""
|
||||||
# If the tag is not declared, these function prototypes have
|
# If the tag is not declared, these function prototypes have
|
||||||
# incompatible types.
|
# incompatible types.
|
||||||
text = ('void foo (%s *);\n'
|
text = ('void foo_%(num)d (%(type_name)s *);\n'
|
||||||
'void foo (%s *);\n'
|
'void foo_%(num)d (%(type_name)s *);\n'
|
||||||
% (self.type_name, self.type_name))
|
% vars(self))
|
||||||
header_tests.compile_test('Availability of tag %s' % self.type_name,
|
header_tests.compile_test('Availability of tag %s' % self.type_name,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -243,14 +247,15 @@ class FunctionTest(object):
|
|||||||
|
|
||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run a FunctionTest."""
|
"""Run a FunctionTest."""
|
||||||
text = ('%s (*foobarbaz) %s = %s;\n'
|
text = ('%(return_type)s (*foobarbaz_%(num)d) %(args)s '
|
||||||
% (self.return_type, self.args, self.function_name))
|
'= %(function_name)s;\n'
|
||||||
|
% vars(self))
|
||||||
header_tests.compile_test('Availability of function %s'
|
header_tests.compile_test('Availability of function %s'
|
||||||
% self.function_name,
|
% self.function_name,
|
||||||
text)
|
text)
|
||||||
text = ('extern %s (*foobarbaz) %s;\n'
|
text = ('extern %(return_type)s (*foobarbaz2_%(num)d) %(args)s;\n'
|
||||||
'extern __typeof__ (&%s) foobarbaz;\n'
|
'extern __typeof__ (&%(function_name)s) foobarbaz2_%(num)d;\n'
|
||||||
% (self.return_type, self.args, self.function_name))
|
% vars(self))
|
||||||
header_tests.compile_test('Type of function %s' % self.function_name,
|
header_tests.compile_test('Type of function %s' % self.function_name,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -267,14 +272,14 @@ class VariableTest(object):
|
|||||||
|
|
||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run a VariableTest."""
|
"""Run a VariableTest."""
|
||||||
text = ('typedef %s xyzzy%s;\n'
|
text = ('typedef %(var_type)s xyzzy_%(num)d%(rest)s;\n'
|
||||||
'xyzzy *foobarbaz = &%s;\n'
|
'xyzzy_%(num)d *foobarbaz_%(num)d = &%(var_name)s;\n'
|
||||||
% (self.var_type, self.rest, self.var_name))
|
% vars(self))
|
||||||
header_tests.compile_test('Availability of variable %s'
|
header_tests.compile_test('Availability of variable %s'
|
||||||
% self.var_name,
|
% self.var_name,
|
||||||
text)
|
text)
|
||||||
text = ('extern %s %s%s;\n'
|
text = ('extern %(var_type)s %(var_name)s%(rest)s;\n'
|
||||||
% (self.var_type, self.var_name, self.rest))
|
% vars(self))
|
||||||
header_tests.compile_test('Type of variable %s' % self.var_name,
|
header_tests.compile_test('Type of variable %s' % self.var_name,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -291,20 +296,19 @@ class MacroFunctionTest(object):
|
|||||||
|
|
||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run a MacroFunctionTest."""
|
"""Run a MacroFunctionTest."""
|
||||||
text = ('#ifndef %s\n'
|
text = ('#ifndef %(function_name)s\n'
|
||||||
'%s (*foobarbaz) %s = %s;\n'
|
'%(return_type)s (*foobarbaz_%(num)d) %(args)s '
|
||||||
|
'= %(function_name)s;\n'
|
||||||
'#endif\n'
|
'#endif\n'
|
||||||
% (self.function_name, self.return_type, self.args,
|
% vars(self))
|
||||||
self.function_name))
|
|
||||||
header_tests.compile_test('Availability of macro %s'
|
header_tests.compile_test('Availability of macro %s'
|
||||||
% self.function_name,
|
% self.function_name,
|
||||||
text)
|
text)
|
||||||
text = ('#ifndef %s\n'
|
text = ('#ifndef %(function_name)s\n'
|
||||||
'extern %s (*foobarbaz) %s;\n'
|
'extern %(return_type)s (*foobarbaz2_%(num)d) %(args)s;\n'
|
||||||
'extern __typeof__ (&%s) foobarbaz;\n'
|
'extern __typeof__ (&%(function_name)s) foobarbaz2_%(num)d;\n'
|
||||||
'#endif\n'
|
'#endif\n'
|
||||||
% (self.function_name, self.return_type, self.args,
|
% vars(self))
|
||||||
self.function_name))
|
|
||||||
header_tests.compile_test('Type of macro %s' % self.function_name,
|
header_tests.compile_test('Type of macro %s' % self.function_name,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -320,16 +324,17 @@ class MacroStrTest(object):
|
|||||||
|
|
||||||
def run(self, header_tests):
|
def run(self, header_tests):
|
||||||
"""Run a MacroStrTest."""
|
"""Run a MacroStrTest."""
|
||||||
text = ('#ifndef %s\n'
|
text = ('#ifndef %(macro_name)s\n'
|
||||||
'# error "Macro %s not defined"\n'
|
'# error "Macro %(macro_name)s not defined"\n'
|
||||||
'#endif\n'
|
'#endif\n'
|
||||||
% (self.macro_name, self.macro_name))
|
% vars(self))
|
||||||
header_tests.compile_test('Availability of macro %s' % self.macro_name,
|
header_tests.compile_test('Availability of macro %s' % self.macro_name,
|
||||||
text)
|
text)
|
||||||
# We can't include <string.h> here.
|
# We can't include <string.h> here.
|
||||||
text = ('extern int (strcmp)(const char *, const char *);\n'
|
text = ('extern int (strcmp)(const char *, const char *);\n'
|
||||||
'int main (void) { return (strcmp) (%s, %s) != 0; }\n'
|
'int main (void) { return (strcmp) (%(macro_name)s, '
|
||||||
% (self.macro_name, self.value))
|
'%(value)s) != 0; }\n'
|
||||||
|
% vars(self))
|
||||||
header_tests.execute_test('Value of macro %s' % self.macro_name,
|
header_tests.execute_test('Value of macro %s' % self.macro_name,
|
||||||
text)
|
text)
|
||||||
|
|
||||||
@ -355,6 +360,7 @@ class HeaderTests(object):
|
|||||||
self.allow = set()
|
self.allow = set()
|
||||||
self.allow_fnmatch = set()
|
self.allow_fnmatch = set()
|
||||||
self.headers_handled = set()
|
self.headers_handled = set()
|
||||||
|
self.num_tests = 0
|
||||||
self.total = 0
|
self.total = 0
|
||||||
self.skipped = 0
|
self.skipped = 0
|
||||||
self.errors = 0
|
self.errors = 0
|
||||||
@ -458,6 +464,8 @@ class HeaderTests(object):
|
|||||||
test = test_classes[tokens[0]](*tokens)
|
test = test_classes[tokens[0]](*tokens)
|
||||||
test.xfail = xfail
|
test.xfail = xfail
|
||||||
test.optional = optional
|
test.optional = optional
|
||||||
|
test.num = self.num_tests
|
||||||
|
self.num_tests += 1
|
||||||
self.add_allow(test.allow_name, False)
|
self.add_allow(test.allow_name, False)
|
||||||
if not allow:
|
if not allow:
|
||||||
self.tests.append(test)
|
self.tests.append(test)
|
||||||
|
Reference in New Issue
Block a user