From patchwork Wed Aug 9 13:18:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avinesh Kumar X-Patchwork-Id: 1819316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=mpXK1rbN; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=tZ+gy/Jk; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RLVxx0WCMz1yfB for ; Wed, 9 Aug 2023 23:19:00 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D832E3CB6EA for ; Wed, 9 Aug 2023 15:18:56 +0200 (CEST) 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 [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id D5D453C9984 for ; Wed, 9 Aug 2023 15:18:53 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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 36406601101 for ; Wed, 9 Aug 2023 15:18:51 +0200 (CEST) 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-out2.suse.de (Postfix) with ESMTPS id 284AF1F390 for ; Wed, 9 Aug 2023 13:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691587130; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xTnEkQKeYkrqKgZ+o5FdeI9Q22OkgPJKB6w1+Zt8CsI=; b=mpXK1rbN40jLYwyqSQePE9MzvdeiaZC6Inl8+4+l3WSwJdNWvBE1yax+hLs/PJGf9mGBZ5 IQiLfT7j8TI+ThOScDjOqGZI8GyIAXPYDc2QNpAQo9bHJu2xYT03MMpaue/WosmombMmgS PIuFar/Y3Z/TneqVM91OlSRQHVFkRsw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691587130; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xTnEkQKeYkrqKgZ+o5FdeI9Q22OkgPJKB6w1+Zt8CsI=; b=tZ+gy/JkFO7Z9v2a3R6Z8VLdJEPQzmqO+09VfeJH0/EnixxUjvgKwM++5DKjGIXjoYnLAc B6BbXCytTBQlpCAg== 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 B2CE613251 for ; Wed, 9 Aug 2023 13:18:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +g+cIjmS02TOCgAAMHmgww (envelope-from ) for ; Wed, 09 Aug 2023 13:18:49 +0000 From: Avinesh Kumar To: ltp@lists.linux.it Date: Wed, 9 Aug 2023 18:48:45 +0530 Message-ID: <20230809131847.10914-1-akumar@suse.de> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.1 at in-5.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 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 Subject: [LTP] [PATCH v2 1/2] sbrk01.c: Refactor the 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" Signed-off-by: Avinesh Kumar --- testcases/kernel/syscalls/sbrk/sbrk01.c | 121 +++++------------------- 1 file changed, 25 insertions(+), 96 deletions(-) diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c b/testcases/kernel/syscalls/sbrk/sbrk01.c index ce26b1503..c99fb0106 100644 --- a/testcases/kernel/syscalls/sbrk/sbrk01.c +++ b/testcases/kernel/syscalls/sbrk/sbrk01.c @@ -1,111 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * AUTHOR : William Roske - * CO-PILOT : Dave Fenner - * - * 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/ - * - */ -/* - * DESCRIPTION - * 1.) test sbrk(8192) should return successfully. - * 2.) test sbrk(-8192) should return successfully. + * AUTHOR : William Roske, CO-PILOT : Dave Fenner + * Copyright (c) 2023 SUSE LLC Avinesh Kumar */ -#include -#include -#include -#include -#include - -#include "test.h" +/*\ + * [Description] + * + * Verify that sbrk() successfully increments or decrements the program's + * data break. + */ -char *TCID = "sbrk01"; +#include "tst_test.h" -static struct test_case_t { +static struct tcase { long increment; -} test_cases[] = { +} tcases[] = { + {0}, {8192}, - {-8192}, + {-8192} }; -static void setup(void); -static void sbrk_verify(const struct test_case_t *); -static void cleanup(void); - -int TST_TOTAL = ARRAY_SIZE(test_cases); - -int main(int ac, char **av) +static void run(unsigned int i) { - int lc; - int i; - - tst_parse_opts(ac, av, NULL, NULL); + struct tcase *tc = &tcases[i]; - setup(); + TESTPTR(sbrk(tc->increment)); - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - for (i = 0; i < TST_TOTAL; i++) - sbrk_verify(&test_cases[i]); - } - - cleanup(); - tst_exit(); - -} - -static void setup(void) -{ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - TEST_PAUSE; + if (TST_RET_PTR == (void *) -1) + tst_res(TFAIL | TTERRNO, "sbrk(%ld) failed", tc->increment); + else + tst_res(TPASS, "sbrk(%ld) returned %p", tc->increment, TST_RET_PTR); } -static void sbrk_verify(const struct test_case_t *test) -{ - void *tret; - - tret = sbrk(test->increment); - TEST_ERRNO = errno; - - if (tret == (void *)-1) { - tst_resm(TFAIL | TTERRNO, "sbrk - Increase by %ld bytes failed", - test->increment); - } else { - tst_resm(TPASS, "sbrk - Increase by %ld bytes returned %p", - test->increment, tret); - } -} - -static void cleanup(void) -{ -} +static struct tst_test test = { + .test = run, + .tcnt = ARRAY_SIZE(tcases) +}; From patchwork Wed Aug 9 13:18:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avinesh Kumar X-Patchwork-Id: 1819317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=hzngr1Jw; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Kpjjvgk9; dkim-atps=neutral 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 (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RLVy75MGFz1yfB for ; Wed, 9 Aug 2023 23:19:11 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A524C3CD0D3 for ; Wed, 9 Aug 2023 15:19:09 +0200 (CEST) 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 [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id DB0313CACD6 for ; Wed, 9 Aug 2023 15:18:53 +0200 (CEST) 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-2.smtp.seeweb.it (Postfix) with ESMTPS id EB15964027B for ; Wed, 9 Aug 2023 15:18:52 +0200 (CEST) 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 771CA21853 for ; Wed, 9 Aug 2023 13:18:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691587132; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HYkBl4Vi+Xoc8Eezh2TBRey5ouix5YuWeeBRVrk8uZQ=; b=hzngr1JwKxhW4GpApsaCpIipxD6ofua10PTYjOIZ20VTYxTyOn3TtCIHQ0i7qJGt1m+SE5 /d1rAZsIbrGrOUpI0wppiWZtMPD/JhS8aOLuZX+TUmyjRg+fqe/PfXv3mIHQD0yNqve+PI fEBXJEiYYV9qYrFqdJnupn0fqkYNujY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691587132; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HYkBl4Vi+Xoc8Eezh2TBRey5ouix5YuWeeBRVrk8uZQ=; b=Kpjjvgk9wi18gt3ORFjaadgkdXihJQTDDrYXQILl5BG3xydER8KaAZ2SI5SV2uFHGN6XSp 8gDdP6oi/21xt+Dw== 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 28C3E13251 for ; Wed, 9 Aug 2023 13:18:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IKraADyS02TXCgAAMHmgww (envelope-from ) for ; Wed, 09 Aug 2023 13:18:52 +0000 From: Avinesh Kumar To: ltp@lists.linux.it Date: Wed, 9 Aug 2023 18:48:46 +0530 Message-ID: <20230809131847.10914-2-akumar@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809131847.10914-1-akumar@suse.de> References: <20230809131847.10914-1-akumar@suse.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.1 at in-2.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 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 Subject: [LTP] [PATCH v2 2/2] sbrk02.c: Refactor the 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" Signed-off-by: Avinesh Kumar --- testcases/kernel/syscalls/sbrk/sbrk02.c | 101 ++++++------------------ 1 file changed, 26 insertions(+), 75 deletions(-) diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c b/testcases/kernel/syscalls/sbrk/sbrk02.c index 84744ef90..7fccc4d3a 100644 --- a/testcases/kernel/syscalls/sbrk/sbrk02.c +++ b/testcases/kernel/syscalls/sbrk/sbrk02.c @@ -1,101 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2014 Fujitsu Ltd. * Author: Zeng Linggang - * - * 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. + * Copyright (c) 2023 SUSE LLC Avinesh Kumar */ -/* - * DESCRIPTION - * Check sbrk() with error condition that should produce ENOMEM. - */ - -#include -#include -#include "test.h" -#define INC 16*1024*1024 +/*\ + * [Description] + * + * Verify that sbrk() on failure sets errno to ENOMEM. + */ -char *TCID = "sbrk02"; -int TST_TOTAL = 1; -static void setup(void); -static void sbrk_verify(void); -static void cleanup(void); +#include "tst_test.h" +#define INC (16*1024*1024) static long increment = INC; -int main(int argc, char *argv[]) +static void run(void) { - int lc; - int i; - - tst_parse_opts(argc, argv, NULL, NULL); - - setup(); + TESTPTR(sbrk(increment)); - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - for (i = 0; i < TST_TOTAL; i++) - sbrk_verify(); + if (TST_RET_PTR != (void *)-1) { + tst_res(TFAIL, "sbrk(%ld) unexpectedly passed and returned %p, " + "expected (void *)-1 with errno=%d", + increment, TST_RET_PTR, ENOMEM); + return; } - cleanup(); - tst_exit(); + if (TST_ERR == ENOMEM) + tst_res(TPASS | TTERRNO, "sbrk(%ld) failed as expected", increment); + else + tst_res(TFAIL | TTERRNO, "sbrk(%ld) failed but unexpected errno, " + "expected errno=%d - %s", + increment, ENOMEM, strerror(ENOMEM)); } static void setup(void) { void *ret = NULL; - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - TEST_PAUSE; - - /* call sbrk until it fails or increment overflows */ while (ret != (void *)-1 && increment > 0) { ret = sbrk(increment); increment += INC; } - tst_resm(TINFO | TERRNO, "setup() bailing inc: %ld, ret: %p, sbrk: %p", - increment, ret, sbrk(0)); - - errno = 0; -} - -static void sbrk_verify(void) -{ - void *tret; - - tret = sbrk(increment); - TEST_ERRNO = errno; - - if (tret != (void *)-1) { - tst_resm(TFAIL, - "sbrk(%ld) returned %p, expected (void *)-1, errno=%d", - increment, tret, ENOMEM); - return; - } - - if (TEST_ERRNO == ENOMEM) { - tst_resm(TPASS | TTERRNO, "sbrk(%ld) failed as expected", - increment); - } else { - tst_resm(TFAIL | TTERRNO, - "sbrk(%ld) failed unexpectedly; expected: %d - %s", - increment, ENOMEM, strerror(ENOMEM)); - } } -static void cleanup(void) -{ -} +static struct tst_test test = { + .test_all = run, + .setup = setup +};