• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Alan-Jowett / ebpf-verifier / 18949625295

28 Oct 2025 10:33AM UTC coverage: 87.448% (-1.0%) from 88.47%
18949625295

push

github

elazarg
Bump CLI11 to v2.6.1

Signed-off-by: Elazar Gershuni <elazarg@gmail.com>

9022 of 10317 relevant lines covered (87.45%)

10783407.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.87
/src/test/test_print.cpp
1
// Copyright (c) Prevail Verifier contributors.
2
// SPDX-License-Identifier: MIT
3
#include <catch2/catch_all.hpp>
4

5
#include <algorithm>
6
#include <cctype>
7
#include <fstream>
8
#include <string>
9
#include <variant>
10

11
#if !defined(MAX_PATH)
12
#define MAX_PATH (256)
13
#endif
14

15
#include "elf_loader.hpp"
16
#include "ir/unmarshal.hpp"
17

18
#define TEST_OBJECT_FILE_DIRECTORY "ebpf-samples/build/"
19
#define TEST_ASM_FILE_DIRECTORY "ebpf-samples/asm/"
20
#define PRINT_CASE(file) \
21
    TEST_CASE("Print suite: " file, "[print]") { verify_printed_string(file); }
22

23
using namespace prevail;
24

25
static void trim_right(std::string& s) {
1,396✔
26
    if (!s.empty() && s.back() == '\r') {
1,396✔
27
        s.pop_back();
×
28
    }
29
    s.erase(std::find_if(s.rbegin(), s.rend(), [](const unsigned char ch) { return !std::isspace(ch); }).base(),
2,792✔
30
            s.end());
1,396✔
31
}
1,396✔
32

33
void verify_printed_string(const std::string& file) {
38✔
34
    std::stringstream generated_output;
38✔
35
    auto raw_progs = read_elf(std::string(TEST_OBJECT_FILE_DIRECTORY) + file + ".o", "", {}, &g_ebpf_platform_linux);
152✔
36
    const RawProgram& raw_prog = raw_progs.back();
38✔
37
    std::variant<InstructionSeq, std::string> prog_or_error = unmarshal(raw_prog);
38✔
38
    auto program = std::get_if<InstructionSeq>(&prog_or_error);
38✔
39
    REQUIRE(program != nullptr);
38✔
40
    print(*program, generated_output, {});
38✔
41
    print_map_descriptors(raw_prog.info.map_descriptors, generated_output);
38✔
42
    std::ifstream expected_stream(std::string(TEST_ASM_FILE_DIRECTORY) + file + std::string(".asm"));
114✔
43
    REQUIRE(expected_stream);
38✔
44
    std::string expected_line;
38✔
45
    std::string actual_line;
38✔
46
    while (std::getline(expected_stream, expected_line)) {
736✔
47
        bool has_more = static_cast<bool>(std::getline(generated_output, actual_line));
698✔
48
        REQUIRE(has_more);
698✔
49
        trim_right(expected_line);
698✔
50
        trim_right(actual_line);
698✔
51
        REQUIRE(expected_line == actual_line);
1,047✔
52
    }
53
    bool has_more = static_cast<bool>(std::getline(expected_stream, actual_line));
38✔
54
    REQUIRE_FALSE(has_more);
57✔
55
}
38✔
56

57
PRINT_CASE("byteswap")
5✔
58
PRINT_CASE("ctxoffset")
5✔
59
PRINT_CASE("exposeptr")
5✔
60
PRINT_CASE("exposeptr2")
5✔
61
PRINT_CASE("map_in_map")
5✔
62
PRINT_CASE("mapoverflow")
5✔
63
PRINT_CASE("mapunderflow")
5✔
64
PRINT_CASE("mapvalue-overrun")
5✔
65
PRINT_CASE("nullmapref")
5✔
66
PRINT_CASE("packet_access")
5✔
67
PRINT_CASE("packet_overflow")
5✔
68
PRINT_CASE("packet_reallocate")
5✔
69
PRINT_CASE("packet_start_ok")
5✔
70
PRINT_CASE("stackok")
5✔
71
PRINT_CASE("tail_call")
5✔
72
PRINT_CASE("tail_call_bad")
5✔
73
PRINT_CASE("twomaps")
5✔
74
PRINT_CASE("twostackvars")
5✔
75
PRINT_CASE("twotypes")
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc