public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Federico Bonfiglio <federico.bonfiglio@protonmail.ch>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] sched_setscheduler: test SCHED_RESET_ON_FORK
Date: Tue, 15 Nov 2022 12:25:20 +0100	[thread overview]
Message-ID: <Y3N3ICYP+g2Tf6bd@yuki> (raw)
In-Reply-To: <20221114225616.54212-1-federico.bonfiglio@protonmail.ch>

Hi!
> +/*
> + * [Description]
> + *
> + * Testcases that test if sched_setscheduler with flag
> + * SCHED_RESET_ON_FORK restores children policy to
> + * SCHED_NORMAL.
> + *
> + */
> +
> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <sched.h>
> +#include <linux/sched.h>
> +
> +#include "tst_test.h"
> +#include "tst_sched.h"
> +
> +struct test_c
> ase_t {
 ^
 Looks like the patch was mangled by your email client.

> +	int policy;
> +	char *desc;
> +};
> +
> +static struct test_case_t cases[] = {
> +	{
> +		.policy = SCHED_FIFO,
> +		.desc = "SCHED_FIFO"
> +	},
> +	{
> +		.policy = SCHED_RR,
> +		.desc = "SCHED_RR"
> +	}
> +};
> +
> +static void test_reset_on_fork(unsigned int i)
> +{
> +	struct sched_variant *tv = &sched_variants[tst_variant];
> +	struct test_case_t *tc = &cases[i];
> +
> +	tst_res(TINFO, "Testing %s variant", tv->desc);
> +	tst_res(TINFO, "Testing %s policy", tc->desc);

Why two messages? Why not just:

tst_res(TINFO, "Testing %s variant %s policy", tv->desc, tc->desc);

> +	struct sched_param param = { .sched_priority = 1 };
> +
> +	tv->sched_setscheduler(getpid(), tc->policy | SCHED_RESET_ON_FORK, &param);
> +
> +	pid_t pid = SAFE_FORK();
> +
> +	if (!pid == 0) {
            ^
	    Uff, please don't.

That's just if (pid)


> +		if (sched_getscheduler(pid) == SCHED_NORMAL)
> +			tst_res(TPASS, "Policy reset to SCHED_NORMAL");
> +		else
> +			tst_res(TFAIL, "Policy NOT reset to SCHED_NORMAL");


We should check that the priority was reset to DEFAULT_PRIO as well.

> +	}
> +
> +	tst_reap_children();

There is no need to call this as long as the child exits normally the
test library will pick it up.

> +}
> +
> +static struct tst_test test = {
> +	.forks_child = 1,
> +	.caps = (struct tst_cap[]) {
> +	    TST_CAP(TST_CAP_REQ, CAP_SYS_NICE)
> 
> +	},
> +	.test_variants = ARRAY_SIZE(sched_variants),
> +	.tcnt = ARRAY_SIZE(cases),
> +	.test = test_reset_on_fork
> +};
> +
> --
> 2.38.1
> 





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


-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2022-11-15 11:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 22:57 [LTP] [PATCH v2] sched_setscheduler: test SCHED_RESET_ON_FORK Federico Bonfiglio via ltp
2022-11-15 11:25 ` Cyril Hrubis [this message]
2022-11-15 11:43 ` Richard Palethorpe
2023-09-16 12:49 ` [LTP] [PATCH v3] sched_setscheduler04.c: Test SCHED_RESET_ON_FORK Wei Gao via ltp
2023-11-17  9:21   ` Richard Palethorpe

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=Y3N3ICYP+g2Tf6bd@yuki \
    --to=chrubis@suse.cz \
    --cc=federico.bonfiglio@protonmail.ch \
    --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