From patchwork Wed Dec 11 12:20:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021282 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=fN3FPeWw; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fQMUbAIC; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=fN3FPeWw; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fQMUbAIC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZTp2pTyz1yR6 for ; Wed, 11 Dec 2024 23:21:50 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C5D243E88F3 for ; Wed, 11 Dec 2024 13:21:48 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 61C273E88F6 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id DB1AE630053 for ; Wed, 11 Dec 2024 13:20:27 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BDFAE1F445 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ddm66tG8OdUKYeOjjYaOFBvzbFNhqGsJolF/AfHm5wg=; b=fN3FPeWw7Jg3GMDIJmKLzWl/DSBOMkK1KMVBaXBJQctiE0IZc+ud30Pauxm0kj1+dIsJB3 23dhQYNT48Vu41TgStZfZXKfJcRF0LFWJ9RSnboCodv2F7seCjpMAMZ3xg/4L5pNOkgAZY nO9PXnUzpvGqcidS/BAEU0/QElqR9JI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ddm66tG8OdUKYeOjjYaOFBvzbFNhqGsJolF/AfHm5wg=; b=fQMUbAICrP2k0Ttb3PDdFFCLd2ytTC2BNbxMw9RFiaUj27ZS096YD1Zdp8gKQxzFxZHtjd yevXCLtXEIQZeRDw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ddm66tG8OdUKYeOjjYaOFBvzbFNhqGsJolF/AfHm5wg=; b=fN3FPeWw7Jg3GMDIJmKLzWl/DSBOMkK1KMVBaXBJQctiE0IZc+ud30Pauxm0kj1+dIsJB3 23dhQYNT48Vu41TgStZfZXKfJcRF0LFWJ9RSnboCodv2F7seCjpMAMZ3xg/4L5pNOkgAZY nO9PXnUzpvGqcidS/BAEU0/QElqR9JI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ddm66tG8OdUKYeOjjYaOFBvzbFNhqGsJolF/AfHm5wg=; b=fQMUbAICrP2k0Ttb3PDdFFCLd2ytTC2BNbxMw9RFiaUj27ZS096YD1Zdp8gKQxzFxZHtjd yevXCLtXEIQZeRDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B21E513998 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WATnKoqDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:24 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-1-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=5434; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=kUmNJ42SNG8znj7LVjk8VHRyh4sOYALd3KSp6ajnFXE=; b=33K3LfZcgNaI4+rDi8VYX3j6xtE7XmfAYc4Xocz3B324n6RKcGnyJLwysvCfWx2ILOi+nuiWc lNr0zaOnxZdB2K08WtxkBYTJdgBA66ssml1f3Wwo20EWgifeUAkQTBF X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid] X-Spam-Score: -4.30 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-5.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 01/10] Refactor setpgid01 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Test used to fail when running inside an executor that is setting a new session via setsid(). By using the new LTP library, we fix this issue since it forks parent first, then execute it, enabling any setsid() to be run in the main process before execution. Fixes: https://github.com/linux-test-project/kirk/issues/28 Signed-off-by: Andrea Cervesato Reviewed-by: Petr Vorel --- testcases/kernel/syscalls/setpgid/setpgid01.c | 152 +++++--------------------- 1 file changed, 25 insertions(+), 127 deletions(-) diff --git a/testcases/kernel/syscalls/setpgid/setpgid01.c b/testcases/kernel/syscalls/setpgid/setpgid01.c index 60034e01660d5c3aebe8ca960ff64c03f2b539e5..c976c3a5138ce7bca9f92a7d624797a9f2a08154 100644 --- a/testcases/kernel/syscalls/setpgid/setpgid01.c +++ b/testcases/kernel/syscalls/setpgid/setpgid01.c @@ -1,150 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ - * + * Copyright (C) 2024 SUSE LLC Andrea Cervesato */ -/* $Id: setpgid01.c,v 1.7 2009/11/02 13:57:18 subrata_modak Exp $ */ -/* - * Description: - * Verify that: - * 1. Basic functionality test for setpgid(2). - * 2. Check functioning of setpgid(2) with pid = 0 and pgid = 0. +/*\ + * [Description] + * + * Verify basic setpgid() functionality, re-setting group ID inside both parent + * and child. In the first case, we obtain getpgrp() and set it. In the second + * case, we use setpgid(0, 0). */ -#include -#include -#include -#include -#include -#include "test.h" - -static void setup(void); -static void cleanup(void); - -char *TCID = "setpgid01"; - -static void setpgid_test1(void); -static void setpgid_test2(void); -static void (*testfunc[])(void) = { setpgid_test1, setpgid_test2}; -int TST_TOTAL = ARRAY_SIZE(testfunc); - -int main(int ac, char **av) -{ - int i, lc; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - - for (i = 0; i < TST_TOTAL; i++) - (*testfunc[i])(); - } - - cleanup(); - tst_exit(); -} +#include "tst_test.h" static void setpgid_test1(void) { pid_t pgid, pid; - pgid = getpgrp(); - pid = getpid(); + pgid = TST_EXP_PID(getpgrp()); + pid = TST_EXP_PID(getpid()); - TEST(setpgid(pid, pgid)); - if (TEST_RETURN == -1 || getpgrp() != pgid) { - tst_resm(TFAIL | TTERRNO, "test setpgid(%d, %d) fail", - pid, pgid); - } else { - tst_resm(TPASS, "test setpgid(%d, %d) success", pid, pgid); - } -} - -static int wait4child(pid_t child) -{ - int status; - - if (waitpid(child, &status, 0) == -1) - tst_resm(TBROK|TERRNO, "waitpid"); - if (WIFEXITED(status)) - return WEXITSTATUS(status); - else - return status; + TST_EXP_PASS(setpgid(pid, pgid)); + TST_EXP_EQ_LI(pgid, getpgrp()); } static void setpgid_test2(void) { - int ret; - pid_t pgid, pid; + pid_t pgid; - pid = tst_fork(); - if (pid == -1) - tst_brkm(TBROK | TERRNO, cleanup, "fork()"); - - if (pid != 0) { - ret = wait4child(pid); - } else { - pid = getpid(); - TEST(setpgid(0, 0)); - pgid = getpgrp(); - if (TEST_RETURN == -1) { - fprintf(stderr, "setpgid(0, 0) fails in " - "child process: %s\n", strerror(TEST_ERRNO)); - exit(1); - } else if (pgid != pid) { - fprintf(stderr, "setpgid(0, 0) fails to make PGID" - "equal to PID\n"); - exit(1); - } else { - exit(0); - } + if (!SAFE_FORK()) { + pgid = TST_EXP_PID(getpid()); + TST_EXP_PASS(setpgid(0, 0)); + TST_EXP_EQ_LI(pgid, getpgrp()); } - - if (ret == 0) - tst_resm(TPASS, "test setpgid(0, 0) success"); - else - tst_resm(TFAIL, "test setpgid(0, 0) fail"); } - -static void setup(void) +static void run(void) { - tst_sig(FORK, DEF_HANDLER, cleanup); - - TEST_PAUSE; + setpgid_test1(); + setpgid_test2(); } -static void cleanup(void) -{ -} +static struct tst_test test = { + .test_all = run, + .forks_child = 1, +}; From patchwork Wed Dec 11 12:20:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=GPkejcCl; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=8C3KWNQT; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=GPkejcCl; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=8C3KWNQT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZT10YTQz1yR6 for ; Wed, 11 Dec 2024 23:21:09 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AB35F3E8905 for ; Wed, 11 Dec 2024 13:21:06 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 787443E88F4 for ; Wed, 11 Dec 2024 13:20:28 +0100 (CET) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 81B5861E700 for ; Wed, 11 Dec 2024 13:20:27 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C49381F460 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u95w/8RhVIaAYAofyQ7/Wdj/KW1n+cjKvqcY1bWD1W4=; b=GPkejcClmEbYEGlbtolze1rD8K0Y2OXu8pDht97z1wJgzwkF120VdhDGrw/34nOeKF8+8N zjMNpX1cza7hRRS8q/ApGB1pxhllW/dpGaqN5BqviH6TjTtphP3UN3E1U2IZFgWpFLFfBS weGGLbHKD4U5Gqy1rLn7bch+QKvPWms= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u95w/8RhVIaAYAofyQ7/Wdj/KW1n+cjKvqcY1bWD1W4=; b=8C3KWNQTEtQn0+6X5wG5CIpRdac8J4Dwp00TCy1b2PRw7MCI9GJ18DZiGdKqzbwEskuCEk P0qPNF0w//qQftBQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GPkejcCl; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8C3KWNQT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u95w/8RhVIaAYAofyQ7/Wdj/KW1n+cjKvqcY1bWD1W4=; b=GPkejcClmEbYEGlbtolze1rD8K0Y2OXu8pDht97z1wJgzwkF120VdhDGrw/34nOeKF8+8N zjMNpX1cza7hRRS8q/ApGB1pxhllW/dpGaqN5BqviH6TjTtphP3UN3E1U2IZFgWpFLFfBS weGGLbHKD4U5Gqy1rLn7bch+QKvPWms= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u95w/8RhVIaAYAofyQ7/Wdj/KW1n+cjKvqcY1bWD1W4=; b=8C3KWNQTEtQn0+6X5wG5CIpRdac8J4Dwp00TCy1b2PRw7MCI9GJ18DZiGdKqzbwEskuCEk P0qPNF0w//qQftBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B8A4113A69 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yEa/LIqDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:25 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-2-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=12718; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=Pzj000aJS3POORfhR41qIG5nl4PLsyGH7Jo8+2GR30w=; b=6vtysIZ9ZeIH5P8+iFYX70ksCoJbRmgYGLOdD4k7xYIAxlk30xuwyNVGo46aVBB5PNemEAg1j vvD9DYMI3rBA76CgXiWZURBveqDiQ9KNOTEWt0j2ATT7AhtcW7fv2cV X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Rspamd-Queue-Id: C49381F460 X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid]; RCPT_COUNT_ONE(0.00)[1]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -4.51 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-5.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 02/10] Refactor ptem01 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Fix test failure when running inside a new session via setsid() and start spliting its internal tests cases implementations into multiple files. Fixes: https://github.com/linux-test-project/kirk/issues/28 Signed-off-by: Andrea Cervesato Reviewed-by: Petr Vorel --- testcases/kernel/pty/ptem01.c | 463 ++++-------------------------------------- 1 file changed, 44 insertions(+), 419 deletions(-) diff --git a/testcases/kernel/pty/ptem01.c b/testcases/kernel/pty/ptem01.c index 20ef5d0a739a55262c1c32ec03e57885dfe09787..75befe8274dc86bd8f1bc7aeeb5a70034783f297 100644 --- a/testcases/kernel/pty/ptem01.c +++ b/testcases/kernel/pty/ptem01.c @@ -1,441 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (c) International Business Machines Corp., 2002 - * Copyright (c) 2020 Petr Vorel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (c) 2020 Petr Vorel + * Copyright (C) 2024 SUSE LLC Andrea Cervesato */ -/* 12/23/2002 Port to LTP robbiew@us.ibm.com */ -/* 06/30/2001 Port to Linux nsharoff@us.ibm.com */ +/*\ + * [Description] + * + * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a + * slave device and configure termos/termios ioctls. + */ #define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "test.h" -#include "safe_macros.h" -#include "lapi/ioctl.h" - -char *TCID = "ptem01"; /* Test program identifier. */ -int TST_TOTAL = 6; /* Total number of test cases. */ -/**************/ +#include +#include +#include "tst_test.h" -/* - * pty master clone device - */ #define MASTERCLONE "/dev/ptmx" -#define BUFSZ 4096 - -/* - * test termio/termios ioctls - */ -int test1(void) +static void run(void) { int masterfd, slavefd; char *slavename; struct termio termio; struct termios termios; - 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"); - - /** NOT REACHED **/ - return 0; + if (slavename == NULL) + tst_res(TFAIL, "Can't get slave device location"); + 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); } -/* - * test window size setting and getting - */ -int test2(void) +static void setup(void) { - int masterfd, slavefd; - char *slavename; - struct winsize wsz; - struct winsize wsz1 = { 24, 80, 5, 10 }; - struct winsize wsz2 = { 60, 100, 11, 777 }; - - masterfd = SAFE_OPEN(NULL, 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(TBROK, NULL, "Could not open %s", slavename); - } - - if (ioctl(masterfd, TIOCSWINSZ, &wsz1) != 0) { - tst_brkm(TFAIL, NULL, "TIOCSWINSZ"); - } - - if (ioctl(slavefd, TIOCGWINSZ, &wsz) != 0) { - tst_brkm(TFAIL, NULL, "TIOCGWINSZ"); - } - - if (wsz.ws_row != wsz1.ws_row || wsz.ws_col != wsz1.ws_col || - wsz.ws_xpixel != wsz1.ws_xpixel || - wsz.ws_ypixel != wsz1.ws_ypixel) { - tst_brkm(TFAIL, NULL, "unexpected window size returned"); - } - - if (ioctl(masterfd, TIOCGWINSZ, &wsz) != 0) { - tst_brkm(TFAIL, NULL, "TIOCGWINSZ"); - } - - if (wsz.ws_row != wsz1.ws_row || wsz.ws_col != wsz1.ws_col || - wsz.ws_xpixel != wsz1.ws_xpixel || - wsz.ws_ypixel != wsz1.ws_ypixel) { - tst_brkm(TFAIL, NULL, "unexpected window size returned"); - } - - if (ioctl(slavefd, TIOCSWINSZ, &wsz2) != 0) { - tst_brkm(TFAIL, NULL, "TIOCSWINSZ"); - } - - if (ioctl(slavefd, TIOCGWINSZ, &wsz) != 0) { - tst_brkm(TFAIL, NULL, "TIOCGWINSZ"); - } - - if (wsz.ws_row != wsz2.ws_row || wsz.ws_col != wsz2.ws_col || - wsz.ws_xpixel != wsz2.ws_xpixel || - wsz.ws_ypixel != wsz2.ws_ypixel) { - tst_brkm(TFAIL, NULL, "unexpected window size returned"); - } - - if (close(slavefd) != 0) { - tst_brkm(TBROK, NULL, "close"); - } - - if (close(masterfd) != 0) { - tst_brkm(TBROK, NULL, "close"); - } - tst_resm(TPASS, "test2"); - - /** NOT REACHED **/ - return 0; + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); } -/* - * test sending a break - */ -int test3(void) -{ - int masterfd, slavefd; - char *slavename; - - masterfd = SAFE_OPEN(NULL, 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(TBROK, NULL, "Could not open %s", slavename); - } - - if (tcsendbreak(masterfd, 10) != 0) { - tst_brkm(TFAIL, NULL, "tcsendbreak"); - } - - if (tcsendbreak(slavefd, 10) != 0) { - tst_brkm(TFAIL, NULL, "tcsendbreak"); - } - - if (close(slavefd) != 0) { - tst_brkm(TBROK, NULL, "close slave"); - } - - if (close(masterfd) != 0) { - tst_brkm(TBROK, NULL, "close master"); - } - tst_resm(TPASS, "test3"); - - /** NOT REACHED **/ - return 0; -} - -/* - * test multiple opens of slave side - */ -int test4(void) -{ - int masterfd, slavefd, slavefd2, slavefd3; - char *slavename; - - masterfd = SAFE_OPEN(NULL, 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(TBROK, NULL, "Could not open %s", slavename); - } - - if ((slavefd2 = open(slavename, O_RDWR)) < 0) { - tst_brkm(TFAIL, NULL, "Could not open %s (again)", slavename); - } - - if ((slavefd3 = open(slavename, O_RDWR)) < 0) { - tst_brkm(TFAIL, NULL, "Could not open %s (once more)", - slavename); - } - - if (close(slavefd) != 0) { - tst_brkm(TBROK, NULL, "close slave"); - } - if (close(slavefd2) != 0) { - tst_brkm(TBROK, NULL, "close slave again"); - } - if (close(slavefd3) != 0) { - tst_brkm(TBROK, NULL, "close slave once more"); - } - if (close(masterfd) != 0) { - tst_brkm(TBROK, NULL, "close master"); - } - tst_resm(TPASS, "test4"); - - /** NOT REACHED **/ - return 0; -} - -#define NUMOPENS 6 - -/* - * test several simultaneous opens - */ -int test5(void) -{ - static int masterfd[NUMOPENS]; - static int slavefd[NUMOPENS]; - char *slavename; - int i; - - 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(); - } - - slavename = ptsname(masterfd[i]); - if (slavename == NULL) { - tst_brkm(TBROK | TERRNO, NULL, - "ptsname() call failed"); - } - - if (grantpt(masterfd[i]) != 0) { - tst_brkm(TBROK | TERRNO, NULL, - "grantpt() call failed"); - } - - 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; -} - -/* - * test hangup semantics - */ -int test6(void) -{ - static int masterfd; - static int slavefd; - char *slavename; - struct termios termios; - - masterfd = SAFE_OPEN(NULL, 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(TBROK, NULL, "Could not open %s", slavename); - } - - if (ioctl(slavefd, TCGETS, &termios) != 0) { - tst_brkm(TFAIL, NULL, "TCGETS"); - } - - termios.c_cflag &= ~CBAUD; - termios.c_cflag |= B0 & CBAUD; - if (ioctl(slavefd, TCSETS, &termios) != 0) { - tst_brkm(TFAIL, NULL, "TCGETS"); - } - - if (close(slavefd) != 0) { - tst_brkm(TBROK, NULL, "close"); - } - if (close(masterfd) != 0) { - tst_brkm(TBROK, NULL, "close"); - } - tst_resm(TPASS, "test6"); - - /** NOT REACHED **/ - return 0; -} - -/* - * main test driver - */ -int main(void) -{ - test1(); - test2(); - test3(); - test4(); - test5(); - test6(); - /* - * all done - */ - tst_exit(); -} +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=riIhYCwU; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7DVgBc3O; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=riIhYCwU; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7DVgBc3O; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZSg26Z7z1yR6 for ; Wed, 11 Dec 2024 23:20:51 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 7AFF93E7D06 for ; Wed, 11 Dec 2024 13:20:49 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 6EE143E88F3 for ; Wed, 11 Dec 2024 13:20:28 +0100 (CET) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 8636F101D8DF for ; Wed, 11 Dec 2024 13:20:27 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CAC7C1F46E for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQD0F71QcruvpNzVJCZfHC8qI8kHuJbwzZ3XWYI5d+Q=; b=riIhYCwU09sB/TUbZLt4OBAPtqX6EFQKlV90Je0bR9v5voOpbGFwsQiQyClMGtXXEvj5ou JwvzfNJ8BnjRgW4pQME9opXpDcdjGoDYlkJRLhRb79dGZXH+KE6kB9zcTc5HTMpWrgjsA0 v2r0S4ZUm4Fd8+f7rjNzWUP4+emarpU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQD0F71QcruvpNzVJCZfHC8qI8kHuJbwzZ3XWYI5d+Q=; b=7DVgBc3OM5F/6O/eJKwv5bvBcFKbd0Y7MzhsbMw0836YleTfB7Df5iMmftd+G1KDNgDd77 MeJ1nL66eVMIxPAA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQD0F71QcruvpNzVJCZfHC8qI8kHuJbwzZ3XWYI5d+Q=; b=riIhYCwU09sB/TUbZLt4OBAPtqX6EFQKlV90Je0bR9v5voOpbGFwsQiQyClMGtXXEvj5ou JwvzfNJ8BnjRgW4pQME9opXpDcdjGoDYlkJRLhRb79dGZXH+KE6kB9zcTc5HTMpWrgjsA0 v2r0S4ZUm4Fd8+f7rjNzWUP4+emarpU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQD0F71QcruvpNzVJCZfHC8qI8kHuJbwzZ3XWYI5d+Q=; b=7DVgBc3OM5F/6O/eJKwv5bvBcFKbd0Y7MzhsbMw0836YleTfB7Df5iMmftd+G1KDNgDd77 MeJ1nL66eVMIxPAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BF30313A6F for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uC9dLoqDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:26 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-3-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=3445; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=nDIsbzah5lslsc18r6hrN18KbzYZvOBz14ZDMhoeFEQ=; b=Tiv/NPy51HphCi8ttmpu1HKcMGISsFPN4eWmAI27Pa12jQTKN3Uto5QLgrUAA1aqVSWtJyi4O jSLRrRujdIpCRLj8KdYgvQcX5YaiXFu2Dzt6gEsE2NPQdf1UKifWHH2 X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email] X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 03/10] Add ptem02 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a slave device and set/get window size. Signed-off-by: Andrea Cervesato --- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/ptem02.c | 78 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/runtest/pty b/runtest/pty index df2074153c2ac01038a0ef0ce5ad8938960ae53d..3ce7160e2776e58973def5893fc269ed035376c0 100644 --- a/runtest/pty +++ b/runtest/pty @@ -7,5 +7,6 @@ pty05 pty05 pty06 pty06 pty07 pty07 ptem01 ptem01 +ptem02 ptem02 hangup01 hangup01 diff --git a/testcases/kernel/pty/.gitignore b/testcases/kernel/pty/.gitignore index acca3db9a1786f243b31f1fc4a8833d6ed8751a6..e638413a127fad65ed2f58c24dc1ae718219e518 100644 --- a/testcases/kernel/pty/.gitignore +++ b/testcases/kernel/pty/.gitignore @@ -1,5 +1,6 @@ /hangup01 /ptem01 +/ptem02 /pty01 /pty02 /pty03 diff --git a/testcases/kernel/pty/ptem02.c b/testcases/kernel/pty/ptem02.c new file mode 100644 index 0000000000000000000000000000000000000000..78ed40d2ca9cb4d1d9a1f3879f1fdcf9198ee493 --- /dev/null +++ b/testcases/kernel/pty/ptem02.c @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (c) 2020 Petr Vorel + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a + * slave device and set/get window size. + */ + +#define _GNU_SOURCE + +#include "tst_test.h" + +#define MASTERCLONE "/dev/ptmx" + +static void run(void) +{ + int masterfd, slavefd; + char *slavename; + struct winsize wsz; + struct winsize wsz1 = { 24, 80, 5, 10 }; + struct winsize wsz2 = { 60, 100, 11, 777 }; + + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR); + + slavename = ptsname(masterfd); + if (slavename == NULL) + tst_res(TFAIL, "Can't get slave device location"); + 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(masterfd, TIOCSWINSZ, &wsz1)); + TST_EXP_POSITIVE(ioctl(slavefd, TIOCGWINSZ, &wsz)); + + TST_EXP_EQ_LI(wsz.ws_row, wsz1.ws_row); + TST_EXP_EQ_LI(wsz.ws_col, wsz1.ws_col); + TST_EXP_EQ_LI(wsz.ws_xpixel, wsz1.ws_xpixel); + TST_EXP_EQ_LI(wsz.ws_ypixel, wsz1.ws_ypixel); + + TST_EXP_POSITIVE(ioctl(masterfd, TIOCGWINSZ, &wsz)); + + TST_EXP_EQ_LI(wsz.ws_row, wsz1.ws_row); + TST_EXP_EQ_LI(wsz.ws_col, wsz1.ws_col); + TST_EXP_EQ_LI(wsz.ws_xpixel, wsz1.ws_xpixel); + TST_EXP_EQ_LI(wsz.ws_ypixel, wsz1.ws_ypixel); + + TST_EXP_POSITIVE(ioctl(slavefd, TIOCSWINSZ, &wsz2)); + TST_EXP_POSITIVE(ioctl(slavefd, TIOCGWINSZ, &wsz)); + + TST_EXP_EQ_LI(wsz.ws_row, wsz2.ws_row); + TST_EXP_EQ_LI(wsz.ws_col, wsz2.ws_col); + TST_EXP_EQ_LI(wsz.ws_xpixel, wsz2.ws_xpixel); + TST_EXP_EQ_LI(wsz.ws_ypixel, wsz2.ws_ypixel); + + SAFE_CLOSE(slavefd); + SAFE_CLOSE(masterfd); +} + +static void setup(void) +{ + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=NnqBXoWl; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=0EuLdidh; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=NnqBXoWl; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=0EuLdidh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZSJ3Txnz1yR6 for ; Wed, 11 Dec 2024 23:20:32 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E22703E88FC for ; Wed, 11 Dec 2024 13:20:30 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 6AD8D3E7D06 for ; Wed, 11 Dec 2024 13:20:28 +0100 (CET) Authentication-Results: in-3.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id EBDB01BCC62A for ; Wed, 11 Dec 2024 13:20:27 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D4C0A1F6E6 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l8tPganWo9JIps/RyvipT0fZuBhvu32c99HoNwqO8mo=; b=NnqBXoWlPMPfBrSRpvru7Jup7KLfOPOSzFj1W51GsgvCuf83A+wkfOFTEZMEMEUd+/RGaQ sRr5FZxKITmE6NrgjLNIuOM4ulTxfBw/cKnYaqHVZ/dhX5BozQEC1FdvusCSlfP6rFoI4u V6oYK3r1pdXy4ZRiqphwBC5Q/XesMPo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l8tPganWo9JIps/RyvipT0fZuBhvu32c99HoNwqO8mo=; b=0EuLdidhGcBbleg1wdDGgeX6dJIteayIst2Ip8ekrZ5NJLtYMOf4ZHFeCQZtBxjht5kikM ygrbXRYV9VTDtdCg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l8tPganWo9JIps/RyvipT0fZuBhvu32c99HoNwqO8mo=; b=NnqBXoWlPMPfBrSRpvru7Jup7KLfOPOSzFj1W51GsgvCuf83A+wkfOFTEZMEMEUd+/RGaQ sRr5FZxKITmE6NrgjLNIuOM4ulTxfBw/cKnYaqHVZ/dhX5BozQEC1FdvusCSlfP6rFoI4u V6oYK3r1pdXy4ZRiqphwBC5Q/XesMPo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l8tPganWo9JIps/RyvipT0fZuBhvu32c99HoNwqO8mo=; b=0EuLdidhGcBbleg1wdDGgeX6dJIteayIst2Ip8ekrZ5NJLtYMOf4ZHFeCQZtBxjht5kikM ygrbXRYV9VTDtdCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C67F713AD3 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +B3xL4qDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:27 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-4-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=2649; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=4jqt6mVmZh6o5Evr0obzjvwrsiuBLgKIr4j+QTDtT54=; b=ITwyppsVWvFlIbK1KTAcw6BgL2QeipqIgG91fmbA3OGeeQ3z0xTe7uw/rTYF1O4FHucVTpli+ cmJlW103ZriByn/YyvxABoiUChcKOx5cBt4C0M9oefIzz3k8tvCnSX4 X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email] X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-3.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 04/10] Add ptem03 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a slave device and to send a break to both master and slave. Signed-off-by: Andrea Cervesato --- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/ptem03.c | 56 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/runtest/pty b/runtest/pty index 3ce7160e2776e58973def5893fc269ed035376c0..329cc84cdc107ab8e814fea72a8088ea62d5ad25 100644 --- a/runtest/pty +++ b/runtest/pty @@ -8,5 +8,6 @@ pty06 pty06 pty07 pty07 ptem01 ptem01 ptem02 ptem02 +ptem03 ptem03 hangup01 hangup01 diff --git a/testcases/kernel/pty/.gitignore b/testcases/kernel/pty/.gitignore index e638413a127fad65ed2f58c24dc1ae718219e518..61fec1ddae3ea39d20e97123e34888708050c25c 100644 --- a/testcases/kernel/pty/.gitignore +++ b/testcases/kernel/pty/.gitignore @@ -1,6 +1,7 @@ /hangup01 /ptem01 /ptem02 +/ptem03 /pty01 /pty02 /pty03 diff --git a/testcases/kernel/pty/ptem03.c b/testcases/kernel/pty/ptem03.c new file mode 100644 index 0000000000000000000000000000000000000000..e12ebe27dfe952a2d085205bff1b25ea3709fbba --- /dev/null +++ b/testcases/kernel/pty/ptem03.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (c) 2020 Petr Vorel + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a + * slave device and to send a break to both master and slave. + */ + +#define _GNU_SOURCE + +#include +#include "tst_test.h" + +#define MASTERCLONE "/dev/ptmx" + +static void run(void) +{ + int masterfd, slavefd; + char *slavename; + + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR); + + slavename = ptsname(masterfd); + if (slavename == NULL) + tst_res(TFAIL, "Can't get slave device location"); + 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_PASS(tcsendbreak(masterfd, 10)); + TST_EXP_PASS(tcsendbreak(slavefd, 10)); + + SAFE_CLOSE(slavefd); + SAFE_CLOSE(masterfd); +} + +static void setup(void) +{ + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=hOsgwZiI; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=UmA0JbzT; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=hOsgwZiI; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=UmA0JbzT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZW84nXfz1yR6 for ; Wed, 11 Dec 2024 23:23:00 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C243E3E8911 for ; Wed, 11 Dec 2024 13:22:58 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id E30AE3E88F5 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 38B9D100BA64 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DEB6F1F74A for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fn31eTE0G3TjWjqpZnxlaXUlE9ERe+88q2FdEd3GWKg=; b=hOsgwZiI2BgPYFev837m6NaNSM2Y1VztaRAcqeRLJfIB9QOekEprb5lcvm+xH5QeuIZAZ+ KIYOOvmZTGgH7i8T9txUwVAX6rDTDlqPYlMSwHXiyIa9QHAQJ7KVLV+L5px49kjbm2+CYM RJ3Vb9i73esHgn1x/G+9EdW7XDXDa00= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fn31eTE0G3TjWjqpZnxlaXUlE9ERe+88q2FdEd3GWKg=; b=UmA0JbzTc1yTxMTtANiP2sl/jVrj0eN5gEKbZMBYtPYdofKnLBEc7v8bVd/6uNY1/n1Cxw ShffokJgJu9/mMDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fn31eTE0G3TjWjqpZnxlaXUlE9ERe+88q2FdEd3GWKg=; b=hOsgwZiI2BgPYFev837m6NaNSM2Y1VztaRAcqeRLJfIB9QOekEprb5lcvm+xH5QeuIZAZ+ KIYOOvmZTGgH7i8T9txUwVAX6rDTDlqPYlMSwHXiyIa9QHAQJ7KVLV+L5px49kjbm2+CYM RJ3Vb9i73esHgn1x/G+9EdW7XDXDa00= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fn31eTE0G3TjWjqpZnxlaXUlE9ERe+88q2FdEd3GWKg=; b=UmA0JbzTc1yTxMTtANiP2sl/jVrj0eN5gEKbZMBYtPYdofKnLBEc7v8bVd/6uNY1/n1Cxw ShffokJgJu9/mMDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CE61F13AD4 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sEoeMoqDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:28 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-5-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=2700; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=7yU30Gz510cpPLJcm0dh86l7z7mYvF6gUD+gyqisKJc=; b=rTN/9xbqciI3i9MnyopJnDe6lSrVUGt4Bhf7wQx6bkQ2zgccjlrjAPYKQLCnew1nsCNOXEqg1 1OMgW9bj3yYClBiCci96KEtuhouX6+luYDm9FFR2JvxRaBnyEEpYdeZ X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email] X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 05/10] Add ptem04 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a slave device and to check if it's possible to open it multiple times. Signed-off-by: Andrea Cervesato --- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/ptem04.c | 57 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/runtest/pty b/runtest/pty index 329cc84cdc107ab8e814fea72a8088ea62d5ad25..63d927eca07aa3dbd312d5c5cc6b6681dbf3627d 100644 --- a/runtest/pty +++ b/runtest/pty @@ -9,5 +9,6 @@ pty07 pty07 ptem01 ptem01 ptem02 ptem02 ptem03 ptem03 +ptem04 ptem04 hangup01 hangup01 diff --git a/testcases/kernel/pty/.gitignore b/testcases/kernel/pty/.gitignore index 61fec1ddae3ea39d20e97123e34888708050c25c..c9bb33664f9de55038f4638406841f403f1a86c4 100644 --- a/testcases/kernel/pty/.gitignore +++ b/testcases/kernel/pty/.gitignore @@ -2,6 +2,7 @@ /ptem01 /ptem02 /ptem03 +/ptem04 /pty01 /pty02 /pty03 diff --git a/testcases/kernel/pty/ptem04.c b/testcases/kernel/pty/ptem04.c new file mode 100644 index 0000000000000000000000000000000000000000..ff91616db9d0d54b0a40477867ce30fff24cae00 --- /dev/null +++ b/testcases/kernel/pty/ptem04.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (c) 2020 Petr Vorel + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, obtain a + * slave device and to check if it's possible to open it multiple times. + */ + +#define _GNU_SOURCE + +#include "tst_test.h" + +#define MASTERCLONE "/dev/ptmx" +#define NUM_SLAVES 10 + +static void run(void) +{ + int masterfd; + int slavefd[NUM_SLAVES]; + char *slavename; + + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR); + + slavename = ptsname(masterfd); + if (slavename == NULL) + tst_res(TFAIL, "Can't get slave device location"); + else + tst_res(TPASS, "pts device location is %s", slavename); + + TST_EXP_PASS(grantpt(masterfd)); + TST_EXP_PASS(unlockpt(masterfd)); + + for (int i = 0; i < NUM_SLAVES; i++) + slavefd[i] = TST_EXP_FD(open(slavename, O_RDWR)); + + for (int i = 0; i < NUM_SLAVES; i++) + SAFE_CLOSE(slavefd[i]); + + SAFE_CLOSE(masterfd); +} + +static void setup(void) +{ + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jyQbE1a2; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Q3XHumAp; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=jyQbE1a2; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Q3XHumAp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZV82MVPz1yR6 for ; Wed, 11 Dec 2024 23:22:08 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 882933E8906 for ; Wed, 11 Dec 2024 13:22:06 +0100 (CET) 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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 7A1073E88F9 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Authentication-Results: in-7.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id E57E022C66C for ; Wed, 11 Dec 2024 13:20:28 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E28AA21167 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbv00uj46cDuZN3bxZNd+1UIWWv5gqsQGH3VhLGi5BM=; b=jyQbE1a2iLcLLh8lZlPSuu4WnGPaci2ScdBCF0nN8x1mDKmNMG44b7dqWd/t9KpiGGhILo f/HRDfz3VcYQtw1nvqCaUcFjwhk34fFYEv4crwTT9mZtYL9bpK1F28sVcN0w0Mkk27RIPC vg4iYnrcps9hS/raM0NYKlfYsW8ZjCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbv00uj46cDuZN3bxZNd+1UIWWv5gqsQGH3VhLGi5BM=; b=Q3XHumApvQk3V1eAzDWsnh9eCaPCsYuRYSKLxnvIjagkb2mQLMTynzSiCbrWtNAlIPyBxy Tvq/UX88el9aTABQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbv00uj46cDuZN3bxZNd+1UIWWv5gqsQGH3VhLGi5BM=; b=jyQbE1a2iLcLLh8lZlPSuu4WnGPaci2ScdBCF0nN8x1mDKmNMG44b7dqWd/t9KpiGGhILo f/HRDfz3VcYQtw1nvqCaUcFjwhk34fFYEv4crwTT9mZtYL9bpK1F28sVcN0w0Mkk27RIPC vg4iYnrcps9hS/raM0NYKlfYsW8ZjCM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbv00uj46cDuZN3bxZNd+1UIWWv5gqsQGH3VhLGi5BM=; b=Q3XHumApvQk3V1eAzDWsnh9eCaPCsYuRYSKLxnvIjagkb2mQLMTynzSiCbrWtNAlIPyBxy Tvq/UX88el9aTABQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D558A13AD6 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id wJ7MM4qDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:29 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-6-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=2717; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=CB13XYLcRBgnTP3VlgnXhv8rIMjbiaMSedbJExjbazQ=; b=h0xm/bpGp2/Mtlp96AgWHe+X2ZcR3fw/LskyGFoniTuYiR1Kme7XEAv2ukAf0PWsRbv/v5yH/ V5MD/XcPrqWDxUnazyRVujCsdcBuxdJyX4aktON4Y3/bG0WO9DcqRbv X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid] X-Spam-Score: -4.30 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-7.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-7.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 06/10] Add ptem05 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Verify that it's possible to open a pseudo-terminal via /dev/ptmx, to obtain a master + slave pair and to open them multiple times. Signed-off-by: Andrea Cervesato --- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/ptem05.c | 58 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/runtest/pty b/runtest/pty index 63d927eca07aa3dbd312d5c5cc6b6681dbf3627d..deb04c3f5725647a32f457eaed638eb7071ab4db 100644 --- a/runtest/pty +++ b/runtest/pty @@ -10,5 +10,6 @@ ptem01 ptem01 ptem02 ptem02 ptem03 ptem03 ptem04 ptem04 +ptem05 ptem05 hangup01 hangup01 diff --git a/testcases/kernel/pty/.gitignore b/testcases/kernel/pty/.gitignore index c9bb33664f9de55038f4638406841f403f1a86c4..ef5751907cad087f5e33132b52a374b52ee7905a 100644 --- a/testcases/kernel/pty/.gitignore +++ b/testcases/kernel/pty/.gitignore @@ -3,6 +3,7 @@ /ptem02 /ptem03 /ptem04 +/ptem05 /pty01 /pty02 /pty03 diff --git a/testcases/kernel/pty/ptem05.c b/testcases/kernel/pty/ptem05.c new file mode 100644 index 0000000000000000000000000000000000000000..10ffc24e2e22cfd4651362b519f3d494d79f3374 --- /dev/null +++ b/testcases/kernel/pty/ptem05.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (c) 2020 Petr Vorel + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, to obtain + * a master + slave pair and to open them multiple times. + */ + +#define _GNU_SOURCE + +#include "tst_test.h" + +#define MASTERCLONE "/dev/ptmx" +#define NUM_OPENS 10 + +static void run(void) +{ + int masterfd[NUM_OPENS]; + int slavefd[NUM_OPENS]; + char *slavename; + + for (int i = 0; i < NUM_OPENS; i++) { + masterfd[i] = SAFE_OPEN(MASTERCLONE, O_RDWR); + + slavename = ptsname(masterfd[i]); + if (slavename == NULL) + tst_res(TFAIL, "Can't get slave device location"); + else + tst_res(TPASS, "pts device location is %s", slavename); + + TST_EXP_PASS(grantpt(masterfd[i])); + TST_EXP_PASS(unlockpt(masterfd[i])); + + slavefd[i] = TST_EXP_FD(open(slavename, O_RDWR)); + } + + for (int i = 0; i < NUM_OPENS; i++) { + SAFE_CLOSE(masterfd[i]); + SAFE_CLOSE(slavefd[i]); + } +} + +static void setup(void) +{ + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=BtX8kF41; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=o6PEdu2s; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=0OkVkNk8; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=CsPwgB2G; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZWr16kdz1yR6 for ; Wed, 11 Dec 2024 23:23:36 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 744FA3E8914 for ; Wed, 11 Dec 2024 13:23:34 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id EE2B83E88FC for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 2B1FD638603 for ; Wed, 11 Dec 2024 13:20:28 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E9D6121168 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ymu/N4W1+bVQXsZPxCgqD9AMtak69iDlryQdVxfUunM=; b=BtX8kF41f4P1DKPLWzZfoM9F7jnB9mbOpfQNCMx7l1sm07kWrjAbP3v4rZBCs6NWXtdtPt +hHVxzwbHL3At7xVM3kLNyZsrke5Kwp7H6nNJYQhw4TwdMfxrZczX+KoeSu4AGt5TBibn0 3pn5xXVM6fnh/xZ/B1ypG7S9yPM5JZs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ymu/N4W1+bVQXsZPxCgqD9AMtak69iDlryQdVxfUunM=; b=o6PEdu2ssLugA4aj5IYdan4R6vLwIOvBXeQOuO1xP69Ydo5pNdC/36DWPslrDi+aw3i2iu 2FyHRgnq7y9x1lAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0OkVkNk8; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=CsPwgB2G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ymu/N4W1+bVQXsZPxCgqD9AMtak69iDlryQdVxfUunM=; b=0OkVkNk8oNbrrngrGqQuSjJI58nkum2FVel1RN+2bxxbAAoBcnEBVCCZz/V/02Qjqwe7F3 bZIT4VqOCnnlFloqRU6NXOOBlNCBE5Qr7l/FMBJRBT5hisDlQ6apg0uQgyaY/ZVuLwR0DI weUEP3WUqn7/FWW9ntNZWSdZ2xNI5U0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ymu/N4W1+bVQXsZPxCgqD9AMtak69iDlryQdVxfUunM=; b=CsPwgB2GvzL/MZYhpXB7szjiydC1pHFAdJ9lXmGQWcv97iEKBk3NrMmIa1RzNydIHiqNo1 KDycax8RLYycinAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DC5701344A for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ANl9NYqDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:30 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-7-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=2772; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=rOesXg7SZTJ/Kb0wF3PAMZolAZ6Tb3xY34xuyGcll64=; b=ZFrOg0oJLxlPEtM5DoON06+44amLt5VW7RIGO2gktF2+c326Pp1NAMwOmWD7GILjd3+E9Vywb abCTp/eX2+8C8H0MMbIrc5VotOZN0+96nmk+HrXtIcK+JI9Te4TY+aJ X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Rspamd-Queue-Id: E9D6121168 X-Spam-Score: -4.51 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email]; RCPT_COUNT_ONE(0.00)[1]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 07/10] Add ptem06 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Verify that it's possible to open a pseudo-terminal via /dev/ptmx, to obtain a slave device and to set baudrate to B0 (which means hang up). Signed-off-by: Andrea Cervesato --- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/ptem06.c | 59 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/runtest/pty b/runtest/pty index deb04c3f5725647a32f457eaed638eb7071ab4db..6343da391ba17627abaf09aa5a23509e4f745556 100644 --- a/runtest/pty +++ b/runtest/pty @@ -11,5 +11,6 @@ ptem02 ptem02 ptem03 ptem03 ptem04 ptem04 ptem05 ptem05 +ptem06 ptem06 hangup01 hangup01 diff --git a/testcases/kernel/pty/.gitignore b/testcases/kernel/pty/.gitignore index ef5751907cad087f5e33132b52a374b52ee7905a..630d7fcf7b0e0adfbc21b793fa456d6c5f5e4ad9 100644 --- a/testcases/kernel/pty/.gitignore +++ b/testcases/kernel/pty/.gitignore @@ -4,6 +4,7 @@ /ptem03 /ptem04 /ptem05 +/ptem06 /pty01 /pty02 /pty03 diff --git a/testcases/kernel/pty/ptem06.c b/testcases/kernel/pty/ptem06.c new file mode 100644 index 0000000000000000000000000000000000000000..be34000e63de48560fa7ae03f72c986e26f7851d --- /dev/null +++ b/testcases/kernel/pty/ptem06.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (c) 2020 Petr Vorel + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Verify that it's possible to open a pseudo-terminal via /dev/ptmx, to obtain + * a slave device and to set baudrate to B0 (which means hang up). + */ + +#define _GNU_SOURCE + +#include +#include "tst_test.h" + +#define MASTERCLONE "/dev/ptmx" + +static void run(void) +{ + int masterfd, slavefd; + struct termios termios; + char *slavename; + + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR); + + slavename = ptsname(masterfd); + if (slavename == NULL) + tst_res(TFAIL, "Can't get slave device location"); + 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_PASS(ioctl(slavefd, TCGETS, &termios)); + termios.c_cflag &= ~CBAUD; + termios.c_cflag |= B0 & CBAUD; + TST_EXP_PASS(ioctl(slavefd, TCSETS, &termios)); + + SAFE_CLOSE(slavefd); + SAFE_CLOSE(masterfd); +} + +static void setup(void) +{ + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=djxp0na4; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=QVU3xLhW; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=UA+FJ52d; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=C8GyZqqb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZWV3F8mz1yR6 for ; Wed, 11 Dec 2024 23:23:18 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AD6393E88F9 for ; Wed, 11 Dec 2024 13:23:16 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 073683E88F4 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Authentication-Results: in-4.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id E4FB51020C35 for ; Wed, 11 Dec 2024 13:20:28 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EBB552116C for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=85LReEaouifIi25b97a+VCJxP2Ph4ghtTH1RBHYk63I=; b=djxp0na4Ch4+0mitsvOeM0nM32eVKEAb2rTH1sBTwB47Alzc6yCCTjM8lYbpwtGjvQN7Fi q26FJ3kkImRy5TUkzu98MJzBZo28yBrR9/s5yJa1iQDK6VhcPTKmAz1eULuWRR6X3L2zG/ zKK0PLR67ZIyVJhlbDt85wTmW0t4mNc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=85LReEaouifIi25b97a+VCJxP2Ph4ghtTH1RBHYk63I=; b=QVU3xLhWOPLpvtLY2zkejgAkTkOvpKdZPR/XgczSTTwIOK2zw0FmYQ1iSOVx0vKPN3d/hm UTFljnEFsC4zOfBQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=85LReEaouifIi25b97a+VCJxP2Ph4ghtTH1RBHYk63I=; b=UA+FJ52dEl/l32mNsrIGd2QI1v15teYbIMceGI7lJ8nrFOz4/ltqewetgOVPbzyy0YI0mb HNZd3gQo0LU3+4Zb+fctoSI6CfQrOUl1lbDuZNK33c2QSZyOWDqRPUYLRo5CFWnwIj5gcR EjG7BHuEOC5qFMduCLB7OnR68X9qy5U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=85LReEaouifIi25b97a+VCJxP2Ph4ghtTH1RBHYk63I=; b=C8GyZqqbtRUN9C/tLguj9bcvpf75TV8FQ5xNNwh0Qh7+7RF7u+u3tWPfSN4juCvBNZsYoJ 8m17MuxQtAxTdrCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E36ED13AD7 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8K4zN4qDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:31 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-8-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=12189; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=Qu3GgaWGX48C3itged9bzi0Y451iYddO08gPQjKSdz0=; b=Wx0wzD8AUEJ0zxjNRdh7l+qDG5qDJWIPh3fqcDKfUajfjJJXBNRe7KC4yh4iASA5EywpwV3wS tQtlVTpFUkHAJuOKeJCholEhf4deSaAvGvIxJjlUNOMk4Aucen502Bf X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid] X-Spam-Score: -4.30 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-4.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 08/10] Refactor pty01 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Rewrite part of the code using the new LTP library and fix the execution of the test inside a new session via setsid(). The test is now split into multiple files, instead of having multiple test* functions executing all in one file. Fixes: https://github.com/linux-test-project/kirk/issues/28 Signed-off-by: Andrea Cervesato --- testcases/kernel/pty/pty01.c | 417 ++++++------------------------------------- 1 file changed, 52 insertions(+), 365 deletions(-) diff --git a/testcases/kernel/pty/pty01.c b/testcases/kernel/pty/pty01.c index 666b221b017fe214b7baa0b2bc608dfc2feff732..9447e3ee25965772fab6d51dcd39097b3d7fb448 100644 --- a/testcases/kernel/pty/pty01.c +++ b/testcases/kernel/pty/pty01.c @@ -1,395 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* - * - * Copyright (c) International Business Machines Corp., 2002 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (C) 2024 SUSE LLC Andrea Cervesato */ -/* 12/23/2002 Port to LTP robbiew@us.ibm.com */ -/* 06/30/2001 Port to Linux nsharoff@us.ibm.com */ +/*\ + * [Description] + * + * Verify that write/read is properly working when master and slave + * pseudo terminals communicate with each other. + */ #define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "test.h" -#include "safe_macros.h" -#include "lapi/ioctl.h" +#include "tst_test.h" -char *TCID = "pty01"; /* Test program identifier. */ -int TST_TOTAL = 5; /* Total number of test cases. */ -/**************/ - -/* - * pty master clone device - */ #define MASTERCLONE "/dev/ptmx" +#define STRING "Linux Test Project" +#define STRING_LEN strlen(STRING) -/* - * string for testing read/write on ptys - */ -#define STRING "Linux Test Project\n" - -/* - * test buffer size - */ -#define TESTSIZE 1024 - -/* - * mode we expect grantpt() to leave pty as - */ -#define PTY_MODE 020622 - -/* - * number of procs for parallel test - */ -#define NUMPROCS 15 - -/* - * test slave locking - */ -static int test1(void) +static void run(void) { - int masterfd; /* master pty fd */ - int slavefd; /* slave pty fd */ + int masterfd; + int slavefd; char *slavename; struct stat st; - char buf[TESTSIZE]; - - masterfd = SAFE_OPEN(NULL, 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 (stat(slavename, &st) != 0) { - tst_brkm(TBROK | TERRNO, NULL, "stat(%s) failed", slavename); - } - if (st.st_uid != getuid()) { - tst_brkm(TBROK, NULL, "uid mismatch"); - } - - /* grantpt() is a no-op in bionic. */ -#ifndef __BIONIC__ - if (st.st_mode != (S_IFCHR | S_IRUSR | S_IWUSR | S_IWGRP)) { - tst_brkm(TBROK, NULL, "mode mismatch (mode=%o)", st.st_mode); - } -#endif - - slavefd = open(slavename, O_RDWR); - if (slavefd >= 0) { - tst_brkm(TBROK, NULL, "open didn't fail as expected!"); - } - - if (unlockpt(masterfd) != 0) { - tst_brkm(TBROK | TERRNO, NULL, "unlockpt() failed"); - } - - slavefd = SAFE_OPEN(NULL, slavename, O_RDWR); - - /* - * test writing to the master / reading from the slave - */ - if (write(masterfd, STRING, strlen(STRING)) != strlen(STRING)) { - /* - * XXX: the errno printout might be garbage, but better to be - * safe than sorry.. - */ - tst_brkm(TFAIL | TERRNO, NULL, "write to master"); - } - - if (read(slavefd, buf, strlen(STRING)) != strlen(STRING)) { - /* XXX: Same as write above.. */ - tst_brkm(TFAIL | TERRNO, NULL, "read from slave"); - } - if (strncmp(STRING, buf, strlen(STRING) - 1) != 0) { - tst_brkm(TFAIL, NULL, - "strings are different (STRING = '%s' != buf = '%s')", - STRING, buf); - } - - /* - * test writing to the slave / reading from the master - */ - if (write(slavefd, STRING, strlen(STRING)) != strlen(STRING)) { - /* XXX: Same as write above.. */ - tst_brkm(TFAIL | TERRNO, NULL, "write to slave"); - } - - if (read(masterfd, buf, strlen(STRING)) != strlen(STRING)) { - /* XXX: Same as write above.. */ - tst_brkm(TFAIL | TERRNO, NULL, "read from master"); - } - if (strncmp(STRING, buf, strlen(STRING) - 1) != 0) { - tst_brkm(TFAIL, NULL, - "strings are different (STRING = '%s' != buf = '%s').", - STRING, buf); - } - - /* - * try an invalid ioctl on the slave... - */ - if (ioctl(slavefd, TIOCGWINSZ, NULL) == 0) { - tst_brkm(TFAIL, NULL, - "invalid slave TIOCGWINSZ ioctl succeeded.. it should " - "have failed"); - } - - /* - * try an invalid ioctl on the master... - */ - if (ioctl(masterfd, TIOCGWINSZ, NULL) == 0) { - tst_brkm(TFAIL, NULL, - "invalid master TIOCGWINSZ ioctl succeeded.. it should " - "have failed"); - } - - /* - * close pty fds - */ - if (close(slavefd) != 0) { - tst_brkm(TBROK | TERRNO, NULL, "close of slave"); - } - if (close(masterfd) != 0) { - tst_brkm(TBROK | TERRNO, NULL, "close of master"); - } - tst_resm(TPASS, "test1"); - /** NOTREACHED **/ - return 0; -} + char buf[BUFSIZ]; -/* - * test slave operations with closed master - */ -static void test2(void) -{ - int masterfd; /* master pty fd */ - int slavefd; /* slave pty fd */ - int i; - char *slavename; - char c; + memset(buf, 0, BUFSIZ); - 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 | TERRNO, NULL, "unlockpt() call failed"); - } - - slavefd = SAFE_OPEN(NULL, slavename, O_RDWR); - - /* - * close pty fds. See what happens when we close the master - * first. - */ - if (close(masterfd) != 0) { - tst_brkm(TBROK | TERRNO, NULL, "close()"); - } - - errno = 0; - if ((i = read(slavefd, &c, 1)) == 1) { - tst_brkm(TFAIL, NULL, - "reading from slave fd should have failed, but didn't" - "(read '%c')", c); - } - - if ((i = write(slavefd, &c, 1)) == 1) { - tst_brkm(TFAIL, NULL, - "writing to slave fd should have failed, but didn't"); - } + if (slavename == NULL) + tst_brk(TBROK | TERRNO, "ptsname() error"); - if (ioctl(slavefd, TIOCGWINSZ, NULL) == 0) { - tst_brkm(TFAIL, NULL, - "trying TIOCGWINSZ on slave fd should have failed, " - "but didn't"); - } + if (grantpt(masterfd) == -1) + tst_brk(TBROK | TERRNO, "grantpt() error"); - if (close(slavefd) != 0) { - tst_brkm(TBROK, NULL, "close"); + TST_EXP_PASS_SILENT(unlockpt(masterfd)); + if (TST_RET == -1) { + SAFE_CLOSE(masterfd); + return; } - tst_resm(TPASS, "test2"); -} - -/* - * test operations on master with closed slave - */ -static void test3(void) -{ - int masterfd; /* master pty fd */ - - masterfd = SAFE_OPEN(NULL, MASTERCLONE, O_RDWR); - if (ioctl(masterfd, TIOCGWINSZ, NULL) == 0) { - tst_brkm(TFAIL | TERRNO, NULL, - "trying TIOCGWINSZ on master with no open slave " - "succeeded unexpectedly"); - } - tst_resm(TPASS, "test3"); -} - -/* - * test multiple opens on slave side of pty - */ -static void test4(void) -{ - int masterfd; /* master pty fd */ - int slavefd; /* slave pty fd */ - int slavefd2; - int slavefd3; - char *slavename; + SAFE_STAT(slavename, &st); + TST_EXP_EQ_LI(st.st_uid, getuid()); - masterfd = SAFE_OPEN(NULL, MASTERCLONE, O_RDWR); - - slavename = ptsname(masterfd); - if (slavename == NULL) { - tst_brkm(TBROK, NULL, "ptsname() call failed"); - } - - if (grantpt(masterfd) != 0) { - tst_brkm(TBROK, NULL, "grantpt() call failed"); - } - - if (unlockpt(masterfd) != 0) { - tst_brkm(TBROK | TERRNO, NULL, "unlockpt() call failed"); - } - - slavefd = SAFE_OPEN(NULL, slavename, O_RDWR); + /* grantpt() is a no-op in bionic. */ +#ifndef __BIONIC__ + TST_EXP_EQ_LI(st.st_mode, 0620); +#endif - slavefd2 = open(slavename, O_RDWR); - if (slavefd < 0) { - tst_brkm(TFAIL | TERRNO, NULL, "Could not open %s (again)", - slavename); - } + slavefd = SAFE_OPEN(slavename, O_RDWR); - slavefd3 = open(slavename, O_RDWR); - if (slavefd < 0) { - tst_brkm(TFAIL | TERRNO, NULL, "Could not open %s (once more)", - slavename); - } + tst_res(TINFO, "Send message to master and read from slave"); + SAFE_WRITE(SAFE_WRITE_ALL, masterfd, STRING, STRING_LEN); + SAFE_WRITE(SAFE_WRITE_ALL, masterfd, "\n", 1); + SAFE_READ(1, slavefd, buf, STRING_LEN); + TST_EXP_EQ_STR(STRING, buf); - /* - * close pty fds. - */ - if (close(slavefd) != 0) { - tst_brkm(TBROK | TERRNO, NULL, "close slave"); - } - - if (close(slavefd2) != 0) { - tst_brkm(TBROK, NULL, "close slave again"); - } + tst_res(TINFO, "Send message to slave and read from master"); + SAFE_WRITE(SAFE_WRITE_ALL, slavefd, STRING, STRING_LEN); + SAFE_WRITE(SAFE_WRITE_ALL, masterfd, "\n", 1); + SAFE_READ(1, masterfd, buf, STRING_LEN); + TST_EXP_EQ_STR(STRING, buf); - if (close(slavefd3) != 0) { - tst_brkm(TBROK, NULL, "close slave once more"); - } - - if (close(masterfd) != 0) { - tst_brkm(TBROK, NULL, "close master"); - } - tst_resm(TPASS, "test4"); + SAFE_CLOSE(slavefd); + SAFE_CLOSE(masterfd); } -/* - * test opening/closing lots of ptys in parallel. We may run out - * of ptys for this test depending on how the system is configured, - * but that's not a fatal error. - */ -static void test5(void) +static void setup(void) { - int masterfd; /* master pty fd */ - char *slavename; - int status; - int i; - - for (i = 0; i < NUMPROCS; ++i) { - switch (fork()) { - case -1: - tst_brkm(TBROK, NULL, "fork()"); - break; - case 0: - masterfd = open(MASTERCLONE, O_RDWR); - if (masterfd < 0) { - printf("proc %d: opening %s failed: %s", - i, MASTERCLONE, strerror(errno)); - exit(1); - } - if (grantpt(masterfd) != 0) { - printf("proc %d: grantpt() call failed: %s", - i, strerror(errno)); - exit(1); - } - slavename = ptsname(masterfd); - if (slavename == NULL) { - printf("proc %d: ptsname() call failed: %s", - i, strerror(errno)); - exit(1); - } - sleep(10); - if (close(masterfd) != 0) { - printf("proc %d: close failed: %s", - i, strerror(errno)); - exit(1); - } - exit(0); - default: - break; - } - } - while (wait(&status) > 0) { - if (status) { - tst_brkm(TFAIL, NULL, - "child exited with non-zero status %d", - status); - } - } - tst_resm(TPASS, "test5"); + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); } -/* - * main test driver - */ -int main(void) -{ - test1(); - test2(); - test3(); - test4(); - test5(); - - /* - * all done - */ - tst_exit(); -} +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=lOSEOSPD; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fSBgCrf9; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=lOSEOSPD; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fSBgCrf9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZVT4PZfz1yR6 for ; Wed, 11 Dec 2024 23:22:25 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0A3E93E88FB for ; Wed, 11 Dec 2024 13:22:24 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id A63EE3E88F4 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Authentication-Results: in-3.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 33D601BBFB52 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 096521F74C for ; Wed, 11 Dec 2024 12:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1nyWzl95r8eK8KWtbW2uWhhrkKLW+CVzugpLWWL1OjM=; b=lOSEOSPDM6mq7WKtyQHA/wvuW3aLlpN+RePNSZvpEDxW6nJwxBtkE0RlfgGz6I8ht+3nI5 yaKxshXbQqLhGKeJOfq9bARMV+KXu1VO9UO5ngW06eqChOewnq+P0YOseBWYVtQ5+Js+qY 5b3LdFeZuCl7BYEM70V+i001YUi0rSA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1nyWzl95r8eK8KWtbW2uWhhrkKLW+CVzugpLWWL1OjM=; b=fSBgCrf90u7ugyLP6EAwNdZkz2QhaB9g9zkis1ywfHCIDUnRMg4OEKcuShQmjbOuSo4z2J iO3fPeW17r9NNMDg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1nyWzl95r8eK8KWtbW2uWhhrkKLW+CVzugpLWWL1OjM=; b=lOSEOSPDM6mq7WKtyQHA/wvuW3aLlpN+RePNSZvpEDxW6nJwxBtkE0RlfgGz6I8ht+3nI5 yaKxshXbQqLhGKeJOfq9bARMV+KXu1VO9UO5ngW06eqChOewnq+P0YOseBWYVtQ5+Js+qY 5b3LdFeZuCl7BYEM70V+i001YUi0rSA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1nyWzl95r8eK8KWtbW2uWhhrkKLW+CVzugpLWWL1OjM=; b=fSBgCrf90u7ugyLP6EAwNdZkz2QhaB9g9zkis1ywfHCIDUnRMg4OEKcuShQmjbOuSo4z2J iO3fPeW17r9NNMDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E9D9913A69 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mFzIOIqDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:32 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-9-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=2607; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=/0lRl6aQr62MJhGCBCIA48fYEX9Rp2M6Bvi4mduG72k=; b=pL9+E8T5/1I/eCNF6dZdfhk+R6MAzIAOvDDVrm7/ZNJLsCadF2SVX4N5Ey8hPmJ1SmPPUhMl6 nmsOXmZlS4FDdTsX5MVf5Lk4K5MmItDv6o5GIwrTLmTm3lGNfbjAO7S X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid] X-Spam-Score: -4.30 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-3.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 09/10] Add pty08 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Verify that slave pseudo-terminal fails reading/writing if master has been closed. Signed-off-by: Andrea Cervesato --- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/pty08.c | 60 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/runtest/pty b/runtest/pty index 6343da391ba17627abaf09aa5a23509e4f745556..365a46ee9730aa36b22dbbdbfba82ac0d491ac94 100644 --- a/runtest/pty +++ b/runtest/pty @@ -6,6 +6,7 @@ pty04 pty04 pty05 pty05 pty06 pty06 pty07 pty07 +pty08 pty08 ptem01 ptem01 ptem02 ptem02 ptem03 ptem03 diff --git a/testcases/kernel/pty/.gitignore b/testcases/kernel/pty/.gitignore index 630d7fcf7b0e0adfbc21b793fa456d6c5f5e4ad9..7d8d4dceda84f2e2695a8bee39abfe894288b8b6 100644 --- a/testcases/kernel/pty/.gitignore +++ b/testcases/kernel/pty/.gitignore @@ -12,3 +12,4 @@ /pty05 /pty06 /pty07 +/pty08 diff --git a/testcases/kernel/pty/pty08.c b/testcases/kernel/pty/pty08.c new file mode 100644 index 0000000000000000000000000000000000000000..1e3eb191b2e2a88258319da90e29ed582cdfa7b7 --- /dev/null +++ b/testcases/kernel/pty/pty08.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Verify that slave pseudo-terminal fails reading/writing if master has been + * closed. + */ + +#define _GNU_SOURCE + +#include "tst_test.h" + +#define MASTERCLONE "/dev/ptmx" + +static void run(void) +{ + int masterfd, slavefd; + char *slavename; + char buf; + + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR); + + slavename = ptsname(masterfd); + if (slavename == NULL) + tst_brk(TBROK | TERRNO, "ptsname() error"); + + tst_res(TINFO, "pts device location is %s", slavename); + + if (grantpt(masterfd) == -1) + tst_brk(TBROK | TERRNO, "grantpt() error"); + + if (unlockpt(masterfd) == -1) + tst_brk(TBROK | TERRNO, "unlockpt() error"); + + slavefd = SAFE_OPEN(slavename, O_RDWR); + + tst_res(TINFO, "Closing master communication"); + SAFE_CLOSE(masterfd); + + TST_EXP_FAIL(read(slavefd, &buf, 1), EIO); + TST_EXP_FAIL(write(slavefd, &buf, 1), EIO); + + SAFE_CLOSE(slavefd); +} + +static void setup(void) +{ + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, +}; From patchwork Wed Dec 11 12:20:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 2021285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ZJNYlrI8; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=pUR3rCCG; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=ZJNYlrI8; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=pUR3rCCG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) 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=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7ZVq0QN3z1yRy for ; Wed, 11 Dec 2024 23:22:43 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 586E23E890A for ; Wed, 11 Dec 2024 13:22:41 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id C2C853E88FB for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Authentication-Results: in-6.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 2DE98140B5A9 for ; Wed, 11 Dec 2024 13:20:29 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 046401F74B for ; Wed, 11 Dec 2024 12:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U58GSWe4DdDcBPWWrN1BkeneKex/aMiVeJ5yVCTsTxQ=; b=ZJNYlrI8iys60DdZ3HRMxilcnhJ/IHKRP5NRoAqQ1idj8O3wbIfHwz/I/DkJYWIsEeWQ3B fXCi9yxK/C0M+Bs1+EVVCkkm7rk7RHji+rgawwxXjfTgOaOXDTVbLJaSPHn2KlxkZHHG2c 5bcEC9TDMxUssotYVivU+wyj9JK+ppI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U58GSWe4DdDcBPWWrN1BkeneKex/aMiVeJ5yVCTsTxQ=; b=pUR3rCCG6WgyP66ZEI2tzAAcn27JNnY2mv9xHI4NcUnGRK/e7JvaC0hSaJGZiGD3EfXgCL rh22IgUyi92knXAw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U58GSWe4DdDcBPWWrN1BkeneKex/aMiVeJ5yVCTsTxQ=; b=ZJNYlrI8iys60DdZ3HRMxilcnhJ/IHKRP5NRoAqQ1idj8O3wbIfHwz/I/DkJYWIsEeWQ3B fXCi9yxK/C0M+Bs1+EVVCkkm7rk7RHji+rgawwxXjfTgOaOXDTVbLJaSPHn2KlxkZHHG2c 5bcEC9TDMxUssotYVivU+wyj9JK+ppI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1733919627; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U58GSWe4DdDcBPWWrN1BkeneKex/aMiVeJ5yVCTsTxQ=; b=pUR3rCCG6WgyP66ZEI2tzAAcn27JNnY2mv9xHI4NcUnGRK/e7JvaC0hSaJGZiGD3EfXgCL rh22IgUyi92knXAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F051213998 for ; Wed, 11 Dec 2024 12:20:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yC9aOoqDWWdNAwAAD6G6ig (envelope-from ) for ; Wed, 11 Dec 2024 12:20:26 +0000 From: Andrea Cervesato Date: Wed, 11 Dec 2024 13:20:33 +0100 MIME-Version: 1.0 Message-Id: <20241211-fix_setsid_tests-v1-10-e103f36c6462@suse.com> References: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> In-Reply-To: <20241211-fix_setsid_tests-v1-0-e103f36c6462@suse.com> To: ltp@lists.linux.it X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733919626; l=3265; i=andrea.cervesato@suse.com; s=20240812; h=from:subject:message-id; bh=IKg+lBwFGbHy86VIvjdWZm4lIKxTlK9YtqFa7OaaRFw=; b=Yk2hwcjhW1FcCFzPTaW43pqHJjIX0Wlq2589GN4M/LN9gtHSaJ1rguQLdt3iNiiCg2/oVnUz5 odkTot2zAAnCaknTdjc68M/oqDBCvK3sYP637KrHq4V7UTviWFl58Fo X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=RG/nLJ5snb1tLKGwSORQXBJ5XA4juT0WF2Pc/lq9meo= X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; PREVIOUSLY_DELIVERED(0.00)[ltp@lists.linux.it]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email] X-Spam-Level: X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-6.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-6.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH 10/10] Add pty09 test X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Verify that slave pseudo-terminal can be opened multiple times in parallel. Signed-off-by: Andrea Cervesato --- runtest/pty | 1 + testcases/kernel/pty/.gitignore | 1 + testcases/kernel/pty/pty09.c | 89 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/runtest/pty b/runtest/pty index 365a46ee9730aa36b22dbbdbfba82ac0d491ac94..4b1abe7a602a14456877f3bc42f2275a3be0f8f0 100644 --- a/runtest/pty +++ b/runtest/pty @@ -7,6 +7,7 @@ pty05 pty05 pty06 pty06 pty07 pty07 pty08 pty08 +pty09 pty09 ptem01 ptem01 ptem02 ptem02 ptem03 ptem03 diff --git a/testcases/kernel/pty/.gitignore b/testcases/kernel/pty/.gitignore index 7d8d4dceda84f2e2695a8bee39abfe894288b8b6..2d0c8bb6ff7d6883abfc7838e257b9be50244b69 100644 --- a/testcases/kernel/pty/.gitignore +++ b/testcases/kernel/pty/.gitignore @@ -13,3 +13,4 @@ /pty06 /pty07 /pty08 +/pty09 diff --git a/testcases/kernel/pty/pty09.c b/testcases/kernel/pty/pty09.c new file mode 100644 index 0000000000000000000000000000000000000000..a9adf6ef619334b858fb99d5c388c0adac3976f5 --- /dev/null +++ b/testcases/kernel/pty/pty09.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2002 + * Copyright (C) 2024 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] + * + * Verify that slave pseudo-terminal can be opened multiple times in parallel. + */ + +#define _GNU_SOURCE + +#include "tst_test.h" + +#define MASTERCLONE "/dev/ptmx" + +static unsigned int count_avail_pid(void) +{ + DIR *dir; + struct dirent *ent; + struct rlimit limit; + unsigned int count = 0; + unsigned int max_pid_num; + + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); + + SAFE_GETRLIMIT(RLIMIT_NOFILE, &limit); + + dir = SAFE_OPENDIR("/proc/self/fd"); + while ((ent = SAFE_READDIR(dir))) + count++; + + SAFE_CLOSEDIR(dir); + + max_pid_num = limit.rlim_cur - count; + + tst_res(TINFO, "Available number of pids: %u", max_pid_num); + + return max_pid_num; +} + +static void run(void) +{ + int masterfd; + char *slavename; + unsigned int max_pid_num; + + masterfd = SAFE_OPEN(MASTERCLONE, O_RDWR); + + slavename = ptsname(masterfd); + if (slavename == NULL) + tst_brk(TBROK | TERRNO, "ptsname() error"); + + tst_res(TINFO, "pts device location is %s", slavename); + + if (grantpt(masterfd) == -1) + tst_brk(TBROK | TERRNO, "grantpt() error"); + + if (unlockpt(masterfd) == -1) + tst_brk(TBROK | TERRNO, "unlockpt() error"); + + max_pid_num = count_avail_pid(); + + int slavefd[max_pid_num]; + + for (uint32_t i = 0; i < max_pid_num; i++) + slavefd[i] = SAFE_OPEN(slavename, O_RDWR); + + tst_res(TPASS, "%s has been opened %d times", slavename, max_pid_num); + + for (uint32_t i = 0; i < max_pid_num; i++) + SAFE_CLOSE(slavefd[i]); + + SAFE_CLOSE(masterfd); +} + +static void setup(void) +{ + if (access(MASTERCLONE, F_OK)) + tst_brk(TBROK, "%s device doesn't exist", MASTERCLONE); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, +};