All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Ma Xinjian <maxj.fnst@fujitsu.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] sched_getattr02: refactor with new LTP API
Date: Mon, 16 Dec 2024 23:04:54 +0100	[thread overview]
Message-ID: <20241216220454.GA652340@pevik> (raw)
In-Reply-To: <20240913094615.245573-1-maxj.fnst@fujitsu.com>

Hi Ma Xinjian,

There was missing static:

$ make check-sched_getattr02
CHECK testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
sched_getattr02.c:28:19: warning: Symbol 'attr_copy' has no prototype or library ('tst_') prefix. Should it be static?

> +static void verify_sched_getattr(unsigned int n)
>  {
> -	TEST(sched_getattr(*(test->pid), test->a, test->size,
> -			test->flags));
> +	struct test_case *tc = tcase + n;
> +
> +	TEST(sched_getattr(*(tc->pid), tc->a, tc->size, tc->flags));

> -	if (TEST_RETURN != -1) {
> -		tst_resm(TFAIL, "sched_getattr() succeeded unexpectedly.");
> +	if (TST_RET != -1) {
> +		tst_res(TFAIL, "sched_getattr() succeeded unexpectedly.");
>  		return;
>  	}

> -	if (TEST_ERRNO == test->exp_errno) {
> -		tst_resm(TPASS | TTERRNO,
> -			"sched_getattr() failed expectedly");
> +	if (TST_ERR == tc->exp_errno) {
> +		tst_res(TPASS | TTERRNO, "sched_getattr() failed expectedly");
>  		return;
>  	}

> -	tst_resm(TFAIL | TTERRNO, "sched_getattr() failed unexpectedly "
> +	tst_res(TFAIL | TTERRNO, "sched_getattr() failed unexpectedly "
>  		": expected: %d - %s",
> -		test->exp_errno, tst_strerrno(test->exp_errno));
> +		tc->exp_errno, tst_strerrno(tc->exp_errno));
>  }

We have TST_EXP_FAIL() for it. Merged with following diff.
Thanks!

Kind regards,
Petr

+++ testcases/kernel/syscalls/sched_getattr/sched_getattr02.c
@@ -7,7 +7,7 @@
 /*\
  * [Description]
  *
- * Verify that, sched_getattr(2) returns -1 and sets errno to
+ * Verify that, sched_getattr(2) returns -1 and sets errno to:
  *
  * 1. ESRCH if pid is unused.
  * 2. EINVAL if address is NULL.
@@ -18,18 +18,16 @@
 #define _GNU_SOURCE
 
 #include <errno.h>
-#include <string.h>
-
 #include "tst_test.h"
 #include "lapi/sched.h"
 
 static pid_t pid;
 static pid_t unused_pid;
-struct sched_attr attr_copy;
+static struct sched_attr attr_copy;
 
 static struct test_case {
 	pid_t *pid;
-	struct sched_attr *a;
+	struct sched_attr *attr;
 	unsigned int size;
 	unsigned int flags;
 	int exp_errno;
@@ -42,23 +40,11 @@ static struct test_case {
 
 static void verify_sched_getattr(unsigned int n)
 {
-	struct test_case *tc = tcase + n;
-
-	TEST(sched_getattr(*(tc->pid), tc->a, tc->size, tc->flags));
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "sched_getattr() succeeded unexpectedly.");
-		return;
-	}
-
-	if (TST_ERR == tc->exp_errno) {
-		tst_res(TPASS | TTERRNO, "sched_getattr() failed expectedly");
-		return;
-	}
+	struct test_case *tc = &tcase[n];
 
-	tst_res(TFAIL | TTERRNO, "sched_getattr() failed unexpectedly "
-		": expected: %d - %s",
-		tc->exp_errno, tst_strerrno(tc->exp_errno));
+	TST_EXP_FAIL(sched_getattr(*(tc->pid), tc->attr, tc->size, tc->flags),
+				 tc->exp_errno, "sched_getattr(%d, ..., %d, %d)", *tc->pid,
+				 tc->size, tc->flags);
 }
 
 static void setup(void)

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

      reply	other threads:[~2024-12-16 22:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-13  9:46 [LTP] [PATCH] sched_getattr02: refactor with new LTP API Ma Xinjian via ltp
2024-12-16 22:04 ` Petr Vorel [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=20241216220454.GA652340@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=maxj.fnst@fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.