{"id":2224017,"url":"http://patchwork.ozlabs.org/api/patches/2224017/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/patch/20260416-stream_refactoring-v2-2-8321b1ec6f68@suse.com/","project":{"id":59,"url":"http://patchwork.ozlabs.org/api/projects/59/?format=json","name":"Linux Test Project development","link_name":"ltp","list_id":"ltp.lists.linux.it","list_email":"ltp@lists.linux.it","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260416-stream_refactoring-v2-2-8321b1ec6f68@suse.com>","list_archive_url":null,"date":"2026-04-16T14:33:36","name":"[v2,2/7] fs: rewrite stream01 test using new API","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"fcef284ae770897cf1077fd6050b02afdd98b013","submitter":{"id":83220,"url":"http://patchwork.ozlabs.org/api/people/83220/?format=json","name":"Andrea Cervesato","email":"andrea.cervesato@suse.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/ltp/patch/20260416-stream_refactoring-v2-2-8321b1ec6f68@suse.com/mbox/","series":[{"id":500172,"url":"http://patchwork.ozlabs.org/api/series/500172/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/list/?series=500172","date":"2026-04-16T14:33:35","name":"Rewrite fs stream testing suite","version":2,"mbox":"http://patchwork.ozlabs.org/series/500172/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224017/comments/","check":"warning","checks":"http://patchwork.ozlabs.org/api/patches/2224017/checks/","tags":{},"related":[],"headers":{"Return-Path":"<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>","X-Original-To":["incoming@patchwork.ozlabs.org","ltp@lists.linux.it"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","ltp@picard.linux.it"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=uF966s80;\n\tdkim=fail reason=\"signature verification failed\" header.d=suse.de\n header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519\n header.b=WpbfWIQN;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key)\n header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa\n header.b=AQ7qKfJI;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=w0g1ZtGe;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=2001:1418:10:5::2; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)","smtp-out2.suse.de;\n\tnone"],"Received":["from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fxL9r5kCSz1yHV\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 00:34:08 +1000 (AEST)","from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id A54B93E4AD4\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 16:34:06 +0200 (CEST)","from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id CAC063E1685\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 16:33:40 +0200 (CEST)","from smtp-out2.suse.de (smtp-out2.suse.de\n [IPv6:2a07:de40:b251:101:10:150:64:2])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 2FC2D10006C1\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 16:33:38 +0200 (CEST)","from imap1.dmz-prg2.suse.org (unknown [10.150.64.97])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by smtp-out2.suse.de (Postfix) with ESMTPS id F18705BCFF;\n Thu, 16 Apr 2026 14:33:36 +0000 (UTC)","from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CBA7F593A5;\n Thu, 16 Apr 2026 14:33:36 +0000 (UTC)","from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n by imap1.dmz-prg2.suse.org with ESMTPSA id 2GeuL0Dz4GniGQAAD6G6ig\n (envelope-from <andrea.cervesato@suse.de>); Thu, 16 Apr 2026 14:33:36 +0000"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1776350017;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=zNvweveLksEIgbqxDOWT4YwGPOo/y8SFjPJ/HQJ2aII=;\n b=uF966s80HxZfWZB5sdd4eWAMNnBC4Yb67qOTXpRzPOt8A9qXObd/wjjshN2GKbaFtjxRPf\n s+TJQyO70AtMtSoMjv9cr0iXzmbbzr5YhLwFm7L7bgwhUXp7Q3SBUdVoOJ1HEvRMW5UD6z\n Ng5hSGWD+OC68p6f9AKnl9nNnLBFwXY=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776350017;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=zNvweveLksEIgbqxDOWT4YwGPOo/y8SFjPJ/HQJ2aII=;\n b=WpbfWIQNaWlmtWdJfk2ZrFEVIJEs1Jd2GOH8tAmm2ZeTTkd4DleQfrnZmpJMFwG1whUXrG\n 0tiM1P0JCVG2s2DA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1776350016;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=zNvweveLksEIgbqxDOWT4YwGPOo/y8SFjPJ/HQJ2aII=;\n b=AQ7qKfJI4dlq1XlMlLaGCbESi6eC88TrgWEXY/WESMA+HnFCMXsk46sYi3H9C4Vzd/wbT9\n yoUlRFpthZG8ja/oK/74UveaTga95JUVwkRDuIZQdncM1ZiRpn/3i548bn69Z1x8IZHvo8\n DyH5e4hmDR7m0rHRiPtYPQgUM6WuU5Q=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776350016;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=zNvweveLksEIgbqxDOWT4YwGPOo/y8SFjPJ/HQJ2aII=;\n b=w0g1ZtGevPQ73l7hwbivEUaUYC5bv2JeXWhUp1sjO/sH/RGmXhPweEPayga8zoy9Yhd9s5\n SeDM9a3fW0EDoSBw=="],"From":"Andrea Cervesato <andrea.cervesato@suse.de>","Date":"Thu, 16 Apr 2026 16:33:36 +0200","MIME-Version":"1.0","Message-Id":"<20260416-stream_refactoring-v2-2-8321b1ec6f68@suse.com>","References":"<20260416-stream_refactoring-v2-0-8321b1ec6f68@suse.com>","In-Reply-To":"<20260416-stream_refactoring-v2-0-8321b1ec6f68@suse.com>","To":"Linux Test Project <ltp@lists.linux.it>","X-Mailer":"b4 0.14.2","X-Developer-Signature":"v=1; a=ed25519-sha256; t=1776350016; l=6295;\n i=andrea.cervesato@suse.com; s=20251210; h=from:subject:message-id;\n bh=KsB9Mqim4sxKCSV4Z1DNb2b/uUwFP0wc0B/hxWG+1+g=;\n b=ytoIiCsnkhhD3Za5DMLTf+uOK49trmGYBMGWQ2J+B/HunV9fLzbBRZWhIbjufnP9VGrsqCqa5\n zSO6OrgrSRTAM3gzKPDxua6bMHUgf1HvCo8SLfxn912TLHhp0VUxhdK","X-Developer-Key":"i=andrea.cervesato@suse.com; a=ed25519;\n pk=zKY+6GCauOiuHNZ//d8PQ/UL4jFCTKbXrzXAOQSLevI=","X-Spamd-Result":"default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%];\n NEURAL_HAM_LONG(-1.00)[-1.000];\n NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain];\n RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2];\n FUZZY_RATELIMITED(0.00)[rspamd.com];\n RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n URIBL_BLOCKED(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo];\n TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+];\n FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[];\n RCVD_COUNT_TWO(0.00)[2];\n DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid, suse.com:email,\n imap1.dmz-prg2.suse.org:helo]","X-Spam-Score":"-4.30","X-Spam-Level":"","X-Spam-Status":"No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no\n autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on in-4.smtp.seeweb.it","X-Virus-Scanned":"clamav-milter 1.0.9 at in-4.smtp.seeweb.it","X-Virus-Status":"Clean","Subject":"[LTP] [PATCH v2 2/7] fs: rewrite stream01 test using new API","X-BeenThere":"ltp@lists.linux.it","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"Linux Test Project <ltp.lists.linux.it>","List-Unsubscribe":"<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>","List-Archive":"<http://lists.linux.it/pipermail/ltp/>","List-Post":"<mailto:ltp@lists.linux.it>","List-Help":"<mailto:ltp-request@lists.linux.it?subject=help>","List-Subscribe":"<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it","Sender":"\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>"},"content":"From: Andrea Cervesato <andrea.cervesato@suse.com>\n\nOld LTP API is deprecated. Convert stream01 to new tst_test.h-based\nAPI, using SAFE_FOPEN/SAFE_FWRITE/SAFE_FREOPEN/SAFE_FCLOSE macros\nand structured result reporting.\n\nSigned-off-by: Andrea Cervesato <andrea.cervesato@suse.com>\n---\n testcases/kernel/fs/stream/stream01.c | 155 +++++++++++-----------------------\n 1 file changed, 49 insertions(+), 106 deletions(-)","diff":"diff --git a/testcases/kernel/fs/stream/stream01.c b/testcases/kernel/fs/stream/stream01.c\nindex af56bca3b916c080328c3356681efbd869b961d2..ec4bf96a47a0fc291a4c9c9c13f46705d878ca91 100644\n--- a/testcases/kernel/fs/stream/stream01.c\n+++ b/testcases/kernel/fs/stream/stream01.c\n@@ -1,127 +1,70 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n /*\n+ * Copyright (c) International Business Machines  Corp., 2002\n+ *\tported from SPIE section2/filesuite/stream1.c, by Airong Zhang\n  *\n- *   Copyright (c) International Business Machines  Corp., 2002\n- *\n- *   This program is free software;  you can redistribute it and/or modify\n- *   it under the terms of the GNU General Public License as published by\n- *   the Free Software Foundation; either version 2 of the License, or\n- *   (at your option) any later version.\n+ * Copyright (c) 2026 Andrea Cervesato <andrea.cervesato@suse.com>\n+ */\n+\n+/*\\\n+ * Verify that `freopen()` substitutes the named file in place of stream.\n  *\n- *   This program is distributed in the hope that it will be useful,\n- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of\n- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See\n- *   the GNU General Public License for more details.\n+ * [Algorithm]\n  *\n- *   You should have received a copy of the GNU General Public License\n- *   along with this program;  if not, write to the Free Software\n- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n+ * - fopen() a stream\n+ * - fwrite() something inside it\n+ * - perform freopen() creating a new stream pointing to the first one\n+ * - fwrite() data inside the new stream\n+ * - check that second write to stream went to the file specified by freopen()\n  */\n \n-/* ported from SPIE section2/filesuite/stream1.c, by Airong Zhang */\n+#include \"tst_test.h\"\n+#include \"tst_safe_stdio.h\"\n \n-/*======================================================================\n-\t=================== TESTPLAN SEGMENT ===================\n->KEYS:  < freopen()\n->WHAT:  < 1) check that freopen substitutes the named file in place of stream.\n->HOW:   < 1) open a stream, write something to it, perform freopen and\n-\t<    write some more. Check that second write to stream went to\n-\t<    the file specified by freopen.\n->BUGS:  <\n-======================================================================*/\n+#define FILENAME1 \"ltp_file1.txt\"\n+#define FILENAME2 \"ltp_file2.txt\"\n \n-#include <stdio.h>\n-#include <errno.h>\n-#include \"test.h\"\n+static char *buff_file1 = \"abc\";\n+static char *buff_file2 = \"def\";\n \n-char *TCID = \"stream01\";\n-int TST_TOTAL = 1;\n-int local_flag;\n+static void read_file(const char *file, const char *str, size_t n)\n+{\n+\tchar buf[128];\n+\tFILE *stream;\n+\tsize_t len;\n \n-#define PASSED 1\n-#define FAILED 0\n+\tmemset(buf, 0, sizeof(buf));\n \n-/* XXX: add setup and cleanup. */\n+\tstream = SAFE_FOPEN(file, \"r\");\n+\tlen = SAFE_FREAD(buf, 1, n, stream);\n+\tSAFE_FCLOSE(stream);\n \n-char progname[] = \"stream01()\";\n-char tempfile1[40] = \"\";\n-char tempfile2[40] = \"\";\n+\tTST_EXP_EXPR(len == n, \"Read the entire %s file buffer\", file);\n+\tTST_EXP_EQ_STRN(buf, str, n);\n+}\n \n-/*--------------------------------------------------------------------*/\n-int main(int ac, char *av[])\n+static void run(void)\n {\n \tFILE *stream;\n-\tchar buf[10];\n-\tint i;\n-\tint lc;\n-\n-\t/*\n-\t * parse standard options\n-\t */\n-\ttst_parse_opts(ac, av, NULL, NULL);\n \n-\tlocal_flag = PASSED;\n-\ttst_tmpdir();\n-\tfor (lc = 0; TEST_LOOPING(lc); lc++) {\n+\ttst_res(TINFO, \"Write %s file\", FILENAME1);\n+\tstream = SAFE_FOPEN(FILENAME1, \"a+\");\n+\tSAFE_FWRITE(buff_file1, 1, strlen(buff_file1), stream);\n \n-\t\tsprintf(tempfile1, \"stream011.%d\", getpid());\n-\t\tsprintf(tempfile2, \"stream012.%d\", getpid());\n-\t/*--------------------------------------------------------------------*/\n-\t\t//block0:\n-\t\tif ((stream = fopen(tempfile1, \"a+\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) a+ failed: %s\",\n-\t\t\t\t tempfile1,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\tfwrite(\"a\", 1, 1, stream);\n-\t\tif ((stream = freopen(tempfile2, \"a+\", stream)) == NULL) {\n-\t\t\ttst_brkm(TFAIL | TERRNO, NULL, \"freopen(%s) a+ failed\",\n-\t\t\t\t tempfile2);\n-\t\t}\n-\t\tfwrite(\"a\", 1, 1, stream);\n-\t\tfclose(stream);\n+\ttst_res(TINFO, \"Write %s file streaming into %s file\", FILENAME2, FILENAME1);\n+\tstream = SAFE_FREOPEN(FILENAME2, \"a+\", stream);\n+\tSAFE_FWRITE(buff_file2, 1, strlen(buff_file2), stream);\n \n-\t\t/* now check that a single \"a\" is in each file */\n-\t\tif ((stream = fopen(tempfile1, \"r\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL | TERRNO, NULL, \"fopen(%s) r failed\",\n-\t\t\t\t tempfile1);\n-\t\t} else {\n-\t\t\tfor (i = 0; i < 10; i++)\n-\t\t\t\tbuf[i] = 0;\n-\t\t\tfread(buf, 1, 1, stream);\n-\t\t\tif ((buf[0] != 'a') || (buf[1] != 0)) {\n-\t\t\t\ttst_resm(TFAIL, \"bad contents in %s\",\n-\t\t\t\t\t tempfile1);\n-\t\t\t\tlocal_flag = FAILED;\n-\t\t\t}\n-\t\t\tfclose(stream);\n-\t\t}\n-\t\tif ((stream = fopen(tempfile2, \"r\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL | TERRNO, NULL, \"fopen(%s) r failed\",\n-\t\t\t\t tempfile2);\n-\t\t} else {\n-\t\t\tfor (i = 0; i < 10; i++)\n-\t\t\t\tbuf[i] = 0;\n-\t\t\tfread(buf, 1, 1, stream);\n-\t\t\tif ((buf[0] != 'a') || (buf[1] != 0)) {\n-\t\t\t\ttst_resm(TFAIL, \"bad contents in %s\",\n-\t\t\t\t\t tempfile2);\n-\t\t\t\tlocal_flag = FAILED;\n-\t\t\t}\n-\t\t\tfclose(stream);\n-\t\t}\n-\t\tif (local_flag == PASSED) {\n-\t\t\ttst_resm(TPASS, \"Test passed.\");\n-\t\t} else {\n-\t\t\ttst_resm(TFAIL, \"Test failed.\");\n-\t\t}\n+\tSAFE_FCLOSE(stream);\n \n-\t\tlocal_flag = PASSED;\n+\tread_file(FILENAME1, buff_file1, 3);\n+\tread_file(FILENAME2, buff_file2, 3);\n \n-\t/*--------------------------------------------------------------------*/\n-\t\tunlink(tempfile1);\n-\t\tunlink(tempfile2);\n-\n-\t}\t\t\t/* end for */\n-\ttst_rmdir();\n-\ttst_exit();\n+\tSAFE_UNLINK(FILENAME1);\n+\tSAFE_UNLINK(FILENAME2);\n }\n+\n+static struct tst_test test = {\n+\t.test_all = run,\n+\t.needs_tmpdir = 1,\n+};\n","prefixes":["v2","2/7"]}