From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 03/11] Refactor ptem01 test
Date: Tue, 7 Jan 2025 17:01:48 +0100 [thread overview]
Message-ID: <Z31P7KEtbAwaCG7l@yuki.lan> (raw)
In-Reply-To: <20250106-fix_setsid_tests-v2-3-c43f57a2bab6@suse.com>
Hi!
> + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR);
> + slavename = SAFE_PTSNAME(masterfd);
>
> - for (i = 0; i < NUMOPENS; ++i) {
> - masterfd[i] = open(MASTERCLONE, O_RDWR);
> - if (masterfd[i] < 0) {
> - tst_resm(TBROK, "%s", MASTERCLONE);
> - tst_resm(TBROK, "out of ptys");
> - for (i = 0; i < NUMOPENS; ++i) {
> - if (masterfd[i] != 0) {
> - (void)close(masterfd[i]);
> - }
> - if (slavefd[i] != 0) {
> - (void)close(slavefd[i]);
> - }
> - }
> - tst_exit();
> - }
> + TST_EXP_PASS(grantpt(masterfd));
> + TST_EXP_PASS(unlockpt(masterfd));
>
> - slavename = ptsname(masterfd[i]);
> - if (slavename == NULL) {
> - tst_brkm(TBROK | TERRNO, NULL,
> - "ptsname() call failed");
> - }
> + slavefd = SAFE_OPEN(slavename, O_RDWR);
This would be a bit better if done in setup()
> - if (grantpt(masterfd[i]) != 0) {
> - tst_brkm(TBROK | TERRNO, NULL,
> - "grantpt() call failed");
> - }
> + 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));
Are you sure these shouldn't be TST_EXP_PASS() instead? The original
code was doing != 0 for all of these.
> - if (unlockpt(masterfd[i]) != 0) {
> - tst_brkm(TBROK, NULL, "unlockpt() call failed");
> - }
> -
> - if ((slavefd[i] = open(slavename, O_RDWR)) < 0) {
> - tst_brkm(TFAIL, NULL,
> - "Iteration %d: Could not open %s", i,
> - slavename);
> - }
> -
> - }
> -
> - for (i = 0; i < NUMOPENS; ++i) {
> - if (close(slavefd[i]) != 0) {
> - tst_brkm(TBROK, NULL, "Iteration %d: close slave", i);
> - }
> - if (close(masterfd[i]) != 0) {
> - tst_brkm(TBROK, NULL, "close master");
> - }
> - }
> - tst_resm(TPASS, "test5");
> -
> - /** NOT REACHED **/
> - return 0;
> + SAFE_CLOSE(slavefd);
> + SAFE_CLOSE(masterfd);
And this should be done in cleanup if we do the init in the
setup.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-01-07 16:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 10:31 [LTP] [PATCH v2 00/11] Fix tests failing with setsid Andrea Cervesato
2025-01-06 10:31 ` [LTP] [PATCH v2 01/11] Refactor setpgid01 test Andrea Cervesato
2025-01-07 15:26 ` Cyril Hrubis
2025-01-06 10:31 ` [LTP] [PATCH v2 02/11] Add SAFE_PTSNAME macro Andrea Cervesato
2025-01-07 15:32 ` Cyril Hrubis
2025-01-08 12:01 ` Petr Vorel
2025-01-06 10:31 ` [LTP] [PATCH v2 03/11] Refactor ptem01 test Andrea Cervesato
2025-01-07 16:01 ` Cyril Hrubis [this message]
2025-01-08 12:47 ` Petr Vorel
2025-01-06 10:31 ` [LTP] [PATCH v2 04/11] Add ptem02 test Andrea Cervesato
2025-01-07 16:14 ` Cyril Hrubis
2025-01-06 10:31 ` [LTP] [PATCH v2 05/11] Add ptem03 test Andrea Cervesato
2025-01-07 16:30 ` Cyril Hrubis
2025-01-06 10:31 ` [LTP] [PATCH v2 06/11] Add ptem04 test Andrea Cervesato
2025-01-06 10:31 ` [LTP] [PATCH v2 07/11] Add ptem05 test Andrea Cervesato
2025-01-06 10:31 ` [LTP] [PATCH v2 08/11] Add ptem06 test Andrea Cervesato
2025-01-06 10:31 ` [LTP] [PATCH v2 09/11] Refactor pty01 test Andrea Cervesato
2025-01-08 12:39 ` Petr Vorel
2025-01-09 8:28 ` Andrea Cervesato via ltp
2025-01-06 10:31 ` [LTP] [PATCH v2 10/11] Add pty08 test Andrea Cervesato
2025-01-06 10:31 ` [LTP] [PATCH v2 11/11] 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=Z31P7KEtbAwaCG7l@yuki.lan \
--to=chrubis@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