From: Petr Vorel <pvorel@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 02/10] Refactor ptem01 test
Date: Mon, 16 Dec 2024 22:22:21 +0100 [thread overview]
Message-ID: <20241216212221.GB633653@pevik> (raw)
In-Reply-To: <20241211-fix_setsid_tests-v1-2-e103f36c6462@suse.com>
Hi Andrea,
> Fix test failure when running inside a new session via setsid() and
> start spliting its internal tests cases implementations into multiple
> files.
+1
> Fixes: https://github.com/linux-test-project/kirk/issues/28
+1
...
> - masterfd = SAFE_OPEN(NULL, MASTERCLONE, O_RDWR);
> + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR);
> slavename = ptsname(masterfd);
> - if (slavename == NULL) {
> - tst_brkm(TBROK | TERRNO, NULL, "ptsname() call failed");
> - }
> -
> - if (grantpt(masterfd) != 0) {
> - tst_brkm(TBROK | TERRNO, NULL, "grantpt() call failed");
> - }
> -
> - if (unlockpt(masterfd) != 0) {
> - tst_brkm(TBROK, NULL, "unlockpt() call failed");
> - }
> -
> - if ((slavefd = open(slavename, O_RDWR)) < 0) {
> - tst_brkm(TFAIL, NULL, "Could not open %s", slavename);
> - }
> -
> - if (ioctl(slavefd, TCGETS, &termios) != 0) {
> - tst_brkm(TFAIL, NULL, "TCGETS");
> - }
> -
> - if (ioctl(slavefd, TCSETS, &termios) != 0) {
> - tst_brkm(TFAIL, NULL, "TCSETS");
> - }
> -
> - if (ioctl(slavefd, TCSETSW, &termios) != 0) {
> - tst_brkm(TFAIL, NULL, "TCSETSW");
> - }
> -
> - if (ioctl(slavefd, TCSETSF, &termios) != 0) {
> - tst_brkm(TFAIL, NULL, "TCSETSF");
> - }
> -
> - if (ioctl(slavefd, TCSETS, &termios) != 0) {
> - tst_brkm(TFAIL, NULL, "TCSETS");
> - }
> -
> - if (ioctl(slavefd, TCGETA, &termio) != 0) {
> - tst_brkm(TFAIL, NULL, "TCGETA");
> - }
> -
> - if (ioctl(slavefd, TCSETA, &termio) != 0) {
> - tst_brkm(TFAIL, NULL, "TCSETA");
> - }
> -
> - if (ioctl(slavefd, TCSETAW, &termio) != 0) {
> - tst_brkm(TFAIL, NULL, "TCSETAW");
> - }
> -
> - if (ioctl(slavefd, TCSETAF, &termio) != 0) {
> - tst_brkm(TFAIL, NULL, "TCSETAF");
> - }
> -
> - if (close(slavefd) != 0) {
> - tst_brkm(TBROK, NULL, "close slave");
> - }
> -
> - if (close(masterfd) != 0) {
> - tst_brkm(TBROK, NULL, "close master");
> - }
> - tst_resm(TPASS, "test1");
...
> + if (slavename == NULL)
> + tst_res(TFAIL, "Can't get slave device location");
The old test uses tst_brkm() for all tests, which is IMHO necessary, but I this
one should be tst_brk() because slavename is later used with open/SAFE_OPEN().
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> + else
> + tst_res(TPASS, "pts device location is %s", slavename);
> +
> + TST_EXP_PASS(grantpt(masterfd));
> + TST_EXP_PASS(unlockpt(masterfd));
> +
> + slavefd = SAFE_OPEN(slavename, O_RDWR);
> +
> + TST_EXP_POSITIVE(ioctl(slavefd, TCGETS, &termios));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCSETS, &termios));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCSETSW, &termios));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCSETSF, &termios));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCSETS, &termios));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCGETA, &termio));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCSETA, &termio));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCSETAW, &termio));
> + TST_EXP_POSITIVE(ioctl(slavefd, TCSETAF, &termio));
> +
> + SAFE_CLOSE(slavefd);
> + SAFE_CLOSE(masterfd);
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-12-16 21:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 12:20 [LTP] [PATCH 00/10] Fix tests failing with setsid Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 01/10] Refactor setpgid01 test Andrea Cervesato
2024-12-16 21:04 ` Petr Vorel
2024-12-11 12:20 ` [LTP] [PATCH 02/10] Refactor ptem01 test Andrea Cervesato
2024-12-16 21:22 ` Petr Vorel [this message]
2024-12-11 12:20 ` [LTP] [PATCH 03/10] Add ptem02 test Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 04/10] Add ptem03 test Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 05/10] Add ptem04 test Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 06/10] Add ptem05 test Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 07/10] Add ptem06 test Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 08/10] Refactor pty01 test Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 09/10] Add pty08 test Andrea Cervesato
2024-12-11 12:20 ` [LTP] [PATCH 10/10] Add pty09 test Andrea Cervesato
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=20241216212221.GB633653@pevik \
--to=pvorel@suse.cz \
--cc=andrea.cervesato@suse.de \
--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