public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: Pavithra <pavrampu@linux.ibm.com>
Cc: pavrampu@linux.ibm.com, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH]  Migrating the libhugetlbfs/testcases/quota.c
Date: Tue, 24 Mar 2026 14:47:56 +0000	[thread overview]
Message-ID: <69c2a41e.050a0220.1db94b.c696@mx.google.com> (raw)
In-Reply-To: <20260219163507.24341-1-pavrampu@linux.ibm.com>

Hi Pavithra,

Consider this as a simple first-looking review. Probably more will come
when you will send more patches.

Thanks for working on migrating this test. A few issues below that
need to be addressed before this can be merged.

> +/*\
> + * [Description]
> + *

The [Description] tag is deprecated and must be removed. Just start
the doc comment directly with the text.

> +#define _GNU_SOURCE
> +#include <sys/types.h>
> +#include <sys/wait.h>
> +#include <sys/vfs.h>
> +#include <sys/statfs.h>
> +#include <sys/mount.h>
> +
> +#include "hugetlb.h"
> +#include "tst_safe_macros.h"

The "tst_safe_macros.h" include is redundant since tst_test.h (pulled
in by hugetlb.h) already includes it. Please drop it.

> +static void verify_quota_stat(int line, long tot, long free, long avail)
> +{
> +[...]
> +		tst_res_(NULL, line, TFAIL,

> +#define VERIFY_QUOTA_STAT(t, f, a) verify_quota_stat(__LINE__, t, f, a)

> static void do_map(unsigned long size, int mmap_flags, int action_flags)

In this function it's better to use goto to cleanup memory at the end of
it. So we reduce nesting after mmap() failure. Also, should we TBROK mmap()
when there's no quota pressure but the syscall fails? At the moment we are
failing for mmap() for any type of errno.

> +static void test_quota_scenario(int line, int expected_result,
> +[...]
> +		tst_res_(NULL, line, TFAIL,

> +#define TEST_QUOTA(exp, size, flags, actions) \
> +	test_quota_scenario(__LINE__, exp, size, flags, actions)

tst_res_() is an internal LTP API and must not be used directly by
tests. Drop the __LINE__ parameter and the wrapper macros, and use
plain tst_res(TFAIL, ...) instead. The failure messages already
contain enough context (quota counter values, expected vs actual
result) to identify which check failed without needing line numbers.

> +	if (actual_result != expected_result) {
> +		const char *result_names[] = {"success", "signal", "failure"};
> +		tst_res_(NULL, line, TFAIL,

checkpatch flags two issues here:
  - result_names[] should be static const
  - missing blank line after the declaration

> +	if (mount("none", quota_mnt, "hugetlbfs", 0, mount_opts) == -1) {
> +		if (errno == ENOSYS || errno == ENODEV)
> +			tst_brk(TCONF, "hugetlbfs not supported");

checkpatch warns about ENOSYS here. ENOSYS means "invalid syscall
number" and mount() will not return it. ENODEV alone is sufficient
to detect missing hugetlbfs support.

> +	.needs_tmpdir = 1,

The test already has .mntpoint and .needs_hugetlbfs set, so it gets a
temporary directory via the hugetlbfs mount infrastructure. Is
.needs_tmpdir = 1 actually needed here? If the test does not create
files outside MNTPOINT (it does not appear to), this can be dropped.


Also, in general, I think that we should have multiple test cases for
different types of quota, instead of calling the `test_quota_scenario()`
with different parameters one after another. In this way we can organise
test in a better way and reduce redundancy inside the code.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      reply	other threads:[~2026-03-24 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 16:35 [LTP] [PATCH] Migrating the libhugetlbfs/testcases/quota.c Pavithra
2026-03-24 14:47 ` Andrea Cervesato via ltp [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69c2a41e.050a0220.1db94b.c696@mx.google.com \
    --to=ltp@lists.linux.it \
    --cc=andrea.cervesato@suse.com \
    --cc=pavrampu@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox