Skip to content

Commit bc83f4e

Browse files
mbedtls_test_fork_run_child: Expose file to invasive metatest
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
1 parent 8667f86 commit bc83f4e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/src/fork_helpers.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ static void run_child(
143143
_exit(child_exit_code);
144144
}
145145

146+
/* Do not use this variable unless you are doing debugging or fault injection
147+
* in a metatest of mbedtls_test_fork_run_child() */
148+
int mbedtls_test_fork_child_fd = -1;
149+
146150
int mbedtls_test_fork_run_child(
147151
mbedtls_test_fork_child_callback_t *child_callback,
148152
void *param,
@@ -169,6 +173,7 @@ int mbedtls_test_fork_run_child(
169173
(long) getpid(), (void *) filename);
170174
file = fopen(filename, "w+");
171175
TEST_ASSERT_ERRNO(file != NULL);
176+
mbedtls_test_fork_child_fd = fileno(file);
172177
unlink(filename);
173178

174179
/* The temporary file will contain the test result from the child,
@@ -226,6 +231,7 @@ int mbedtls_test_fork_run_child(
226231
*child_output_length = len;
227232

228233
fclose(file);
234+
mbedtls_test_fork_child_fd = -1;
229235
return 0;
230236

231237
exit:

0 commit comments

Comments
 (0)