Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2224023/?format=api
{ "id": 2224023, "url": "http://patchwork.ozlabs.org/api/patches/2224023/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260416-stream_refactoring-v2-7-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-7-8321b1ec6f68@suse.com>", "list_archive_url": null, "date": "2026-04-16T14:33:41", "name": "[v2,7/7] fs: rewrite stream05 test using new API", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "1479e44b6ed88cad32b57fb9f77d9d445b96b571", "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-7-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/2224023/comments/", "check": "warning", "checks": "http://patchwork.ozlabs.org/api/patches/2224023/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=vFJp1d4M;\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=j358PWHl;\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=vFJp1d4M;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=j358PWHl;\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)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fxLD91r1Rz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 00:36:09 +1000 (AEST)", "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id E0CCF3E2142\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 16:36:06 +0200 (CEST)", "from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it\n [IPv6:2001:4b78:1:20::6])\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 07FA73E4E54\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 16:33:54 +0200 (CEST)", "from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131])\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-6.smtp.seeweb.it (Postfix) with ESMTPS id 001931400DAF\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 16:33:53 +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 07E4F5BD12;\n Thu, 16 Apr 2026 14:33:38 +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 C8FB4593AA;\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 0DsBL0Hz4GniGQAAD6G6ig\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=1776350018;\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=swCk5K33V9CiDhlSS8z1WXGgJ68obO8ZjycbV83ly9E=;\n b=vFJp1d4Mk3cz2/J0tbunKR7tRwA0MrpR+xxljNqoSmdfTX0z+MxBDo9XQHIcqDB+BcjRW0\n A1gRbX3oQ7GRhQNJzn64xiHv0YZ3GsrO67nS3qm6BTsBlFQOP5GWK8Phxi/EZZk0//KyjP\n FoHJPipGgOrQsMUwfGeHDmJazSLsrkM=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776350018;\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=swCk5K33V9CiDhlSS8z1WXGgJ68obO8ZjycbV83ly9E=;\n b=j358PWHlvZLRnjsrfUBcYnDMqOVDhhWzcWj2DT5Y5Ilvei1YN8raJSXJmZqRtbpwI7mAY2\n acbyXgOOgkUDaVBg==", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n t=1776350018;\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=swCk5K33V9CiDhlSS8z1WXGgJ68obO8ZjycbV83ly9E=;\n b=vFJp1d4Mk3cz2/J0tbunKR7tRwA0MrpR+xxljNqoSmdfTX0z+MxBDo9XQHIcqDB+BcjRW0\n A1gRbX3oQ7GRhQNJzn64xiHv0YZ3GsrO67nS3qm6BTsBlFQOP5GWK8Phxi/EZZk0//KyjP\n FoHJPipGgOrQsMUwfGeHDmJazSLsrkM=", "v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_ed25519; t=1776350018;\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=swCk5K33V9CiDhlSS8z1WXGgJ68obO8ZjycbV83ly9E=;\n b=j358PWHlvZLRnjsrfUBcYnDMqOVDhhWzcWj2DT5Y5Ilvei1YN8raJSXJmZqRtbpwI7mAY2\n acbyXgOOgkUDaVBg==" ], "From": "Andrea Cervesato <andrea.cervesato@suse.de>", "Date": "Thu, 16 Apr 2026 16:33:41 +0200", "MIME-Version": "1.0", "Message-Id": "<20260416-stream_refactoring-v2-7-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=8972;\n i=andrea.cervesato@suse.com; s=20251210; h=from:subject:message-id;\n bh=XtGV4wrJiWsdcy7LG+F1NvUOzmp7mPgp2HoQ5N1jK/E=;\n b=UsTyd2UC10BNEbjnjZ5HEjDxClPXbMgizjmRQkCHRtmO+L1J8pThVMZwGNTdCW5MEwQ7HSIHl\n oysitgKw1KNCINsWb9uljIDN92CO1QoKRowPJMC0CXq2Ks9RZI7YqJ1", "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)[]; FUZZY_RATELIMITED(0.00)[rspamd.com];\n RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[];\n MIME_TRACE(0.00)[0:+];\n DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email,suse.com:mid,suse.com:email];\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)[imap1.dmz-prg2.suse.org:helo, suse.com:mid,\n suse.com:email, suse.cz:email]", "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-6.smtp.seeweb.it", "X-Virus-Scanned": "clamav-milter 1.0.9 at in-6.smtp.seeweb.it", "X-Virus-Status": "Clean", "Subject": "[LTP] [PATCH v2 7/7] fs: rewrite stream05 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. Replace the old stream05 with a new test\nthat verifies read/write on a file descriptor obtained via fileno()\nand that fclose() fails with EBADF after the fd is closed directly.\n\nReviewed-by: Cyril Hrubis <chrubis@suse.cz>\nSigned-off-by: Andrea Cervesato <andrea.cervesato@suse.com>\n---\n testcases/kernel/fs/stream/stream05.c | 258 +++++++---------------------------\n 1 file changed, 47 insertions(+), 211 deletions(-)", "diff": "diff --git a/testcases/kernel/fs/stream/stream05.c b/testcases/kernel/fs/stream/stream05.c\nindex f561744c3da86cc5d80b97c9707f5583059d21f0..04cb237a145246f607f874c97bc1758724b325a2 100644\n--- a/testcases/kernel/fs/stream/stream05.c\n+++ b/testcases/kernel/fs/stream/stream05.c\n@@ -1,230 +1,66 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n /*\n+ * Copyright (c) International Business Machines Corp., 2002\n+ *\tported from SPIE section2/filesuite/stream.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/stream.c, by Airong Zhang */\n-\n-/*======================================================================\n-\t=================== TESTPLAN SEGMENT ===================\n->KEYS: < ferror() feof() clearerr() fileno()\n->WHAT: < 1) check that ferror returns zero\n-\t< 2) check fileno returns valid file descriptor\n-\t< 3) check that feof returns zero (nonzero) appropriately\n-\t< 4) check that clearerr resets EOF indicator.\n->HOW: < 1) open a stream and immediately execute ferror\n-\t< 2) use the file des returned from fileno to read a file\n-\t< written with stream - compare actual vs expected.\n-\t< 3) open stream and ensure feof returns zero, read to end of\n-\t< file and ensure feof returns non-zero.\n-\t< 4) after 3) above use clearerr and then use feof to ensure\n-\t< clearerr worked\n->BUGS: <\n-======================================================================*/\n-\n-#include <unistd.h>\n-#include <stdio.h>\n-#include <errno.h>\n-#include \"test.h\"\n+/*\\\n+ * Verify that it's possible to read/write on a file descriptor returned by\n+ * `fileno()` and to close it, leaving `fclose()` to raise EBADF error.\n+ */\n \n-char *TCID = \"stream05\";\n-int TST_TOTAL = 1;\n-int local_flag;\n+#include \"tst_test.h\"\n+#include \"tst_safe_stdio.h\"\n+#include \"tst_rand_data.h\"\n \n-#define PASSED 1\n-#define FAILED 0\n+#define FILENAME \"ltp_file\"\n+#define DATASIZE 3\n+#define BUFFSIZE (2 * DATASIZE)\n \n-char progname[] = \"stream05()\";\n-char tempfile[40] = \"\";\n+static char *data;\n+static char *buff;\n \n-/*--------------------------------------------------------------------*/\n-int main(int ac, char *av[])\n+static void run(void)\n {\n+\tint fd;\n \tFILE *stream;\n-\tchar buf[10];\n-\tint nr, fd;\n-\n-\tint lc;\n-\n-\t/*\n-\t * parse standard options\n-\t */\n-\ttst_parse_opts(ac, av, NULL, NULL);\n-\ttst_tmpdir();\n-\tlocal_flag = PASSED;\n-\n-\tfor (lc = 0; TEST_LOOPING(lc); lc++) {\n-\t\tlocal_flag = PASSED;\n-\n-\t\tsprintf(tempfile, \"stream05.%d\", getpid());\n-\t/*--------------------------------------------------------------------*/\n-\t\t//block0:\n-\t\tif ((stream = fopen(tempfile, \"a+\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) a+ failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\tfprintf(stream, \"a\");\n-\t\tfclose(stream);\n-\n-\t\tif ((stream = fopen(tempfile, \"r+\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) r+ failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\n-\t\t/* check that ferror returns zero */\n-\t\tif (ferror(stream) != 0) {\n-\t\t\ttst_resm(TFAIL, \"ferror did not return zero: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\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 \n-\t\tlocal_flag = PASSED;\n+\tmemset(buff, 0, BUFFSIZE);\n \n-\t/*--------------------------------------------------------------------*/\n-\t\t//block1:\n+\tstream = SAFE_FOPEN(FILENAME, \"a+\");\n+\tSAFE_FWRITE(data, 1, DATASIZE, stream);\n+\tSAFE_FFLUSH(stream);\n \n-\t\t/* check that fileno returns valid file descriptor */\n-\t\tfd = fileno(stream);\n-\t\tif ((nr = read(fd, buf, 1)) < 0) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"read failed: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\tif (nr != 1) {\n-\t\t\ttst_resm(TFAIL, \"read did not read right number\");\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\t\tif (buf[0] != 'a') {\n-\t\t\ttst_resm(TFAIL, \"read returned bad values\");\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\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+\tfd = SAFE_FILENO(stream);\n+\tSAFE_WRITE(SAFE_WRITE_ALL, fd, data, DATASIZE);\n \n-\t\tlocal_flag = PASSED;\n-\t/*--------------------------------------------------------------------*/\n-\t\t//block2:\n+\tSAFE_FSYNC(fd);\n+\tSAFE_FSEEK(stream, 0, SEEK_SET);\n+\tSAFE_READ(1, fd, buff, BUFFSIZE);\n \n-\t\t/* read to EOF and ensure feof returns non-zero */\n-\t\tfclose(stream);\n+\tTST_EXP_EQ_STRN(data, buff, DATASIZE);\n+\tTST_EXP_EQ_STRN(data, buff + 3, DATASIZE);\n \n-\t\tif ((stream = fopen(tempfile, \"r+\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) r+ failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\tif (feof(stream) != 0) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"feof returned non-zero when it should not: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\t\tfread(buf, 1, 2, stream);\t/* read to EOF */\n-\t\tif (feof(stream) == 0) {\n-\t\t\ttst_resm(TFAIL,\n-\t\t\t\t \"feof returned zero when it should not: %s\",\n-\t\t\t\t strerror(errno));\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n+\tSAFE_CLOSE(fd);\n+\tTST_EXP_FAIL(fclose(stream), EBADF);\n \n-\t\tif (local_flag == PASSED) {\n-\t\t\ttst_resm(TPASS, \"Test passed in block2.\");\n-\t\t} else {\n-\t\t\ttst_resm(TFAIL, \"Test failed in block2.\");\n-\t\t}\n-\n-\t\tlocal_flag = PASSED;\n-\t/*--------------------------------------------------------------------*/\n-\t\t//block3:\n-\t\t/* ensure clearerr works */\n-\t\tclearerr(stream);\n-\t\tif (feof(stream) != 0) {\n-\t\t\ttst_resm(TFAIL, \"clearerr failed: %s\", strerror(errno));\n-\t\t\tlocal_flag = FAILED;\n-\t\t}\n-\t\tif (local_flag == PASSED) {\n-\t\t\ttst_resm(TPASS, \"Test passed in block3.\");\n-\t\t} else {\n-\t\t\ttst_resm(TFAIL, \"Test failed in block3.\");\n-\t\t}\n-\n-\t\tlocal_flag = PASSED;\n-\t/*--------------------------------------------------------------------*/\n-\t\t//block4:\n-\n-\t\t/* test fopen \"b\" flags -- should be allowed but ignored */\n-\t\t(void)fclose(stream);\n-\n-\t\tif ((stream = fopen(tempfile, \"rb\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) rb failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\t(void)fclose(stream);\n-\n-\t\tif ((stream = fopen(tempfile, \"wb\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) wb failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\t(void)fclose(stream);\n-\n-\t\tif ((stream = fopen(tempfile, \"ab\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) ab failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\t(void)fclose(stream);\n-\n-\t\tif ((stream = fopen(tempfile, \"rb+\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) rb+ failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\t(void)fclose(stream);\n-\n-\t\tif ((stream = fopen(tempfile, \"wb+\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) wb+ failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\t(void)fclose(stream);\n-\n-\t\tif ((stream = fopen(tempfile, \"ab+\")) == NULL) {\n-\t\t\ttst_brkm(TFAIL, NULL, \"fopen(%s) ab+ failed: %s\",\n-\t\t\t\t tempfile,\n-\t\t\t\t strerror(errno));\n-\t\t}\n-\t\t(void)fclose(stream);\n+\tSAFE_UNLINK(FILENAME);\n+}\n \n-\t\ttst_resm(TPASS, \"Test passed in block4.\");\n-\t/*--------------------------------------------------------------------*/\n-\t\tunlink(tempfile);\n-\t}\t\t\t/* end for */\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", "7/7" ] }