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

mavlink / MAVSDK / 16665088909

01 Aug 2025 02:55AM UTC coverage: 46.166% (-0.1%) from 46.31%
16665088909

push

github

web-flow
Merge pull request #2630 from mavlink/pr-segfault-fixes

Stack-use-after-free and thread-safety fixes, CI additions, clang-format-19

241 of 320 new or added lines in 32 files covered. (75.31%)

39 existing lines in 10 files now uncovered.

16101 of 34876 relevant lines covered (46.17%)

361.1 hits per line

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

80.56
/src/system_tests/fs_helpers.cpp
1
#include "fs_helpers.h"
2
#include "log.h"
3
#include <algorithm>
4
#include <iostream>
5
#include <iterator>
6
#include <filesystem>
7
#include <fstream>
8
#include <cstring>
9

10
using namespace mavsdk;
11

12
bool create_temp_file(const fs::path& path, size_t len, uint8_t start)
121✔
13
{
14
    const auto parent_path = path.parent_path();
121✔
15
    create_directories(parent_path);
121✔
16

17
    std::ofstream tempfile{};
121✔
18
    tempfile.open(path, std::ios::out | std::ios::binary | std::ios::trunc);
121✔
19
    if (tempfile.fail()) {
121✔
20
        LogWarn() << "Failed to open temp file";
×
21
        return false;
×
22
    }
23

24
    for (size_t i = 0; i < len; ++i) {
156,571✔
25
        const char c = (i + start) % 256;
156,450✔
26
        tempfile.write(&c, 1);
156,450✔
27
    }
28

29
    tempfile.close();
121✔
30

31
    return true;
121✔
32
}
121✔
33

34
bool reset_directories(const fs::path& path)
123✔
35
{
36
    std::error_code ec;
123✔
37
    fs::remove_all(path, ec);
123✔
38
    if (ec) {
123✔
NEW
39
        LogErr() << "Error removing " << path << ": " << ec.message();
×
40
    }
41

42
    return fs::create_directories(path);
123✔
43
}
44

45
bool are_files_identical(const fs::path& path1, const fs::path& path2)
9✔
46
{
47
    std::ifstream file1(path1, std::ios::binary);
9✔
48
    std::ifstream file2(path2, std::ios::binary);
9✔
49

50
    if (!file1) {
9✔
51
        LogWarn() << "Could not open " << path1;
×
52
        return false;
×
53
    }
54

55
    if (!file2) {
9✔
56
        LogWarn() << "Could not open " << path2;
×
57
        return false;
×
58
    }
59

60
    std::istreambuf_iterator<char> begin1(file1);
9✔
61
    std::istreambuf_iterator<char> begin2(file2);
9✔
62
    std::istreambuf_iterator<char> end;
9✔
63

64
    return std::equal(begin1, end, begin2, end);
9✔
65
}
9✔
66

67
bool file_exists(const fs::path& path)
6✔
68
{
69
    return fs::exists(path);
6✔
70
}
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

© 2025 Coveralls, Inc