Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-crypt/tpm2-tss/files/, app-crypt/tpm2-tss/
Date: Wed, 28 Sep 2022 00:10:02
Message-Id: 1664323607.1b00c3313f3cafb09b94ec635dbadb86547744c5.sam@gentoo
1 commit: 1b00c3313f3cafb09b94ec635dbadb86547744c5
2 Author: Christopher Byrne <salah.coronya <AT> gmail <DOT> com>
3 AuthorDate: Tue Sep 27 23:22:13 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 28 00:06:47 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1b00c331
7
8 app-crypt/tpm2-tss: Fix tests under musl
9
10 Closes: https://bugs.gentoo.org/833530
11 Signed-off-by: Christopher Byrne <salah.coronya <AT> gmail.com>
12 Closes: https://github.com/gentoo/gentoo/pull/27503
13 Signed-off-by: Sam James <sam <AT> gentoo.org>
14
15 ...st-fix-usage-of-FILE-in-unit-test-fapi-io.patch | 146 +++++++++++++++++++++
16 app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild | 1 +
17 2 files changed, 147 insertions(+)
18
19 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
20 new file mode 100644
21 index 000000000000..aff792a28263
22 --- /dev/null
23 +++ b/app-crypt/tpm2-tss/files/tpm2-tss-3.2.0-test-fix-usage-of-FILE-in-unit-test-fapi-io.patch
24 @@ -0,0 +1,146 @@
25 +https://github.com/tpm2-software/tpm2-tss/commit/bda22252507124bb8e466ac2f0c61d5ebed9027d
26 +https://github.com/tpm2-software/tpm2-tss/pull/2423
27 +https://bugs.gentoo.org/833530
28 +
29 +From bda22252507124bb8e466ac2f0c61d5ebed9027d Mon Sep 17 00:00:00 2001
30 +From: William Roberts <william.c.roberts@×××××.com>
31 +Date: Mon, 26 Sep 2022 15:16:15 -0500
32 +Subject: [PATCH] test: fix usage of FILE in unit test fapi-io
33 +
34 +The unit test had a static FILE structure used to pass to stdio FILE *
35 +routines as a dummy value to indicate to use the __real_xxx variant of
36 +the mocked function. This doesn't work when FILE is opaque as the
37 +compiler cannot figure out how much storage space is needed for a FILE
38 +struct.
39 +
40 +Fix this by passing a dummy pointer to a data type the compiler knows
41 +about and casting it to FILE pointer.
42 +
43 +Fixes: #2419
44 +
45 +Signed-off-by: William Roberts <william.c.roberts@×××××.com>
46 +---
47 + test/unit/fapi-io.c | 30 ++++++++++++++++--------------
48 + 1 file changed, 16 insertions(+), 14 deletions(-)
49 +
50 +diff --git a/test/unit/fapi-io.c b/test/unit/fapi-io.c
51 +index dbadcb47..8a883a43 100644
52 +--- a/test/unit/fapi-io.c
53 ++++ b/test/unit/fapi-io.c
54 +@@ -38,7 +38,9 @@
55 + bool wrap_fcntl_test = false;
56 + bool wrap_malloc_test = false;
57 + bool wrap_read_test = false;
58 +-FILE mock_stream; /**< stream will be used to activate wrapper.*/
59 ++char _mock_stream; /**< stream will be used to activate wrapper.*/
60 ++
61 ++#define MOCK_STREAM ((FILE *)(&_mock_stream))
62 +
63 + /*
64 + * Wrapper functions for file system io.
65 +@@ -74,7 +76,7 @@ __real_fclose(FILE *stream, ...);
66 + int
67 + __wrap_fclose(FILE *stream, ...)
68 + {
69 +- if (stream != &mock_stream) {
70 ++ if (stream != MOCK_STREAM) {
71 + return __real_fclose(stream);
72 + }
73 + return mock_type(int);
74 +@@ -86,7 +88,7 @@ __real_fseek(FILE *stream, long offset, int whence, ...);
75 + int
76 + __wrap_fseek(FILE *stream, long offset, int whence, ...)
77 + {
78 +- if (stream != &mock_stream) {
79 ++ if (stream != MOCK_STREAM) {
80 + return __real_fseek(stream, offset, whence);
81 + }
82 + return mock_type(int);
83 +@@ -98,7 +100,7 @@ __real_ftell(FILE *stream, ...);
84 + long
85 + __wrap_ftell(FILE *stream, ...)
86 + {
87 +- if (stream != &mock_stream) {
88 ++ if (stream != MOCK_STREAM) {
89 + return __real_ftell(stream);
90 + }
91 + return mock_type(int);
92 +@@ -135,7 +137,7 @@ __real_fileno(FILE *stream, ...);
93 + int
94 + __wrap_fileno(FILE *stream, ...)
95 + {
96 +- if (stream != &mock_stream) {
97 ++ if (stream != MOCK_STREAM) {
98 + return __real_fileno(stream);
99 + }
100 + return 1;
101 +@@ -179,7 +181,7 @@ check_io_read_async(void **state) {
102 + assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
103 +
104 + wrap_fcntl_test = true;
105 +- will_return(__wrap_fopen, &mock_stream);
106 ++ will_return(__wrap_fopen, MOCK_STREAM);
107 + will_return(__wrap_fcntl, -1);
108 + will_return_always(__wrap_fclose, 0);
109 + errno = EAGAIN;
110 +@@ -187,8 +189,8 @@ check_io_read_async(void **state) {
111 + r = ifapi_io_read_async(&io, "tss_unit_dummyf");
112 + assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
113 +
114 +- will_return(__wrap_fopen, &mock_stream);
115 +- will_return(__wrap_fopen, &mock_stream);
116 ++ will_return(__wrap_fopen, MOCK_STREAM);
117 ++ will_return(__wrap_fopen, MOCK_STREAM);
118 + will_return(__wrap_fcntl, 0);
119 + will_return(__wrap_fseek, 0);
120 + will_return(__wrap_ftell, 1);
121 +@@ -202,8 +204,8 @@ check_io_read_async(void **state) {
122 +
123 + wrap_malloc_test = false;
124 +
125 +- will_return(__wrap_fopen, &mock_stream);
126 +- will_return(__wrap_fopen, &mock_stream);
127 ++ will_return(__wrap_fopen, MOCK_STREAM);
128 ++ will_return(__wrap_fopen, MOCK_STREAM);
129 + will_return(__wrap_fcntl, 0);
130 + will_return(__wrap_fseek, 0);
131 + will_return(__wrap_ftell, 1);
132 +@@ -236,7 +238,7 @@ check_io_read_finish(void **state) {
133 + will_return_always(__wrap_fclose, 0);
134 + io.char_buffer = &io_char_buffer[0];
135 + io.buffer_length = 10;
136 +- io.stream = &mock_stream;
137 ++ io.stream = MOCK_STREAM;
138 + errno = EAGAIN;
139 + r = ifapi_io_read_finish(&io, &buffer[0], &count);
140 + assert_int_equal(r, TSS2_FAPI_RC_TRY_AGAIN);
141 +@@ -298,7 +300,7 @@ check_io_write_async(void **state) {
142 + assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
143 +
144 + wrap_fcntl_test = true;
145 +- will_return(__wrap_fopen, &mock_stream);
146 ++ will_return(__wrap_fopen, MOCK_STREAM);
147 + will_return(__wrap_fcntl, -1);
148 +
149 + errno = EAGAIN;
150 +@@ -306,7 +308,7 @@ check_io_write_async(void **state) {
151 + assert_int_equal(r, TSS2_FAPI_RC_IO_ERROR);
152 +
153 + io.char_rbuffer = NULL;
154 +- will_return(__wrap_fopen, &mock_stream);
155 ++ will_return(__wrap_fopen, MOCK_STREAM);
156 + will_return(__wrap_fcntl, 0);
157 + will_return(__wrap_fcntl, 0);
158 + will_return(__wrap_fcntl, -1);
159 +@@ -345,7 +347,7 @@ check_io_write_finish(void **state) {
160 + will_return_always(__wrap_fclose, 0);
161 +
162 + wrap_write_test = true;
163 +- io.stream = &mock_stream;
164 ++ io.stream = MOCK_STREAM;
165 + will_return(__wrap_write, -1);
166 + errno = EAGAIN;
167 + r = ifapi_io_write_finish(&io);
168 +--
169 +2.35.1
170 +
171
172 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
173 index 78d18901ba6d..1e76e7ee9d5f 100644
174 --- a/app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild
175 +++ b/app-crypt/tpm2-tss/tpm2-tss-3.2.0-r4.ebuild
176 @@ -38,6 +38,7 @@ BDEPEND="sys-apps/acl
177 PATCHES=(
178 "${FILESDIR}/${PN}-3.2.0-Dont-run-systemd-sysusers-in-Makefile.patch"
179 "${FILESDIR}/${PN}-3.2.0-slibtool.patch" # 858674
180 + "${FILESDIR}/${PN}-3.2.0-test-fix-usage-of-FILE-in-unit-test-fapi-io.patch"
181 )
182
183 pkg_setup() {