Re: [LTP] [PATCH v3 1/4] Hugetlb: Add new tst_test options for hugeltb test support

Cyril Hrubis
2022-10-31T14:54:43Z

Hi!
> Why not consider encapsulating these two new fields in 'struct
> tst_hugepage' ?
>
> Then the tst_test in the case can simply initialize to:
>
> ....
> static struct tst_test test = {
> .needs_root = 1,
> .taint_check = TST_TAINT_D | TST_TAINT_W,
> .setup = setup,
> .test_all = run_test,
> .hugepages = {1, TST_NEEDS, 1, 1},
> };

I do not like that we have magic constants in the .hugepages that are
not self describing. I would treat the hugetltbfs just as we treat
devfs, that would be:

#define MNTPOINT "hugetlbfs/"
#define HUGEFILE MNTPOINT "hugefile"

static int huge_fd;

static void setup(void)
{
huge_fd = tst_creat_unlinked(HUGEFILE);
...
}

static void cleanup(void)
{
if (huge_fd > 0)
SAFE_CLOSE(huge_fd);
}

static struct tst_test test = {
...
.mntpoint = MNTPOINT,
.needs_hugetlbfs = 1,
.setup = setup,
.cleanup = cleanup,
...
}

What do you think?

--
Cyril Hrubis
chrubis@suse.cz