public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 3/3] cgroup: Add memcontrol02
Date: Tue, 21 Dec 2021 08:38:03 +0000	[thread overview]
Message-ID: <87a6gufd77.fsf@suse.de> (raw)
In-Reply-To: <YcCk13sQIpG+E0jR@yuki>

Hello,

Cyril Hrubis <chrubis@suse.cz> writes:

>> +
>> +static void test_memcg_current(unsigned int n)
>> +{
>> +	size_t current;
>> +
>> +	cg_child = tst_cgroup_group_mk(cg_test, "child");
>> +	SAFE_CGROUP_SCANF(cg_child, "memory.current", "%zu", &current);
>> +	TST_EXP_POSITIVE(current == 0, "(current=%zu) == 0", current);
>
> I find these TST_EXP_POSITIVE() macros slightly confusing.
>
> Note that we do have TST_EXP_VAL(), so this can be better defined as
> TST_EXP_VAL(current, 0);
>
> But even then all the macros all written in a way that they do expect
> a syscall as a first parameter and the messages are not clear.

Possibly it should just be TST_EXP(bool_expr, fmt, ...). That would be like
practically every other testing framework. OTOH LTP is somewhat special
as we usually are checking the return value of a syscall. So I should
probably leave these macros alone in this case.

>
> Maybe we need a different solution. We already have tst_assert_foo()
> functions for sysfs/proc files so maybe we need something as compare
> function for the cgroup file attributes:

Frankly that is poor naming. One would expect tst_assert to be similar
to assert from assert.h.

>
> 	enum cmp {
> 		CMP_EQ,
> 		CMP_NE,
> 		CMP_LT,
> 		CMP_GT,
> 		CMP_LE,
> 		CMP_GE,
> 		CMP_EPS,
> 	};
>
> 	CGROUP_ASSERT_CMP_SIZE(cg_child, "memory.current", CMP_EQ, 0);
>
> 	CGROUP_ASSERT_CMP_SIZE(cg_child, "memory.current", CMP_EPS, file, 10);
>
>
> 	or even simple macro that would compare two values accordingly
> 	to the OP and print PASS/FAIL would be better than this.
>

I think it would be simpler to just create a general assert_expr
macro. The above function won't neatly handle loading multiple values
from multiple files. Nor will it handle transforming values.

We could implement SQL queries for sys files, like osquery, that would
be neat!

-- 
Thank you,
Richard.

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

  reply	other threads:[~2021-12-21 10:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 13:10 [LTP] [PATCH 1/3] API/cgroup: Add safe_cgroup_lines_scanf Richard Palethorpe via ltp
2021-12-20 13:10 ` [LTP] [PATCH 2/3] API/cgroup: Add memory.stat Richard Palethorpe via ltp
2021-12-20 15:15   ` Cyril Hrubis
2021-12-20 13:10 ` [LTP] [PATCH 3/3] cgroup: Add memcontrol02 Richard Palethorpe via ltp
2021-12-20 15:44   ` Cyril Hrubis
2021-12-21  8:38     ` Richard Palethorpe [this message]
2021-12-21 11:14       ` Cyril Hrubis
2021-12-20 15:08 ` [LTP] [PATCH 1/3] API/cgroup: Add safe_cgroup_lines_scanf Cyril Hrubis
2021-12-30 10:37 ` [LTP] [PATCH v2 1/5] " Richard Palethorpe via ltp
2021-12-30 10:37   ` [LTP] [PATCH v2 2/5] API/cgroup: Add memory.stat Richard Palethorpe via ltp
2021-12-30 10:37   ` [LTP] [PATCH v2 3/5] API/fs: Add exfat magic Richard Palethorpe via ltp
2021-12-30 10:37   ` [LTP] [PATCH v2 4/5] API: Add TST_EXP_EXPR macro Richard Palethorpe via ltp
2021-12-30 10:37   ` [LTP] [PATCH v2 5/5] cgroup: Add memcontrol02 Richard Palethorpe via ltp
2022-01-03  9:45     ` Petr Vorel
2022-01-03  9:51   ` [LTP] [PATCH v2 1/5] API/cgroup: Add safe_cgroup_lines_scanf Petr Vorel

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=87a6gufd77.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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