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

Alan-Jowett / ebpf-verifier / 21993000823

13 Feb 2026 01:02PM UTC coverage: 86.313% (-0.5%) from 86.783%
21993000823

push

github

web-flow
ISA feature support matrix and precise rejection semantics (#999)

* ISA feature support matrix and precise rejection semantics

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

282 of 380 new or added lines in 14 files covered. (74.21%)

3 existing lines in 3 files now uncovered.

9535 of 11047 relevant lines covered (86.31%)

3060772.25 hits per line

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

84.78
/src/test/conformance_check.cpp
1
// Copyright (c) Prevail Verifier contributors.
2
// SPDX-License-Identifier: MIT
3

4
// This program reads BPF instructions from stdin and memory contents from
5
// the first argument. It then executes the BPF program and prints the
6
// value of r0 at the end of execution.
7
// The program is intended to be used with the bpf conformance test suite.
8

9
#include <iostream>
10
#include <sstream>
11
#include <string>
12
#include <vector>
13

14
#include <CLI11/CLI11.hpp>
15

16
#include "ebpf_verifier.hpp"
17
#include "test/ebpf_yaml.hpp"
18

19
using namespace prevail;
20

21
/**
22
 * @brief Read in a string of hex bytes and return a vector of bytes.
23
 *
24
 * @param[in] input String containing hex bytes.
25
 * @return Vector of bytes.
26
 */
27
std::vector<std::byte> base16_decode(const std::string& input) {
1,252✔
28
    std::vector<std::byte> output;
1,252✔
29
    std::stringstream ss(input);
1,252✔
30
    std::string value;
1,252✔
31
    while (std::getline(ss, value, ' ')) {
91,284✔
32
        if (value.empty()) {
90,032✔
33
            continue;
45,016✔
34
        }
35
        try {
22,508✔
36
            output.push_back(static_cast<std::byte>(std::stoi(value, nullptr, 16)));
45,016✔
37
        } catch (std::invalid_argument&) {
×
38
            std::cerr << "base16_decode failed to decode " << value << "\n";
×
39
        } catch (std::out_of_range&) {
×
40
            std::cerr << "base16_decode failed to decode " << value << "\n";
×
41
        }
×
42
    }
43
    return output;
2,504✔
44
}
1,252✔
45

46
/**
47
 * @brief This program reads BPF instructions from stdin and memory contents from
48
 * the first argument. It then executes the BPF program and prints the
49
 * value of r0 at the end of execution.
50
 */
51
int main(int argc, char** argv) {
626✔
52
    CLI::App app{"Check conformance"};
1,565✔
53
    bool debug = false;
626✔
54
    app.add_flag("--debug", debug, "Debug");
1,565✔
55
    std::string memory_string;
626✔
56
    app.add_option("--memory,memory", memory_string, "base16 memory bytes");
1,565✔
57
    std::string program_string;
626✔
58
    app.add_option("--program", program_string, "base16 program bytes");
1,565✔
59
    std::string other_positional_argument;
626✔
60

61
    // Currently the conformance test project passes an empty string as an additional
62
    // positional argument. We need to accept it to make CLI11 parsing pass until
63
    // the test project is fixed.
64
    app.add_option("other", other_positional_argument, "Other");
1,565✔
65
    CLI11_PARSE(app, argc, argv);
626✔
66

67
    if (program_string.empty()) {
626✔
68
        std::getline(std::cin, program_string);
626✔
69
    }
70

71
    const auto& result = run_conformance_test_case(base16_decode(memory_string), base16_decode(program_string), debug);
626✔
72
    if (!result.success) {
626✔
73
        // Write failure reason to stdout since the bpf conformance library does not look at stderr.
74
        if (!result.error_reason.empty()) {
2✔
NEW
75
            std::cout << result.error_reason << "\n";
×
76
        } else {
77
            std::cout << "Verification failed\n";
2✔
78
        }
79
        return 1;
2✔
80
    }
81
    if (result.r0_value.is_top()) {
624✔
82
        std::cout << "Couldn't determine r0 value\n";
4✔
83
        return 1;
2✔
84
    }
85
    if (!result.r0_value.singleton()) {
927✔
86
        std::cout << "r0 value is range [" << result.r0_value.lb() << ", " << result.r0_value.ub() << "]\n";
15✔
87
        return 1;
6✔
88
    }
89

90
    // Print output so the conformance test suite can check it.
91
    if (result.r0_value.singleton() && result.r0_value.singleton().value().fits_cast_to<int64_t>()) {
1,228✔
92
        std::cout << std::hex << result.r0_value.singleton().value().cast_to<uint64_t>() << std::endl;
1,228✔
93
    } else {
UNCOV
94
        std::cout << result.r0_value << std::endl;
×
95
    }
96

97
    return 0;
307✔
98
}
939✔
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