Skip to content

Commit 5ed00b2

Browse files
Andreagit97poiana
authored andcommitted
new(tests): add some dns tests
Signed-off-by: Andrea Terzolo <[email protected]>
1 parent c5a6a68 commit 5ed00b2

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

Diff for: test/drivers/test_suites/syscall_exit_suite/recvfrom_x.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,50 @@ TEST(SyscallExit, recvfromX_ipv4_tcp_message_not_truncated_fullcapture_port)
152152
evt_test->assert_num_params_pushed(3);
153153
}
154154

155+
TEST(SyscallExit, recvfromX_ipv4_tcp_message_not_truncated_DNS_snaplen)
156+
{
157+
auto evt_test = get_syscall_event_test(__NR_recvfrom, EXIT_EVENT);
158+
159+
evt_test->set_do_dynamic_snaplen(true);
160+
161+
evt_test->enable_capture();
162+
163+
/*=============================== TRIGGER SYSCALL ===========================*/
164+
165+
evt_test->client_to_server_ipv4_tcp(send_data{.syscall_num = __NR_sendto, .greater_snaplen = true},
166+
recv_data{.syscall_num = __NR_recvfrom}, IP_PORT_DNS, IP_PORT_SERVER);
167+
168+
/*=============================== TRIGGER SYSCALL ===========================*/
169+
170+
evt_test->disable_capture();
171+
172+
evt_test->set_do_dynamic_snaplen(false);
173+
174+
evt_test->assert_event_presence();
175+
176+
if(HasFatalFailure())
177+
{
178+
return;
179+
}
180+
181+
evt_test->parse_event();
182+
183+
evt_test->assert_header();
184+
185+
/*=============================== ASSERT PARAMETERS ===========================*/
186+
187+
/* Parameter 1: res (type: PT_ERRNO) */
188+
evt_test->assert_numeric_param(1, (int64_t)MAX_RECV_BUF_SIZE);
189+
190+
/* Parameter 2: data (type: PT_BYTEBUF) */
191+
// Since the client port matches the fullcapture port range we should see the full message.
192+
evt_test->assert_bytebuf_param(2, LONG_MESSAGE, MAX_RECV_BUF_SIZE);
193+
194+
/*=============================== ASSERT PARAMETERS ===========================*/
195+
196+
evt_test->assert_num_params_pushed(3);
197+
}
198+
155199
TEST(SyscallExit, recvfromX_ipv6_tcp_message_not_truncated_fullcapture_port)
156200
{
157201
auto evt_test = get_syscall_event_test(__NR_recvfrom, EXIT_EVENT);

Diff for: test/drivers/test_suites/syscall_exit_suite/sendto_x.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,49 @@ TEST(SyscallExit, sendtoX_ipv4_tcp_message_not_truncated_fullcapture_port)
133133
evt_test->assert_num_params_pushed(2);
134134
}
135135

136+
TEST(SyscallExit, sendtoX_ipv4_tcp_message_not_truncated_DNS_snaplen)
137+
{
138+
auto evt_test = get_syscall_event_test(__NR_sendto, EXIT_EVENT);
139+
140+
evt_test->set_do_dynamic_snaplen(true);
141+
142+
evt_test->enable_capture();
143+
144+
/*=============================== TRIGGER SYSCALL ===========================*/
145+
146+
// The remote port is the DNS one so the snaplen should be increased.
147+
evt_test->client_to_server_ipv4_tcp(send_data{.syscall_num = __NR_sendto, .greater_snaplen = true}, recv_data{.skip_recv_phase = true}, IP_PORT_CLIENT, IP_PORT_DNS);
148+
149+
/*=============================== TRIGGER SYSCALL ===========================*/
150+
151+
evt_test->disable_capture();
152+
153+
evt_test->set_do_dynamic_snaplen(false);
154+
155+
evt_test->assert_event_presence();
156+
157+
if(HasFatalFailure())
158+
{
159+
return;
160+
}
161+
162+
evt_test->parse_event();
163+
164+
evt_test->assert_header();
165+
166+
/*=============================== ASSERT PARAMETERS ===========================*/
167+
168+
/* Parameter 1: res (type: PT_ERRNO) */
169+
evt_test->assert_numeric_param(1, (int64_t)LONG_MESSAGE_LEN);
170+
171+
/* Parameter 2: data (type: PT_BYTEBUF)*/
172+
evt_test->assert_bytebuf_param(2, LONG_MESSAGE, LONG_MESSAGE_LEN);
173+
174+
/*=============================== ASSERT PARAMETERS ===========================*/
175+
176+
evt_test->assert_num_params_pushed(2);
177+
}
178+
136179
TEST(SyscallExit, sendtoX_ipv6_tcp_message_not_truncated_fullcapture_port)
137180
{
138181
auto evt_test = get_syscall_event_test(__NR_sendto, EXIT_EVENT);

0 commit comments

Comments
 (0)