{"id":2229258,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229258/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-mtd/patch/20260427223711.401029-1-bage@debian.org/","project":{"id":3,"url":"http://patchwork.ozlabs.org/api/1.1/projects/3/?format=json","name":"Linux MTD development","link_name":"linux-mtd","list_id":"linux-mtd.lists.infradead.org","list_email":"linux-mtd@lists.infradead.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260427223711.401029-1-bage@debian.org>","date":"2026-04-27T22:37:08","name":"unittests: fix syscall mocks on 32-bit with time64 glibc","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"195c7dc7965d33db77e44cd334c4bab7b2b71250","submitter":{"id":84118,"url":"http://patchwork.ozlabs.org/api/1.1/people/84118/?format=json","name":"Bastian Germann","email":"bage@debian.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-mtd/patch/20260427223711.401029-1-bage@debian.org/mbox/","series":[{"id":501739,"url":"http://patchwork.ozlabs.org/api/1.1/series/501739/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-mtd/list/?series=501739","date":"2026-04-27T22:37:08","name":"unittests: fix syscall mocks on 32-bit with time64 glibc","version":1,"mbox":"http://patchwork.ozlabs.org/series/501739/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229258/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229258/checks/","tags":{},"headers":{"Return-Path":"\n <linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=hMjD4SlU;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n secure) header.d=debian.org header.i=@debian.org header.a=rsa-sha256\n header.s=smtpauto.stravinsky header.b=jDhPI+1E;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\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 4g4JNY6fKCz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 08:37:33 +1000 (AEST)","from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wHUZq-00000000Gb2-3rav;\n\tMon, 27 Apr 2026 22:37:18 +0000","from stravinsky.debian.org ([2001:41b8:202:deb::311:108])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wHUZo-00000000Gag-1qcn\n\tfor linux-mtd@lists.infradead.org;\n\tMon, 27 Apr 2026 22:37:17 +0000","from authenticated user\n\tby stravinsky.debian.org with esmtpsa\n (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)\n\t(Exim 4.96)\n\t(envelope-from <bage@debian.org>)\n\tid 1wHUZl-005oWQ-2S;\n\tMon, 27 Apr 2026 22:37:13 +0000"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc\n\t:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:\n\tList-Owner; bh=gQrFSEFkJ9S9YIw3BNiKAXh60aC2lwCWzzKNDU7P8r0=; b=hMjD4SlUcbz7XC\n\tvo9Y9cmgDxgv59flRS3zQQEBJtyKRF22EZUQcUGKuWZPlyqI7m0jf8t1tewFv92v3tC78I67TaJ8U\n\tjJZ3YYTHoLMDgx1Ue/Ss68vEE0IH2s8aO/qfoSTgPJpuF3H4RXbkdck+Abwg/nQQgM2VGS/sY2t01\n\tUQine2ea3EVoZuyICPT/NkEoS0tUVJC9pMwxAfLVPmIpqbk52kVQ1G7kjrKGaGXAfVvx42XJBlnWj\n\t3HUpZcB993PczeJrpi+yrn2iEifTivnUXsItSgS4U+0bZF5TSPm/qnvnErSPvIg0GY09/UCTz/3aR\n\t6gLF77bIVeNOZJRx9Mpg==;","v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org;\n\ts=smtpauto.stravinsky; h=X-Debian-User:Content-Transfer-Encoding:MIME-Version\n\t:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type:Content-ID:\n\tContent-Description:In-Reply-To:References;\n\tbh=G4TJebyN9kRXgObo2vm1WQGlsSKgjr/qAQc6quo3X3Q=; b=jDhPI+1EvImAcBBu2x8E9GV5HM\n\t6cpqqNAFzVt9qlqOg4IYWj5oH7ydOp5pz5DVCaHR+v+Tb9RdB0hVcYJZg17lo0hHwxEFscYCszkw/\n\tt98M/+KN+llDgbcmNNN+HJ946wCIKlCSAX9TRTwUVVeypyYralvC4vCNakKqVB90OSvzIl/uxXv9i\n\tNJQtN+LdI9Dx5aGYF/kXbMhf5ONJLO5BGgyAs71TCB5yrjIWscS0U2BWlptS1byr1lQKRZR/Ikgit\n\t/04XaCnOpqzAGIrsFBiESo7nuZXkiVebjEXJoQTIFALpHds8eXo7b4xUOXUwqvuTZQbbUIVPX4QJv\n\tLHfwR2Iw==;"],"From":"Bastian Germann <bage@debian.org>","To":"linux-mtd@lists.infradead.org","Cc":"Bastian Germann <bage@debian.org>","Subject":"[PATCH] unittests: fix syscall mocks on 32-bit with time64 glibc","Date":"Tue, 28 Apr 2026 00:37:08 +0200","Message-ID":"<20260427223711.401029-1-bage@debian.org>","X-Mailer":"git-send-email 2.53.0","MIME-Version":"1.0","X-Debian-User":"bage","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20260427_153716_488016_6E938F8D ","X-CRM114-Status":"UNSURE (   9.12  )","X-CRM114-Notice":"Please train this message.","X-Spam-Score":"-4.4 (----)","X-Spam-Report":"Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam.  The original\n message has been attached to this so you can view it or label\n similar future email.  If you have any questions, see\n the administrator of that system for details.\n Content preview:  On 32-bit systems (e.g. armhf),\n building with -D_FORTIFY_SOURCE=2,\n    -D_FILE_OFFSET_BITS=64, and -D_TIME_BITS=64 CFLAGS fails many tests. These\n    flags activate glibc symbol redirects that bypass the --wr [...]\n Content analysis details:   (-4.4 points, 5.0 required)\n  pts rule name              description\n ---- ----------------------\n --------------------------------------------------\n -2.3 RCVD_IN_DNSWL_MED      RBL: Sender listed at https://www.dnswl.org/,\n                             medium trust\n                             [2001:41b8:202:deb:0:0:311:108 listed in]\n                             [list.dnswl.org]\n  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record\n  0.0 SPF_NONE               SPF: sender does not publish an SPF Record\n -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from\n                             envelope-from domain\n -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from\n author's\n                             domain\n -0.1 DKIM_VALID             Message has at least one valid DKIM or DK\n signature\n  0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n not necessarily valid\n -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n  0.0 UNPARSEABLE_RELAY      Informational: message has unparseable relay\n lines\n -0.0 DKIMWL_WL_HIGH         DKIMwl.org - High trust sender","X-BeenThere":"linux-mtd@lists.infradead.org","X-Mailman-Version":"2.1.34","Precedence":"list","List-Id":"Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-mtd/>","List-Post":"<mailto:linux-mtd@lists.infradead.org>","List-Help":"<mailto:linux-mtd-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n <mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>","Errors-To":"linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"},"content":"On 32-bit systems (e.g. armhf), building with -D_FORTIFY_SOURCE=2,\n-D_FILE_OFFSET_BITS=64, and -D_TIME_BITS=64 CFLAGS fails many tests.\nThese flags activate glibc symbol redirects that bypass the --wrap\nlinker interpositions used by the cmocka mocks:\n\n  - _FORTIFY_SOURCE=2 + _FILE_OFFSET_BITS=64: open(path, flags) -> open64()\n  - _FILE_OFFSET_BITS=64: lseek() -> lseek64()\n  - _TIME_BITS=64 (glibc >= 2.34): ioctl() -> __ioctl_time64()\n\nAdd --wrap entries for each redirected symbol and provide thin forwarders\nthat delegate to the primary __wrap_open / __wrap_lseek / __wrap_ioctl\nfunctions via plain function calls. This ensures that __func__ inside\nthose functions resolves correctly for cmocka's expectation lookup.\n\nSigned-off-by: Bastian Germann <bage@debian.org>\n---\n tests/unittests/Makemodule.am |  4 ++--\n tests/unittests/test_lib.h    | 19 +++++++++++++++++++\n 2 files changed, 21 insertions(+), 2 deletions(-)","diff":"diff --git a/tests/unittests/Makemodule.am b/tests/unittests/Makemodule.am\nindex 277cac2..7b2ba4d 100644\n--- a/tests/unittests/Makemodule.am\n+++ b/tests/unittests/Makemodule.am\n@@ -1,13 +1,13 @@\n ubilib_test_SOURCES = tests/unittests/libubi_test.c lib/libubi.c\n ubilib_test_SOURCES += tests/unittests/test_lib.h\n ubilib_test_LDADD = $(CMOCKA_LIBS)\n-ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek\n+ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=open64 -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=__ioctl_time64 -Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=lseek64\n ubilib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I$(top_srcdir)/include -DSYSFS_ROOT='\"$(top_srcdir)/tests/unittests/sysfs_mock\"'\n \n mtdlib_test_SOURCES = tests/unittests/libmtd_test.c lib/libmtd.c lib/libmtd_legacy.c\n mtdlib_test_SOURCES += tests/unittests/test_lib.h\n mtdlib_test_LDADD = $(CMOCKA_LIBS)\n-mtdlib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=write\n+mtdlib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=open64 -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=__ioctl_time64 -Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=lseek64 -Wl,--wrap=write\n mtdlib_test_CPPFLAGS = -O0 -D_GNU_SOURCE --std=gnu99 $(CMOCKA_CFLAGS) -I$(top_srcdir)/lib/ -I$(top_srcdir)/include -DSYSFS_ROOT='\"$(top_srcdir)/tests/unittests/sysfs_mock\"'\n \n TEST_BINS = \\\ndiff --git a/tests/unittests/test_lib.h b/tests/unittests/test_lib.h\nindex cd94d9f..7a5b98b 100644\n--- a/tests/unittests/test_lib.h\n+++ b/tests/unittests/test_lib.h\n@@ -89,6 +89,25 @@ off_t __wrap_lseek(int fd, off_t seek, int whence)\n \treturn mock_type(off_t);\n }\n \n+int __wrap_open64(const char *path, int flags)\n+{\n+        return __wrap_open(path, flags);\n+}\n+\n+off_t __wrap_lseek64(int fd, off_t offset, int whence)\n+{\n+        return __wrap_lseek(fd, offset, whence);\n+}\n+\n+int __wrap___ioctl_time64(int fd, unsigned long req, ...)\n+{\n+        va_list ap;\n+        va_start(ap, req);\n+        void *arg = va_arg(ap, void *);\n+        va_end(ap);\n+        return __wrap_ioctl(fd, req, arg);\n+}\n+\n #define expect_open(X,Y,Z) do { \\\n \t\texpect_string(__wrap_open, path, X);\\\n \t\twill_return(__wrap_open, Y);\\\n","prefixes":[]}