Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2224020/?format=api
{ "id": 2224020, "url": "http://patchwork.ozlabs.org/api/patches/2224020/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260416-stream_refactoring-v2-5-8321b1ec6f68@suse.com/", "project": { "id": 59, "url": "http://patchwork.ozlabs.org/api/projects/59/?format=api", "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-5-8321b1ec6f68@suse.com>", "list_archive_url": null, "date": "2026-04-16T14:33:39", "name": "[v2,5/7] fs: rewrite stream03 test using new API", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e93e432a374de15e65d40ee31df587b07f58d811", "submitter": { "id": 83220, "url": "http://patchwork.ozlabs.org/api/people/83220/?format=api", "name": "Andrea Cervesato", "email": "andrea.cervesato@suse.de" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/ltp/patch/20260416-stream_refactoring-v2-5-8321b1ec6f68@suse.com/mbox/", "series": [ { "id": 500172, "url": "http://patchwork.ozlabs.org/api/series/500172/?format=api", "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/2224020/comments/", "check": "warning", "checks": "http://patchwork.ozlabs.org/api/patches/2224020/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=bkNbbZFF;\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=nceRuAZr;\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=bkNbbZFF;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=nceRuAZr;\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-out1.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)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fxLC15n0Hz1yHP\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 00:35:09 +1000 (AEST)", "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id CA45E3E4ADB\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 16:35:07 +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 E24E73E4AD7\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 16:33:50 +0200 (CEST)", "from smtp-out1.suse.de (smtp-out1.suse.de\n [IPv6:2a07:de40:b251:101:10:150:64:1])\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 451131000443\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 16:33:49 +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-out1.suse.de (Postfix) with ESMTPS id D66456A7FF;\n Thu, 16 Apr 2026 14:33:37 +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 5F075593A8;\n Thu, 16 Apr 2026 14:33:37 +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 CHsNFUHz4GniGQAAD6G6ig\n (envelope-from <andrea.cervesato@suse.de>); Thu, 16 Apr 2026 14:33:37 +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=l9MEZ4K+GH73JI7vnpsqR4hgCtuTK0jCgsVty3RUTgQ=;\n b=bkNbbZFFaja7aaLIolis1PfbOxTflLdf/gvTfZAShVtxWDClqvmd7xhoqdUlPbX18mdjmy\n 5tmMokXWN/MnBVyFxL0X96esCQohLBl39asmwHbANlFdJsBuzcS3A50S86nK5FGl7VJ3Zk\n i4edNXRkbz7Qh8c5DytehUCMMRY7vT4=", "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=l9MEZ4K+GH73JI7vnpsqR4hgCtuTK0jCgsVty3RUTgQ=;\n b=nceRuAZra2Puu+SRegsK69+7Vt7+Hkez9SBGP0iYSv1a2mYO+TI9vGszcYSgXyYU4JHyI/\n z6L3fCpfnCIQu2BQ==", "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=l9MEZ4K+GH73JI7vnpsqR4hgCtuTK0jCgsVty3RUTgQ=;\n b=bkNbbZFFaja7aaLIolis1PfbOxTflLdf/gvTfZAShVtxWDClqvmd7xhoqdUlPbX18mdjmy\n 5tmMokXWN/MnBVyFxL0X96esCQohLBl39asmwHbANlFdJsBuzcS3A50S86nK5FGl7VJ3Zk\n i4edNXRkbz7Qh8c5DytehUCMMRY7vT4=", "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=l9MEZ4K+GH73JI7vnpsqR4hgCtuTK0jCgsVty3RUTgQ=;\n b=nceRuAZra2Puu+SRegsK69+7Vt7+Hkez9SBGP0iYSv1a2mYO+TI9vGszcYSgXyYU4JHyI/\n z6L3fCpfnCIQu2BQ==" ], "From": "Andrea Cervesato <andrea.cervesato@suse.de>", "Date": "Thu, 16 Apr 2026 16:33:39 +0200", "MIME-Version": "1.0", "Message-Id": "<20260416-stream_refactoring-v2-5-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=9978;\n i=andrea.cervesato@suse.com; s=20251210; h=from:subject:message-id;\n bh=XHcmbD0zRAYCrzDSPfE/P4Y6sqDmUgcl91MHx8xO9Rg=;\n b=J2Aw3RMvmQEXg2wjGGCpspTYkkjllOZ8DQoHYYauC4VLThbxpNNoVSIg/dQRj3gtPbTPQMLKN\n cjNQozCMfipDoRAp1MxZxynkF8m2sP36hhXILShEfMbo7PRVlCybIUf", "X-Developer-Key": "i=andrea.cervesato@suse.com; a=ed25519;\n pk=zKY+6GCauOiuHNZ//d8PQ/UL4jFCTKbXrzXAOQSLevI=", "X-Spam-Score": "-4.30", "X-Spam-Level": "", "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_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[];\n MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com];\n RCVD_TLS_ALL(0.00)[];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[];\n RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[];\n TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2];\n DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email, suse.com:mid, suse.com:email,\n imap1.dmz-prg2.suse.org:helo]", "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 5/7] fs: rewrite stream03 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 stream03 to new tst_test.h-based\nAPI, verifying that ftell() reports correct byte offsets after\nrewind, fseek and fgets operations.\n\nReviewed-by: Cyril Hrubis <chrubis@suse.cz>\nSigned-off-by: Andrea Cervesato <andrea.cervesato@suse.com>\n---\n testcases/kernel/fs/stream/stream03.c | 326 ++++++----------------------------\n 1 file changed, 50 insertions(+), 276 deletions(-)", "diff": "diff --git a/testcases/kernel/fs/stream/stream03.c b/testcases/kernel/fs/stream/stream03.c\nindex 31715f740a070d01aec1087981e092b361e656da..24928c5e1a15cc4a5b17b22bcfb907519ed9b4e4 100644\n--- a/testcases/kernel/fs/stream/stream03.c\n+++ b/testcases/kernel/fs/stream/stream03.c\n@@ -1,297 +1,71 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n /*\n+ * Copyright (c) International Business Machines Corp., 2002\n+ *\tported from SPIE, section2/filesuite/stream3.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- *\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- *\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+ * Copyright (c) 2026 Andrea Cervesato <andrea.cervesato@suse.com>\n */\n \n-/* ported from SPIE, section2/filesuite/stream3.c, by Airong Zhang */\n-\n-/*======================================================================\n-\t=================== TESTPLAN SEGMENT ===================\n->KEYS: < fseek() ftell()\n->WHAT: < 1) Ensure ftell reports the correct current byte offset.\n->HOW: < 1) Open a file, write to it, reposition the file pointer and\n-\t check it.\n->BUGS: <\n-======================================================================*/\n-#define _XOPEN_SOURCE 500\n-#include <stdio.h>\n-#include <errno.h>\n-#include <fcntl.h>\n-#include <sys/types.h>\n-#include <sys/stat.h>\n-#include <inttypes.h>\n-#include \"test.h\"\n+/*\\\n+ * Verify that `ftell()` reports the correct current byte offset after\n+ * moving it.\n+ */\n \n-char *TCID = \"stream03\";\n-int TST_TOTAL = 1;\n-int local_flag;\n+#include \"tst_test.h\"\n+#include \"tst_rand_data.h\"\n+#include \"tst_safe_stdio.h\"\n \n-#define PASSED 1\n-#define FAILED 0\n+#define FILENAME \"ltp_file\"\n+#define DATASIZE 30\n+#define BUFFSIZE 10\n \n-char progname[] = \"stream03()\";\n-char tempfile1[40] = \"\";\n+static char *data;\n+static char *buff;\n \n-int main(int ac, char *av[])\n+static void run(void)\n {\n \tFILE *stream;\n-\tchar buf[30];\n-\tchar *junk = \"abcdefghijklmnopqrstuvwxyz\";\n-\tlong pos;\n-\toff_t opos;\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-\n-\tfor (lc = 0; TEST_LOOPING(lc); lc++) {\n-\n-\t\tsprintf(tempfile1, \"stream03.%d\", getpid());\n-\t/*--------------------------------------------------------------------*/\n-\t\t//block0:\n-\n-\t\tif ((stream = fopen(tempfile1, \"a+\")) == NULL) {\n-\t\t\ttst_brkm(TBROK, NULL, \"fopen(%s) a+ failed: %s\",\n-\t\t\t\t tempfile1,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\t/* make sure offset of zero at start */\n-\t\tpos = ftell(stream);\n-\n-\t\tif (pos != 0) {\n-\t\t\ttst_resm(TFAIL, \"file pointer descrepancy 1\");\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* write something and check */\n-\t\tif (fwrite(junk, sizeof(*junk), strlen(junk), stream) == 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fwrite failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\tpos = ftell(stream);\n-\n-\t\tif (pos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 2 (pos=%li)\",\n-\t\t\t\t strlen(junk), pos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* rewind and check */\n-\t\trewind(stream);\n-\t\tpos = ftell(stream);\n-\n-\t\tif (pos != 0) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"file pointer descrepancy 3 (pos=%li, wanted pos=0)\",\n-\t\t\t\t pos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* seek from current position and then check */\n-\t\tif (fseek(stream, strlen(junk), 1) != 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fseek failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\tpos = ftell(stream);\n-\n-\t\tif (pos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 4 (pos=%li)\",\n-\t\t\t\t strlen(junk), pos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* seek from end of file and then check */\n-\t\tif (fseek(stream, 0, 2) != 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fseek failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\tpos = ftell(stream);\n-\n-\t\tif (pos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 5 (pos=%li)\",\n-\t\t\t\t strlen(junk), pos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* rewind with seek and then check */\n-\t\tif (fseek(stream, 0, 0) != 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fseek failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n \n-\t\tpos = ftell(stream);\n+\tmemset(buff, 0, BUFFSIZE);\n \n-\t\tif (pos != 0) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"file pointer descrepancy 6 (pos=%li, wanted pos=0)\",\n-\t\t\t\t pos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n+\tstream = SAFE_FOPEN(FILENAME, \"a+\");\n+\tTST_EXP_EQ_LI(SAFE_FTELL(stream), 0);\n \n-\t\t/* read till EOF, do getc and then check ftell */\n-\t\twhile (fgets(buf, sizeof(buf), stream)) ;\n-\t\tpos = ftell(stream);\n-\t\tgetc(stream);\n-\t\tpos = ftell(stream);\n+\tSAFE_FWRITE(data, 1, DATASIZE, stream);\n+\tTST_EXP_EQ_LI(SAFE_FTELL(stream), DATASIZE);\n \n-\t\tif (pos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 7 (pos=%li)\",\n-\t\t\t\t strlen(junk), pos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n+\trewind(stream);\n+\tTST_EXP_EQ_LI(SAFE_FTELL(stream), SEEK_SET);\n \n-\t\tfclose(stream);\n+\tSAFE_FSEEK(stream, 10, SEEK_CUR);\n+\tTST_EXP_EQ_LI(SAFE_FTELL(stream), 10);\n \n-\t\tif (local_flag == PASSED) {\n-\t\t\ttst_resm(TPASS, \"Test passed in block0.\");\n-\t\t} else {\n-\t\t\ttst_resm(TFAIL, \"Test failed in block0.\");\n-\t\t}\n+\tSAFE_FSEEK(stream, 0, SEEK_END);\n+\tTST_EXP_EQ_LI(SAFE_FTELL(stream), DATASIZE);\n \n-\t\tlocal_flag = PASSED;\n+\tSAFE_FSEEK(stream, 0, SEEK_SET);\n+\tTST_EXP_EQ_LI(SAFE_FTELL(stream), 0);\n \n-\t\tunlink(tempfile1);\n-\t/*--------------------------------------------------------------------*/\n-\t\t//block1:\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+\twhile (fgets(buff, BUFFSIZE, stream))\n+\t\t;\n+\tTST_EXP_EQ_LI(SAFE_FTELL(stream), DATASIZE);\n \n-\t\t/* make sure offset of zero at start */\n-\t\topos = ftello(stream);\n-\n-\t\tif (opos != 0) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"file pointer descrepancy 1 (opos=%\" PRId64\n-\t\t\t\t \", wanted opos=0)\", (int64_t) opos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* write something and check */\n-\t\tif (fwrite(junk, sizeof(*junk), strlen(junk), stream) == 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fwrite failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\topos = ftello(stream);\n-\n-\t\tif (opos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 2 (opos=%\"\n-\t\t\t\t PRId64 \")\", strlen(junk), (int64_t) opos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* rewind and check */\n-\t\trewind(stream);\n-\t\topos = ftello(stream);\n-\n-\t\tif (opos != 0) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"file pointer descrepancy 3 (opos=%\" PRId64\n-\t\t\t\t \", wanted opos=0)\", (int64_t) opos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* seek from current position and then check */\n-\t\tif (fseeko(stream, strlen(junk), 1) != 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fseeko failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\topos = ftello(stream);\n-\n-\t\tif (opos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 4 (opos=%\"\n-\t\t\t\t PRId64 \")\", strlen(junk), (int64_t) opos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* seek from end of file and then check */\n-\t\tif (fseeko(stream, 0, 2) != 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fseeko failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\topos = ftello(stream);\n-\n-\t\tif (opos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 5 (opos=%\"\n-\t\t\t\t PRId64 \")\", strlen(junk), (int64_t) opos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* rewind with seek and then check */\n-\t\tif (fseeko(stream, 0, 0) != 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fseeko failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\topos = ftello(stream);\n-\n-\t\tif (opos != 0) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"file pointer descrepancy 6 (opos=%\" PRId64\n-\t\t\t\t \", wanted opos=0)\", (int64_t) opos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\t/* read till EOF, do getc and then check ftello */\n-\t\twhile (fgets(buf, sizeof(buf), stream)) ;\n-\n-\t\topos = ftello(stream);\n-\t\tgetc(stream);\n-\t\topos = ftello(stream);\n-\n-\t\tif (opos != strlen(junk)) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"strlen(junk)=%zi: file pointer descrepancy 7 (opos=%li)\",\n-\t\t\t\t strlen(junk), opos);\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\n-\t\tfclose(stream);\n-\n-\t\tif (local_flag == PASSED) {\n-\t\t\ttst_resm(TPASS, \"Test passed in block1.\");\n-\t\t} else {\n-\t\t\ttst_resm(TFAIL, \"Test failed in block1.\");\n-\t\t}\n-\n-\t\tunlink(tempfile1);\n-\t}\n+\tSAFE_FCLOSE(stream);\n+\tSAFE_UNLINK(FILENAME);\n+}\n \n-\ttst_rmdir();\n-\ttst_exit();\n+static void setup(void)\n+{\n+\tmemcpy(data, tst_rand_data, DATASIZE);\n }\n+\n+static struct tst_test test = {\n+\t.test_all = run,\n+\t.setup = setup,\n+\t.needs_tmpdir = 1,\n+\t.bufs = (struct tst_buffers[]) {\n+\t\t{&data, .size = DATASIZE},\n+\t\t{&buff, .size = BUFFSIZE},\n+\t\t{},\n+\t},\n+};\n", "prefixes": [ "v2", "5/7" ] }