public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: 路斐 <lufei@uniontech.com>
To: "Cyril Hrubis" <chrubis@suse.cz>
Cc: ltp <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] Add case about arch_prctl syscall.
Date: Wed, 8 May 2024 02:29:00 +0000	[thread overview]
Message-ID: <tencent_60EAD0C87B6992E152F29F11@qq.com> (raw)
In-Reply-To: <ZjojkXpTTleALvrQ@yuki>

Hi, Cyril.&nbsp;
Thanks again very much.


As written in man page,&nbsp;ENODEV seems only for ARCH_SET_CPUID, so I didn't use TST_EXP_FAIL in ARCH_GET_CPUID check. ARCH_GET_CPUID always success with returning cpuid status, I've tested this on a Intel&nbsp;J1900 machine witch has no cpuid_fault flag. I've resent the patch.

Lu Fei
site:www.uniontech.com
tel:(+86)18501012352
addr: Xi'an, China&nbsp;



&nbsp;
&nbsp;
------------------&nbsp;Original&nbsp;------------------
From: &nbsp;"Cyril&nbsp;Hrubis"<chrubis@suse.cz&gt;;
Date: &nbsp;Tue, May 7, 2024 12:51 PM
To: &nbsp;"lufei"<lufei@uniontech.com&gt;; 
Cc: &nbsp;"ltp"<ltp@lists.linux.it&gt;; "jstancek"<jstancek@redhat.com&gt;; 
Subject: &nbsp;Re: [PATCH] Add case about arch_prctl syscall.

&nbsp;

Hi!
&gt; +static void run(unsigned int index)
&gt; +{
&gt; +	struct tcase tc = tcases[index];
&gt; +
&gt; +	TEST(arch_prctl_set(ARCH_SET_CPUID, tc.input));
&gt; +
&gt; +	if (TST_RET == tc.set_exp)
&gt; +		if (tc.set_exp == -1)
&gt; +			tst_res((TST_ERR == tc.tst_errno ? TPASS : TFAIL),
&gt; +				"set cpuid, expect: %s, get: %s",
&gt; +				tst_strerrno(tc.tst_errno),
&gt; +				tst_strerrno(TST_ERR));
&gt; +		else
&gt; +			tst_res(TPASS, "set cpuid succeed.");
&gt; +	else
&gt; +		tst_res(TFAIL, "set cpuid failed.");

This is kind of ugly, why can't we just do:

	if (tag)
		TST_EXP_PASS(arch_prctl_set(ARCH_SET_CPUID, index));
	else
		TST_EXP_FAIL(arch_prctl_set(ARCH_SET_CPUID, index), ENODEV);

&gt; +	TEST(arch_prctl_get(ARCH_GET_CPUID));
&gt; +
&gt; +	if (TST_RET == tc.get_exp)
&gt; +		tst_res(TPASS, "get cpuid succeed.");
&gt; +	else
&gt; +		tst_res(TFAIL, "get cpuid failed.");


We have to check the errno here as well, just branch on the tag as well:

	if (tag) {
		TEST(arch_prctl_get(ARCH_GET_CPUID));

		if (TST_RET == index)
			tst_res(TPASS, "...");
		else
			tst_res(FAIL, "...");
	} else {
		TST_EXP_FAIL(arch_prctl_get(ARCH_GET_CPUID), ENODEV);
	}

Generally the use of TST_EXP_FAIL() is prefered whenever possible.

&gt; +}
&gt; +
&gt; +static struct tst_test test = {
&gt; +	.test = run,
&gt; +	.setup = setup,
&gt; +	.tcnt = ARRAY_SIZE(tcases),
&gt; +	.min_kver = "4.12",
&gt; +	.supported_archs = (const char *const []){"x86_64", "x86", NULL}
&gt; +};
&gt; +
&gt; +#else /* HAVE_ASM_PRCTL_H */
&gt; +TST_TEST_TCONF("missing <asm/prctl.h&gt;");
&gt; +#endif
&gt; -- 
&gt; 2.39.3
&gt; 

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2024-05-08  2:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  7:07 [LTP] [PATCH v2] Add case about arch_prctl syscall lufei
2024-04-19 15:46 ` Cyril Hrubis
2024-04-21  6:25 ` lufei
2024-04-21  7:15 ` [LTP] (no subject) lufei
2024-04-21  7:15   ` [LTP] [PATCH v2] Add case about arch_prctl syscall lufei
2024-04-26  8:36   ` [LTP] (no subject) Cyril Hrubis
2024-04-26  9:42     ` 路斐
2024-04-26 10:28       ` Cyril Hrubis
2024-04-26 12:27         ` 路斐
2024-04-26 12:47           ` Jan Stancek
2024-04-23  1:05 ` [LTP] [PATCH v2] Add case about arch_prctl syscall lufei
2024-04-28  7:44 ` [LTP] (no subject) lufei
2024-04-28  7:44   ` [LTP] [PATCH] Add case about arch_prctl syscall lufei
2024-04-29 15:02     ` Cyril Hrubis
     [not found]     ` <20240506070336.2711930-1-lufei@uniontech.com>
2024-05-06  7:03       ` lufei
2024-05-06  9:53         ` Cyril Hrubis
     [not found]         ` <20240507043235.1692-1-lufei@uniontech.com>
2024-05-07  4:32           ` lufei
2024-05-07 12:50             ` Cyril Hrubis
2024-05-08  2:29               ` 路斐 [this message]
     [not found]             ` <20240508015852.3362-1-lufei@uniontech.com>
2024-05-08  1:58               ` lufei
2024-05-09 10:27                 ` Cyril Hrubis

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=tencent_60EAD0C87B6992E152F29F11@qq.com \
    --to=lufei@uniontech.com \
    --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