88
99// Verify that if we unmarshal an instruction and then re-marshal it,
1010// we get what we expect.
11- static void compare_unmarshal_marshal (const ebpf_inst& ins, const ebpf_inst& expected_result,
12- const ebpf_verifier_options_t * options = nullptr ,
13- const ebpf_platform_t * platform = &g_ebpf_platform_linux) {
11+ static void compare_unmarshal_marshal (const ebpf_inst& ins, const ebpf_inst& expected_result, const ebpf_platform_t * platform = &g_ebpf_platform_linux) {
1412 program_info info{.platform = platform,
1513 .type = platform->get_program_type (" unspec" , " unspec" )};
1614 const ebpf_inst exit{.opcode = INST_OP_EXIT};
17- InstructionSeq parsed = std::get<InstructionSeq>(unmarshal (raw_program{" " , " " , {ins, exit, exit}, info}, options ));
15+ InstructionSeq parsed = std::get<InstructionSeq>(unmarshal (raw_program{" " , " " , {ins, exit, exit}, info}));
1816 REQUIRE (parsed.size () == 3 );
1917 auto [_, single, _2] = parsed.front ();
2018 (void )_; // unused
@@ -32,7 +30,7 @@ static void compare_unmarshal_marshal(const ebpf_inst& ins1, const ebpf_inst& in
3230 program_info info{.platform = &g_ebpf_platform_linux,
3331 .type = g_ebpf_platform_linux.get_program_type (" unspec" , " unspec" )};
3432 const ebpf_inst exit{.opcode = INST_OP_EXIT};
35- InstructionSeq parsed = std::get<InstructionSeq>(unmarshal (raw_program{" " , " " , {ins1, ins2, exit, exit}, info}, nullptr ));
33+ InstructionSeq parsed = std::get<InstructionSeq>(unmarshal (raw_program{" " , " " , {ins1, ins2, exit, exit}, info}));
3634 REQUIRE (parsed.size () == 3 );
3735 auto [_, single, _2] = parsed.front ();
3836 (void )_; // unused
@@ -47,12 +45,10 @@ static void compare_unmarshal_marshal(const ebpf_inst& ins1, const ebpf_inst& in
4745
4846// Verify that if we marshal an instruction and then unmarshal it,
4947// we get the original.
50- static void compare_marshal_unmarshal (const Instruction& ins, bool double_cmd = false ,
51- const ebpf_verifier_options_t * options = nullptr ,
52- const ebpf_platform_t * platform = &g_ebpf_platform_linux) {
48+ static void compare_marshal_unmarshal (const Instruction& ins, bool double_cmd = false , const ebpf_platform_t * platform = &g_ebpf_platform_linux) {
5349 program_info info{.platform = platform,
5450 .type = platform->get_program_type (" unspec" , " unspec" )};
55- InstructionSeq parsed = std::get<InstructionSeq>(unmarshal (raw_program{" " , " " , marshal (ins, 0 ), info}, options ));
51+ InstructionSeq parsed = std::get<InstructionSeq>(unmarshal (raw_program{" " , " " , marshal (ins, 0 ), info}));
5652 REQUIRE (parsed.size () == 1 );
5753 auto [_, single, _2] = parsed.back ();
5854 (void )_; // unused
@@ -64,17 +60,15 @@ static void check_marshal_unmarshal_fail(const Instruction& ins, std::string exp
6460 const ebpf_platform_t * platform = &g_ebpf_platform_linux) {
6561 program_info info{.platform = platform,
6662 .type = platform->get_program_type (" unspec" , " unspec" )};
67- std::string error_message = std::get<std::string>(unmarshal (raw_program{" " , " " , marshal (ins, 0 ), info}, nullptr ));
63+ std::string error_message = std::get<std::string>(unmarshal (raw_program{" " , " " , marshal (ins, 0 ), info}));
6864 REQUIRE (error_message == expected_error_message);
6965}
7066
71- static void check_unmarshal_fail (ebpf_inst inst, std::string expected_error_message,
72- const ebpf_verifier_options_t * options = nullptr ,
73- const ebpf_platform_t * platform = &g_ebpf_platform_linux) {
67+ static void check_unmarshal_fail (ebpf_inst inst, std::string expected_error_message, const ebpf_platform_t * platform = &g_ebpf_platform_linux) {
7468 program_info info{.platform = platform,
7569 .type = platform->get_program_type (" unspec" , " unspec" )};
7670 std::vector<ebpf_inst> insns = {inst};
77- auto result = unmarshal (raw_program{" " , " " , insns, info}, options );
71+ auto result = unmarshal (raw_program{" " , " " , insns, info});
7872 REQUIRE (std::holds_alternative<std::string>(result));
7973 std::string error_message = std::get<std::string>(result);
8074 REQUIRE (error_message == expected_error_message);
@@ -85,7 +79,7 @@ static void check_unmarshal_fail(ebpf_inst inst1, ebpf_inst inst2, std::string e
8579 program_info info{.platform = &g_ebpf_platform_linux,
8680 .type = g_ebpf_platform_linux.get_program_type (" unspec" , " unspec" )};
8781 std::vector<ebpf_inst> insns = {inst1, inst2};
88- auto result = unmarshal (raw_program{" " , " " , insns, info}, nullptr );
82+ auto result = unmarshal (raw_program{" " , " " , insns, info});
8983 REQUIRE (std::holds_alternative<std::string>(result));
9084 std::string error_message = std::get<std::string>(result);
9185 REQUIRE (error_message == expected_error_message);
@@ -187,8 +181,8 @@ TEST_CASE("disasm_marshal", "[disasm][marshal]") {
187181 // Test callx with support.
188182 ebpf_platform_t platform = g_ebpf_platform_linux;
189183 platform.callx = true ;
190- compare_marshal_unmarshal (Callx{8 }, false , nullptr , &platform);
191- check_unmarshal_fail (ebpf_inst{.opcode = /* 0x8d */ INST_OP_CALLX, .src = 11 }, " 0: Bad register\n " , nullptr , &platform);
184+ compare_marshal_unmarshal (Callx{8 }, false , &platform);
185+ check_unmarshal_fail (ebpf_inst{.opcode = /* 0x8d */ INST_OP_CALLX, .src = 11 }, " 0: Bad register\n " , &platform);
192186 }
193187
194188 SECTION (" Exit" ) { compare_marshal_unmarshal (Exit{}); }
0 commit comments