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

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

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

7.41
/libs/core/testing/src/testing.cpp
1
//  Copyright (c) 2020 ETH Zurich
2
//  Copyright (c) 2013-2022 Hartmut Kaiser
3
//  Copyright (c) 2017 Denis Blank
4
//
5
//  SPDX-License-Identifier: BSL-1.0
6
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
7
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8

9
#define HPX_NO_VERSION_CHECK
10

11
#include <hpx/assert.hpp>
12
#include <hpx/modules/format.hpp>
13
#include <hpx/modules/testing.hpp>
14
#include <hpx/modules/util.hpp>
15

16
#include <atomic>
17
#include <cstddef>
18
#include <cstdint>
19
#include <functional>
20
#include <iostream>
21
#include <string>
22

23
namespace hpx::util {
24

25
    static test_failure_handler_type test_failure_handler;
26

27
    void set_test_failure_handler(test_failure_handler_type f)
64✔
28
    {
29
        test_failure_handler = HPX_MOVE(f);
30
    }
64✔
31

32
    namespace detail {
33

34
        std::atomic<std::size_t> sanity_failures_(0);
35
        std::atomic<std::size_t> test_failures_(0);
36

37
        void fixture::increment(counter_type c) noexcept
×
38
        {
39
            if (test_failure_handler)
×
40
            {
41
                test_failure_handler();
42
            }
43

44
            switch (c)
×
45
            {
46
            case counter_type::sanity:
47
                ++sanity_failures_;
48
                return;
49
            case counter_type::test:
50
                ++test_failures_;
51
                return;
52
            default:
53
                break;
54
            }
55
            HPX_ASSERT(false);
56
        }
57

58
        std::size_t fixture::get(counter_type c) noexcept
×
59
        {
60
            switch (c)
×
61
            {
62
            case counter_type::sanity:
63
                return sanity_failures_;
×
64
            case counter_type::test:
65
                return test_failures_;
×
66
            default:
67
                break;
68
            }
69
            HPX_ASSERT(false);
70
            return static_cast<std::size_t>(-1);
71
        }
72

73
        fixture& global_fixture() noexcept
×
74
        {
75
            static fixture fixture_(std::cerr);
×
76
            return fixture_;
×
77
        }
78
    }    // namespace detail
79

80
    ////////////////////////////////////////////////////////////////////////////
81
    int report_errors()
×
82
    {
83
        return report_errors(std::cerr);
×
84
    }
85

86
    int report_errors(std::ostream& stream)
×
87
    {
88
        std::size_t const sanity =
89
            detail::global_fixture().get(counter_type::sanity);
×
90
        std::size_t const test =
91
            detail::global_fixture().get(counter_type::test);
×
92
        if (sanity == 0 && test == 0)
×
93
            return 0;
94

95
        hpx::util::ios_flags_saver ifs(stream);
×
96
        stream << sanity << " sanity check"    //-V128
97
               << ((sanity == 1) ? " and " : "s and ") << test << " test"
×
98
               << ((test == 1) ? " failed." : "s failed.") << std::endl;
×
99
        return 1;
100
    }
101

102
    void print_cdash_timing(char const* name, double time)
×
103
    {
104
        // use format followed by single cout for better multi-threaded output
105
        std::string const temp =
106
            hpx::util::format("<DartMeasurement name=\"{}\" "
107
                              "type=\"numeric/double\">{}</DartMeasurement>",
108
                name, time);
×
109
        std::cout << temp << std::endl;
110
    }
×
111

112
    void print_cdash_timing(char const* name, std::uint64_t time)
×
113
    {
114
        print_cdash_timing(name, static_cast<double>(time) / 1e9);
×
115
    }
×
116
}    // namespace hpx::util
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