[LTP] [PATCH 1/2] ptrace07: Fix compilation when not on x86
Richard Palethorpe
rpalethorpe@suse.de
Thu Oct 20 09:31:35 CEST 2022
Hello Li,
Li Wang <liwang@redhat.com> writes:
> On Wed, Oct 19, 2022 at 5:30 PM Martin Doucha <mdoucha@suse.cz> wrote:
>
> On 18. 10. 22 17:25, Richard Palethorpe via ltp wrote:
> > Strictly cpuid.h should not be included on non-x86, but this means
> > each test author has to remember not to include it. Instead we can set
> > a blank macro to allow compilation.
> >
> > Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> > ---
>
> Hi,
> defining an empty macro is a bad idea because it'll allow a broken test
> to be compiled and then it'll behave erratically for no apparent reason.
> It's better to get a build failure.
>
> Reverting 1df4de06206b079f24dde7157d037b48727c743d is the best solution
> here. Building ptrace07 and similar arch-specific tests without a key
> piece of code does not make sense. The preprocessor arch checks should
> wrap around the whole file, not just a small non-portable bit that's
> crucial for the test to work.
>
> From what I know, one of the uses of "empty macro" is to conditionally
> include certain portions of a program. In ptrace07, it invokes that useless
> macro for compiling pass on non-x86 arch but does not allow execute it.
>
> I don't see why that's crucial for a test, if we wrap around the whole file and
> avoid it compiling on non-x86, isn't this essentially same as that?
>
> The only distinction between them is partly or wholly skipping the key
> code compilation. or maybe I completely misunderstood this part.
Yes that's it. Since we decided to skip arches depending on what is
tst_test instead of compiling out the whole test. Which we want to do
because it provides meta-data.
I guess we could define the macro as ts_brk(TCONF, ...). However another
problem I just thought of is that cpuid.h might exist on a non-x86
system. So we'll still get a compilation failure.
Ideally we want compilation to fail even on x86 if the correct guards
are not in place and we include cpuid.h.
So we could use some macros like TST_ARCH_GUARD_X86 which is defined by
TST_IF_X86 and undefined by TST_ELSE_X86/TST_ENDIF_X86. Then cpuid.h can
check for that macro.
We could also define assembly in TST_ASM_X86 etc., although it's more
obvious that won't compile on non x86.
Alternatively I could try doing something in Sparse, but the macro pass
is maybe not as easy to hook into.
--
Thank you,
Richard.
More information about the ltp
mailing list