public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-crypt/tpm2-tss/files/, app-crypt/tpm2-tss/
Date: Wed, 28 Sep 2022 00:09:58 +0000 (UTC)	[thread overview]
Message-ID: <1664323607.1b00c3313f3cafb09b94ec635dbadb86547744c5.sam@gentoo> (raw)

commit:     1b00c3313f3cafb09b94ec635dbadb86547744c5
Author:     Christopher Byrne <salah.coronya <AT> gmail <DOT> com>
AuthorDate: Tue Sep 27 23:22:13 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Sep 28 00:06:47 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1b00c331

app-crypt/tpm2-tss: Fix tests under musl

Closes: https://bugs.gentoo.org/833530
Signed-off-by: Christopher Byrne <salah.coronya <AT> gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/27503
Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...st-fix-usage-of-FILE-in-unit-test-fapi-io.patch | 146 +++++++++++++++++++++
 app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild        |   1 +
 2 files changed, 147 insertions(+)

diff --git a/app-crypt/tpm2-tss/files/tpm2-tss-3.2.0-test-fix-usage-of-FILE-in-unit-test-fapi-io.patch b/app-crypt/tpm2-tss/files/tpm2-tss-3.2.0-test-fix-usage-of-FILE-in-unit-test-fapi-io.patch
new file mode 100644
index 000000000000..aff792a28263
--- /dev/null
+++ b/app-crypt/tpm2-tss/files/tpm2-tss-3.2.0-test-fix-usage-of-FILE-in-unit-test-fapi-io.patch
@@ -0,0 +1,146 @@
+https://github.com/tpm2-software/tpm2-tss/commit/bda22252507124bb8e466ac2f0c61d5ebed9027d
+https://github.com/tpm2-software/tpm2-tss/pull/2423
+https://bugs.gentoo.org/833530
+
+From bda22252507124bb8e466ac2f0c61d5ebed9027d Mon Sep 17 00:00:00 2001
+From: William Roberts <william.c.roberts@intel.com>
+Date: Mon, 26 Sep 2022 15:16:15 -0500
+Subject: [PATCH] test: fix usage of FILE in unit test fapi-io
+
+The unit test had a static FILE structure used to pass to stdio FILE *
+routines as a dummy value to indicate to use the __real_xxx variant of
+the mocked function. This doesn't work when FILE is opaque as the
+compiler cannot figure out how much storage space is needed for a FILE
+struct.
+
+Fix this by passing a dummy pointer to a data type the compiler knows
+about and casting it to FILE pointer.
+
+Fixes: #2419
+
+Signed-off-by: William Roberts <william.c.roberts@intel.com>
+---
+ test/unit/fapi-io.c | 30 ++++++++++++++++--------------
+ 1 file changed, 16 insertions(+), 14 deletions(-)
+
+diff --git a/test/unit/fapi-io.c b/test/unit/fapi-io.c
+index dbadcb47..8a883a43 100644
+--- a/test/unit/fapi-io.c
++++ b/test/unit/fapi-io.c
+@@ -38,7 +38,9 @@
+ bool wrap_fcntl_test = false;
+ bool wrap_malloc_test = false;
+ bool wrap_read_test = false;
+-FILE mock_stream; /**< stream will be used to activate wrapper.*/
++char _mock_stream; /**< stream will be used to activate wrapper.*/
++
++#define MOCK_STREAM ((FILE *)(&_mock_stream))
+ 
+ /*
+  * Wrapper functions for file system io.
+@@ -74,7 +76,7 @@ __real_fclose(FILE *stream, ...);
+ int
+ __wrap_fclose(FILE *stream, ...)
+ {
+-    if (stream != &mock_stream) {
++    if (stream != MOCK_STREAM) {
+         return __real_fclose(stream);
+     }
+     return mock_type(int);
+@@ -86,7 +88,7 @@ __real_fseek(FILE *stream, long offset, int whence, ...);
+ int
+ __wrap_fseek(FILE *stream, long offset, int whence, ...)
+ {
+-    if (stream != &mock_stream) {
++    if (stream != MOCK_STREAM) {
+         return __real_fseek(stream, offset, whence);
+     }
+     return mock_type(int);
+@@ -98,7 +100,7 @@ __real_ftell(FILE *stream, ...);
+ long
+ __wrap_ftell(FILE *stream, ...)
+ {
+-    if (stream != &mock_stream) {
++    if (stream != MOCK_STREAM) {
+         return __real_ftell(stream);
+     }
+     return mock_type(int);
+@@ -135,7 +137,7 @@ __real_fileno(FILE *stream, ...);
+ int
+ __wrap_fileno(FILE *stream, ...)
+ {
+-    if (stream != &mock_stream) {
++    if (stream != MOCK_STREAM) {
+         return __real_fileno(stream);
+     }
+     return 1;
+@@ -179,7 +181,7 @@ check_io_read_async(void **state) {
+     assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
+ 
+     wrap_fcntl_test = true;
+-    will_return(__wrap_fopen, &mock_stream);
++    will_return(__wrap_fopen, MOCK_STREAM);
+     will_return(__wrap_fcntl, -1);
+     will_return_always(__wrap_fclose, 0);
+     errno = EAGAIN;
+@@ -187,8 +189,8 @@ check_io_read_async(void **state) {
+     r = ifapi_io_read_async(&io, "tss_unit_dummyf");
+     assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
+ 
+-    will_return(__wrap_fopen, &mock_stream);
+-    will_return(__wrap_fopen, &mock_stream);
++    will_return(__wrap_fopen, MOCK_STREAM);
++    will_return(__wrap_fopen, MOCK_STREAM);
+     will_return(__wrap_fcntl, 0);
+     will_return(__wrap_fseek, 0);
+     will_return(__wrap_ftell, 1);
+@@ -202,8 +204,8 @@ check_io_read_async(void **state) {
+ 
+     wrap_malloc_test = false;
+ 
+-    will_return(__wrap_fopen, &mock_stream);
+-    will_return(__wrap_fopen, &mock_stream);
++    will_return(__wrap_fopen, MOCK_STREAM);
++    will_return(__wrap_fopen, MOCK_STREAM);
+     will_return(__wrap_fcntl, 0);
+     will_return(__wrap_fseek, 0);
+     will_return(__wrap_ftell, 1);
+@@ -236,7 +238,7 @@ check_io_read_finish(void **state) {
+     will_return_always(__wrap_fclose, 0);
+     io.char_buffer = &io_char_buffer[0];
+     io.buffer_length = 10;
+-    io.stream = &mock_stream;
++    io.stream = MOCK_STREAM;
+     errno = EAGAIN;
+     r = ifapi_io_read_finish(&io, &buffer[0], &count);
+     assert_int_equal(r, TSS2_FAPI_RC_TRY_AGAIN);
+@@ -298,7 +300,7 @@ check_io_write_async(void **state) {
+     assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
+ 
+     wrap_fcntl_test = true;
+-    will_return(__wrap_fopen, &mock_stream);
++    will_return(__wrap_fopen, MOCK_STREAM);
+     will_return(__wrap_fcntl, -1);
+ 
+     errno = EAGAIN;
+@@ -306,7 +308,7 @@ check_io_write_async(void **state) {
+     assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
+ 
+     io.char_rbuffer = NULL;
+-    will_return(__wrap_fopen, &mock_stream);
++    will_return(__wrap_fopen, MOCK_STREAM);
+     will_return(__wrap_fcntl, 0);
+     will_return(__wrap_fcntl, 0);
+     will_return(__wrap_fcntl, -1);
+@@ -345,7 +347,7 @@ check_io_write_finish(void **state) {
+     will_return_always(__wrap_fclose, 0);
+ 
+     wrap_write_test = true;
+-    io.stream = &mock_stream;
++    io.stream = MOCK_STREAM;
+     will_return(__wrap_write, -1);
+     errno = EAGAIN;
+     r = ifapi_io_write_finish(&io);
+-- 
+2.35.1
+

diff --git a/app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild b/app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild
index 78d18901ba6d..1e76e7ee9d5f 100644
--- a/app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild
+++ b/app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild
@@ -38,6 +38,7 @@ BDEPEND="sys-apps/acl
 PATCHES=(
 	"${FILESDIR}/${PN}-3.2.0-Dont-run-systemd-sysusers-in-Makefile.patch"
 	"${FILESDIR}/${PN}-3.2.0-slibtool.patch" # 858674
+	"${FILESDIR}/${PN}-3.2.0-test-fix-usage-of-FILE-in-unit-test-fapi-io.patch"
 )
 
 pkg_setup() {


             reply	other threads:[~2022-09-28  0:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28  0:09 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-05-09 22:00 [gentoo-commits] repo/gentoo:master commit in: app-crypt/tpm2-tss/files/, app-crypt/tpm2-tss/ Sam James
2024-05-05 11:36 Sam James
2023-06-25 22:30 David Seifert
2023-01-20  7:26 Viorel Munteanu
2022-12-21 23:37 Sam James
2022-07-16  7:16 Joonas Niilola
2021-06-10  8:13 Joonas Niilola
2020-09-06  5:55 Joonas Niilola
2020-06-17 17:00 Joonas Niilola

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1664323607.1b00c3313f3cafb09b94ec635dbadb86547744c5.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox