From patchwork Wed Feb 16 10:40:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1593613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=iXA41FWV; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5GVLsb/Z; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JzDy22tQZz9sDX for ; Wed, 16 Feb 2022 21:40:40 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 900043CA079 for ; Wed, 16 Feb 2022 11:40:35 +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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 365D63C9564 for ; Wed, 16 Feb 2022 11:40:33 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (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 EF9541001286 for ; Wed, 16 Feb 2022 11:40:28 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1B26F21634; Wed, 16 Feb 2022 10:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1645008028; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=rrIL7VeuRxrQZhD306UzTKzyTBvTYgZMXwQ2QVUWIjk=; b=iXA41FWVczGVo2B46E8PLvtJXpYI1VvBrRIUpHgHJ+b4P7UvLjY4UrgRpjP5zHMgZoz8U9 5ej5vJ+KUpwkbrh+QkhgtBF30tFnJOlpieo3tLK4dqrUx/AGRfOiqCnnKPafQQoShNF47Q FnAs3Gr4ZJPaXUAVsu93OQPWWp9AfrM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1645008028; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=rrIL7VeuRxrQZhD306UzTKzyTBvTYgZMXwQ2QVUWIjk=; b=5GVLsb/ZC3ZnyLo+YwnXJCTwK6+k+jhk3A9j+TI5uDEoMyhp5cawgsmsBJSK7+2G3COFRv KFGghVgaF0IOz1DQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D965B13A95; Wed, 16 Feb 2022 10:40:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id n6rxMpvUDGJbFwAAMHmgww (envelope-from ); Wed, 16 Feb 2022 10:40:27 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Wed, 16 Feb 2022 11:40:26 +0100 Message-Id: <20220216104026.18326-1-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean 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, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v1] Rewrite getcontext01.c test using new LTP API 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" Removed old LTP API from getcontext01.c test and check if getcontext is present in the current system. The check is useful in those systems where libmusl is used by default. Signed-off-by: Andrea Cervesato --- configure.ac | 1 + .../kernel/syscalls/getcontext/getcontext01.c | 93 +++++-------------- 2 files changed, 24 insertions(+), 70 deletions(-) diff --git a/configure.ac b/configure.ac index 8d2c5b1c4..41a21a636 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,7 @@ AC_CHECK_FUNCS_ONCE([ \ fspick \ fstatat \ getauxval \ + getcontext \ getdents \ getdents64 \ io_pgetevents \ diff --git a/testcases/kernel/syscalls/getcontext/getcontext01.c b/testcases/kernel/syscalls/getcontext/getcontext01.c index 48e78907f..fe9971362 100644 --- a/testcases/kernel/syscalls/getcontext/getcontext01.c +++ b/testcases/kernel/syscalls/getcontext/getcontext01.c @@ -1,89 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved. - * Author: Prashant P Yendigeri - * - * 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. - * - * 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. + * Author: Prashant P Yendigeri + * Copyright (C) 2022 SUSE LLC Andrea Cervesato */ -#include - -#include -#include -#include -#include - -#include "test.h" - -char *TCID = "getcontext01"; +/*\ + * [Description] + * + * Test getting user context functionality. + */ -#if !defined(__UCLIBC__) +#include "config.h" +#include "tst_test.h" -static void setup(void); -static void cleanup(void); +#ifdef HAVE_GETCONTEXT -int TST_TOTAL = 1; +#include -static void test_getcontext(void) +static void run(void) { ucontext_t ptr; TEST(getcontext(&ptr)); - if (TEST_RETURN == -1) { - if (errno == ENOSYS) - tst_resm(TCONF, "getcontext not implemented in libc"); - else - tst_resm(TFAIL | TTERRNO, "getcontext failed"); - } else if (TEST_RETURN == 0) { - tst_resm(TPASS, "getcontext passed"); - } else { - tst_resm(TFAIL, "Unexpected return value %li", TEST_RETURN); - } -} - -int main(int ac, char **av) -{ - int lc; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; + if (TST_RET < 0) + tst_res(TFAIL, "getcontext: %s", tst_strerrno(TST_ERR)); - test_getcontext(); - } - - cleanup(); - tst_exit(); + if (TST_RET == 0) + tst_res(TPASS, "getcontext passed"); + else + tst_res(TFAIL, "Unexpected return value %li", TST_RET); } -static void setup(void) -{ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - TEST_PAUSE; -} - -static void cleanup(void) -{ -} +static struct tst_test test = { + .test_all = run, +}; #else /* systems that dont support obsolete getcontext */ -int main(void) -{ - tst_brkm(TCONF, NULL, "system doesn't have getcontext support"); -} +TST_TEST_TCONF("system doesn't have getcontext support"); #endif