This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Move tst-signal-numbers to Python
* Joseph Myers:
> On Mon, 10 Dec 2018, Florian Weimer wrote:
>
>> I would expect something not based on regular expression for those
>> filters, and it's odd there are two of them. I don't think using two
>> filters does not include expressiveness here.
>>
>> re_signal_macro = re.compile(r'^SIG[A-Z].*')
>> ignored_macros = set("SIGCLD SIGIOT SIGSWI SIGUNUSED"
>> " SIGSTKSZ SIGRTMIN SIGRTMAX".split())
>> def signal_macro(name):
>> return re_signal_macro.match(name) and name not in ignored_macros
>
> I don't want to require separate Python code for each such test.
Why not?
> Once there are a few more such tests, I think it will become natural
> to have a single Python script that reads text files describing the
> headers and constants to compare - with separate Python code only for
> more unusual cases.
I still think the comment you included in your patch, listing the signal
names explicitly, is a strong hint that regular expressions are not the
right interface here.
> I think having a regular expression to describe macros to include, and one
> to describe those to exclude, naturally matches multiple use cases for
> such tests. Consider e.g. a test for MAP_* macros, which might compare
> MAP_[A-Z].* but exclude MAP_HUGE_[0-9].* from the comparison, without
> wanting to list all the macros such as MAP_HUGE_256MB individually.
> (That's an example of a case that will also need a kernel version to be
> specified, so that extra macros are allowed on the glibc side if the
> kernel headers are older, and extra macros are allowed on the kernel side
> if the kernel headers are newer.)
The other issue to consider is that the current approach only works if
GCC can interpret the macro constant as a long int. (I think the cast
in an input constraint is not really a C cast.) Future macro
comparisons may well need type annotations, and that that point, regular
expressions seem rather problematic to me.
But please do not let this block you. It's just a test. I don't have a
strong opinion about all this.
Thanks,
Florian