gtest_inject_tcp_rst creates a working directory under the current path
This commit is contained in:
@@ -2,18 +2,24 @@
|
||||
|
||||
#include "packet_injector_test_frame.h"
|
||||
|
||||
static char current_dir[1024] = {0};
|
||||
|
||||
#if 1
|
||||
TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SYN_ACK)
|
||||
{
|
||||
char work_dir[2048] = {0};
|
||||
char input_dir[2048] = {0};
|
||||
snprintf(work_dir, sizeof(work_dir), "%s/%s", current_dir, "inject_ipv4_based_tcp_rst_after_recv_syn_ack");
|
||||
snprintf(input_dir, sizeof(input_dir), "%s/%s", current_dir, "pcap/inject_ipv4_based_tcp_rst_after_recv_syn_ack/test/");
|
||||
|
||||
struct packet_injector_case test = {
|
||||
// descriptor
|
||||
.finish_clean_work_dir = 1,
|
||||
.finish_clean_work_dir = 0,
|
||||
.descriptor = "Inject IPv4 based TCP RST after receiving SYN-ACK packet.",
|
||||
.work_dir = "/tmp/inject_ipv4_based_tcp_rst_after_recv_syn_ack/", // user defined work directory
|
||||
.work_dir = work_dir,
|
||||
|
||||
// prefix
|
||||
.input_prefix = "pcap/inject_ipv4_based_tcp_rst_after_recv_syn_ack/test/",
|
||||
.output_prefix = "/tmp/",
|
||||
.input_prefix = input_dir,
|
||||
|
||||
// input pcap
|
||||
.input_pcap = "input.pcap",
|
||||
@@ -37,15 +43,19 @@ TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SYN_ACK)
|
||||
#if 1
|
||||
TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SUB_ACK)
|
||||
{
|
||||
char work_dir[2048] = {0};
|
||||
char input_dir[2048] = {0};
|
||||
snprintf(work_dir, sizeof(work_dir), "%s/%s", current_dir, "inject_ipv4_based_tcp_rst_after_recv_sub_ack");
|
||||
snprintf(input_dir, sizeof(input_dir), "%s/%s", current_dir, "pcap/inject_ipv4_based_tcp_rst_after_recv_sub_ack/test/");
|
||||
|
||||
struct packet_injector_case test = {
|
||||
// descriptor
|
||||
.finish_clean_work_dir = 1,
|
||||
.finish_clean_work_dir = 0,
|
||||
.descriptor = "Inject IPv4 based TCP RST after receiving SUB-ACK packet.",
|
||||
.work_dir = "/tmp/inject_ipv4_based_tcp_rst_after_recv_sub_ack/", // user defined work directory
|
||||
.work_dir = work_dir,
|
||||
|
||||
// prefix
|
||||
.input_prefix = "pcap/inject_ipv4_based_tcp_rst_after_recv_sub_ack/test/",
|
||||
.output_prefix = "/tmp/",
|
||||
.input_prefix = input_dir,
|
||||
|
||||
// input pcap
|
||||
.input_pcap = "input.pcap",
|
||||
@@ -69,15 +79,19 @@ TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SUB_ACK)
|
||||
#if 1
|
||||
TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_C2S_FIRST_PAYLOAD)
|
||||
{
|
||||
char work_dir[2048] = {0};
|
||||
char input_dir[2048] = {0};
|
||||
snprintf(work_dir, sizeof(work_dir), "%s/%s", current_dir, "inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload");
|
||||
snprintf(input_dir, sizeof(input_dir), "%s/%s", current_dir, "pcap/inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload/test/");
|
||||
|
||||
struct packet_injector_case test = {
|
||||
// descriptor
|
||||
.finish_clean_work_dir = 1,
|
||||
.finish_clean_work_dir = 0,
|
||||
.descriptor = "Inject IPv4 based TCP RST after receiving C2S first payload packet.",
|
||||
.work_dir = "/tmp/inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload/", // user defined work directory
|
||||
.work_dir = work_dir,
|
||||
|
||||
// prefix
|
||||
.input_prefix = "pcap/inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload/test/",
|
||||
.output_prefix = "/tmp/",
|
||||
.input_prefix = input_dir,
|
||||
|
||||
// input pcap
|
||||
.input_pcap = "input.pcap",
|
||||
@@ -101,15 +115,19 @@ TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_C2S_FIRST_PAYLOAD)
|
||||
#if 1
|
||||
TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_S2C_FIRST_PAYLOAD)
|
||||
{
|
||||
char work_dir[2048] = {0};
|
||||
char input_dir[2048] = {0};
|
||||
snprintf(work_dir, sizeof(work_dir), "%s/%s", current_dir, "inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload");
|
||||
snprintf(input_dir, sizeof(input_dir), "%s/%s", current_dir, "pcap/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload/test/");
|
||||
|
||||
struct packet_injector_case test = {
|
||||
// descriptor
|
||||
.finish_clean_work_dir = 1,
|
||||
.finish_clean_work_dir = 0,
|
||||
.descriptor = "Inject IPv4 based TCP RST after receiving S2C first payload packet.",
|
||||
.work_dir = "/tmp/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload/", // user defined work directory
|
||||
.work_dir = work_dir,
|
||||
|
||||
// prefix
|
||||
.input_prefix = "pcap/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload/test/",
|
||||
.output_prefix = "/tmp/",
|
||||
.input_prefix = input_dir,
|
||||
|
||||
// input pcap
|
||||
.input_pcap = "input.pcap",
|
||||
@@ -132,6 +150,7 @@ TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_S2C_FIRST_PAYLOAD)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
getcwd(current_dir, sizeof(current_dir));
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ void packet_injector_test_frame_run(struct packet_injector_case *test)
|
||||
// compare pcap
|
||||
if (test->c2s_output_pcap && test->c2s_expect_pcap)
|
||||
{
|
||||
system_cmd("mv %s/%s %s", test->output_prefix, test->c2s_output_pcap, output_dir_abs_path);
|
||||
system_cmd("mv %s/%s %s", test->work_dir, test->c2s_output_pcap, output_dir_abs_path);
|
||||
expect_cmp_inject(test->work_dir,
|
||||
expect_dir_abs_path, test->c2s_expect_pcap,
|
||||
output_dir_abs_path, test->c2s_output_pcap,
|
||||
@@ -189,7 +189,7 @@ void packet_injector_test_frame_run(struct packet_injector_case *test)
|
||||
}
|
||||
if (test->s2c_output_pcap && test->s2c_expect_pcap)
|
||||
{
|
||||
system_cmd("mv %s/%s %s", test->output_prefix, test->s2c_output_pcap, output_dir_abs_path);
|
||||
system_cmd("mv %s/%s %s", test->work_dir, test->s2c_output_pcap, output_dir_abs_path);
|
||||
expect_cmp_inject(test->work_dir,
|
||||
expect_dir_abs_path, test->s2c_expect_pcap,
|
||||
output_dir_abs_path, test->s2c_output_pcap,
|
||||
|
||||
@@ -15,7 +15,6 @@ struct packet_injector_case
|
||||
|
||||
// prefix
|
||||
const char *input_prefix;
|
||||
const char *output_prefix;
|
||||
|
||||
// input pcap
|
||||
const char *input_pcap;
|
||||
|
||||
Reference in New Issue
Block a user