Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit b44e654

Browse files
Andreagit97poiana
authored andcommitted
test(modern_bpf): close the file after scanning proc
Signed-off-by: Andrea Terzolo <[email protected]>
1 parent 5dac72c commit b44e654

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

test/modern_bpf/test_suites/syscall_exit_suite/accept_x.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,20 @@ TEST(SyscallExit, acceptX_UNIX)
239239
int connected_socket_fd = syscall(__NR_accept, server_socket_fd, NULL, NULL);
240240
assert_syscall_state(SYSCALL_SUCCESS, "accept (server)", connected_socket_fd, NOT_EQUAL, -1);
241241

242+
/* In unix sockets the maximum queue length seems to be 512. */
243+
FILE *f = fopen("/proc/sys/net/unix/max_dgram_qlen", "r");
244+
if(f == NULL)
245+
{
246+
FAIL() << "'fopen' must not fail." << std::endl;
247+
}
248+
int unix_max_queue_len = 0;
249+
if(fscanf(f, "%d", &unix_max_queue_len) != 1)
250+
{
251+
fclose(f);
252+
FAIL() << "'fscanf' must not fail." << std::endl;
253+
}
254+
fclose(f);
255+
242256
/* Cleaning phase */
243257
syscall(__NR_shutdown, connected_socket_fd, 2);
244258
syscall(__NR_shutdown, server_socket_fd, 2);
@@ -282,17 +296,6 @@ TEST(SyscallExit, acceptX_UNIX)
282296
evt_test->assert_numeric_param(4, (uint32_t)0);
283297

284298
/* Parameter 5: queuemax (type: PT_UINT32) */
285-
/* In unix sockets the maximum queue length seems to be 512. */
286-
FILE *f = fopen("/proc/sys/net/unix/max_dgram_qlen", "r");
287-
if(f == NULL)
288-
{
289-
FAIL() << "'fopen' must not fail." << std::endl;
290-
}
291-
int unix_max_queue_len = 0;
292-
if(fscanf(f, "%d", &unix_max_queue_len) != 1)
293-
{
294-
FAIL() << "'fscanf' must not fail." << std::endl;
295-
}
296299
evt_test->assert_numeric_param(5, (uint32_t)unix_max_queue_len);
297300

298301
/*=============================== ASSERT PARAMETERS ===========================*/

0 commit comments

Comments
 (0)