From patchwork Mon May 28 10:39:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 921406 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40vYJn2HNlz9s0y for ; Mon, 28 May 2018 20:39:49 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DC8EA1A9612 for ; Mon, 28 May 2018 12:39:46 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id A4C851A95FE for ; Mon, 28 May 2018 12:39:45 +0200 (CEST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id D2C71200FCF for ; Mon, 28 May 2018 12:39:44 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3FF9FCB19; Mon, 28 May 2018 10:39:42 +0000 (UTC) Received: from dhcp-12-102.nay.redhat.com (dhcp-12-102.nay.redhat.com [10.66.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id E49DA111E41A; Mon, 28 May 2018 10:39:39 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Mon, 28 May 2018 18:39:36 +0800 Message-Id: <20180528103936.22538-1-liwang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 28 May 2018 10:39:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 28 May 2018 10:39:42 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'liwang@redhat.com' RCPT:'' X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: Eric Biggers Subject: [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" To fix this error: tst_test.c:1015: INFO: Timeout per run is 0h 50m 00s pty02.c:42: BROK: tcsetattr() failed: EINVAL POSIX.1 General description: Changes the attributes associated with a terminal. New attributes are specified with a termios control structure. Programs should always issue a tcgetattr() first, modify the desired fields, and then issue a tcsetattr(). tcsetattr() should never be issued using a termios structure that was not obtained using tcgetattr(). tcsetattr() should use only a termios structure that was obtained by tcgetattr(). Signed-off-by: Li Wang Cc: Eric Biggers Cc: Cyril Hrubis --- testcases/kernel/pty/pty02.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/pty/pty02.c b/testcases/kernel/pty/pty02.c index fd3d26b..0cedca8 100644 --- a/testcases/kernel/pty/pty02.c +++ b/testcases/kernel/pty/pty02.c @@ -31,13 +31,18 @@ static void do_test(void) { - struct termios io = { .c_lflag = EXTPROC | ICANON }; + struct termios io; int ptmx, pts; char c = 'A'; int nbytes; ptmx = SAFE_OPEN("/dev/ptmx", O_WRONLY); + if (tcgetattr(ptmx, &io) != 0) + tst_brk(TBROK | TERRNO, "tcgetattr() failed"); + + io.c_lflag = EXTPROC | ICANON; + if (tcsetattr(ptmx, TCSANOW, &io) != 0) tst_brk(TBROK | TERRNO, "tcsetattr() failed");