[LTP] [PATCH v2 1/3] lib: adding .arch field in tst_test structure

Cyril Hrubis chrubis@suse.cz
Fri Nov 5 15:22:43 CET 2021


Hi!
> > > Also I guess that it would be slightly easier to work with as an enum,
> > > so that we can do:
> > >
> > >       switch (tst_arch) {
> > >       case TST_X86_64:
> > >               ...
> > >       break;
> > >       case TST_PPC64_LE:
> >
> > I prefer enum as well. As an aside, we don't want to include LE in
> >
> 
> Sure, but I'm now thinking to extend the tst_arch as a structure
> so that could also be used in a string:
> 
>     enum tst_arch_type {
>             TST_I386,
>             TST_X86_64,
>             ...
>             TST_SPARC,
>     };
> 
>     /*
>      * This tst_arch is to save the system architecture for
>      * using in the whole test case.
>      */
>     extern struct arch {
>              const char name[16];
>              enum tst_arch_type type;
>     } tst_arch;

Or we can add a function to translate the enums into strings as:

const char *tst_arch_name(enum tst_arch arch);

> then we just can do simply in case:
> 
>     switch (tst_arch.type) {
>     case TST_X86_64:
>         ...
>     break;
> 
> 
> 
> > ppc64. If someone finds that the byte order is significant for a test
> >
> 
> Yes, or we can read info via uname() into 'utsname.machine' for
> ppc64le if really needed.
> 
> 
> > then we can add ppc64le or ppc64be. Also at some point we may need to
> > add a "machine" field for e.g. POWER8, i386 etc.
> >
> 
> Adding a new field '.machine' maybe not be necessary if just
> for POWER8/9/10, or can we find a way to combine them together
> with .supported_arch?  Umm, I'm still hesitating.

This is going to get complicated quite fast. I do not think that we need
such granularity now, but if we ever do I think it can be done as a
subtype. E.g.:

enum tst_arch {
	TST_X86,
	TST_X86_64,
	TST_PPC64,
};

enum tst_x86_subarch {
	TST_386,
	TST_486,
	TST_686,
};

enum tst_ppc_subarch {
{
	TST_POWER8,
	TST_POWER9,
	TST_POWER10,
};

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list