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

STEllAR-GROUP / hpx / #847

07 Dec 2022 07:15PM UTC coverage: 85.835% (-0.6%) from 86.482%
#847

push

StellarBot
Merge #6095

6095: Replacing facilities from Boost.Range r=hkaiser a=hkaiser

Working towards #3440 


Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>

43 of 43 new or added lines in 21 files covered. (100.0%)

171460 of 199755 relevant lines covered (85.84%)

1820288.13 hits per line

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

67.8
/libs/full/resiliency_distributed/tests/unit/async_replicate_distributed_plain.cpp
1
//  Copyright (c) 2019-2020 Nikunj Gupta
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#include <hpx/config.hpp>
8
#if !defined(HPX_COMPUTE_DEVICE_CODE)
9

10
#include <hpx/actions_base/plain_action.hpp>
11
#include <hpx/hpx_init.hpp>
12
#include <hpx/include/runtime.hpp>
13
#include <hpx/modules/futures.hpp>
14
#include <hpx/modules/resiliency.hpp>
15
#include <hpx/modules/resiliency_distributed.hpp>
16
#include <hpx/modules/testing.hpp>
17

18
#include <cstddef>
19
#include <iostream>
20
#include <random>
21
#include <vector>
22

23
std::random_device rd;
2✔
24
std::mt19937 mt(rd());
2✔
25
std::uniform_real_distribution<double> dist(1.0, 10.0);
2✔
26

27
int universal_ans()
8✔
28
{
29
    if (dist(mt) > 5)
8✔
30
        return 42;
4✔
31
    return 84;
4✔
32
}
8✔
33

34
HPX_PLAIN_ACTION(universal_ans, universal_action)
23✔
35

36
bool validate(int ans)
4✔
37
{
38
    return ans == 42;
4✔
39
}
40

41
int vote(std::vector<int>&& results)
2✔
42
{
43
    return results.at(0);
2✔
44
}
45

46
int hpx_main()
1✔
47
{
48
    std::vector<hpx::id_type> locals = hpx::find_all_localities();
1✔
49

50
    // Allow a task to replicate on the same locality if there is only 1 locality
51
    if (locals.size() == 1)
1✔
52
    {
53
        locals.insert(locals.end(), 9, hpx::find_here());
×
54
    }
×
55

56
    {
57
        universal_action action;
58
        hpx::future<int> f =
59
            hpx::resiliency::experimental::async_replicate(locals, action);
1✔
60

61
        try
62
        {
63
            f.get();
1✔
64
        }
1✔
65
        catch (hpx::resiliency::experimental::abort_replicate_exception const&)
66
        {
67
            HPX_TEST(true);
×
68
        }
×
69
        catch (...)
70
        {
71
            HPX_TEST(false);
×
72
        }
×
73
    }
1✔
74

75
    {
76
        universal_action action;
77
        hpx::future<int> f =
78
            hpx::resiliency::experimental::async_replicate_validate(
1✔
79
                locals, &validate, action);
1✔
80

81
        try
82
        {
83
            f.get();
1✔
84
        }
1✔
85
        catch (hpx::resiliency::experimental::abort_replicate_exception const&)
86
        {
87
            HPX_TEST(true);
×
88
        }
×
89
        catch (...)
90
        {
91
            HPX_TEST(false);
×
92
        }
×
93
    }
1✔
94

95
    {
96
        universal_action action;
97
        hpx::future<int> f =
98
            hpx::resiliency::experimental::async_replicate_vote(
1✔
99
                locals, &vote, action);
1✔
100

101
        try
102
        {
103
            f.get();
1✔
104
        }
1✔
105
        catch (hpx::resiliency::experimental::abort_replicate_exception const&)
106
        {
107
            HPX_TEST(true);
×
108
        }
×
109
        catch (...)
110
        {
111
            HPX_TEST(false);
×
112
        }
×
113
    }
1✔
114

115
    {
116
        universal_action action;
117
        hpx::future<int> f =
118
            hpx::resiliency::experimental::async_replicate_vote_validate(
1✔
119
                locals, &vote, &validate, action);
1✔
120

121
        try
122
        {
123
            f.get();
1✔
124
        }
1✔
125
        catch (hpx::resiliency::experimental::abort_replicate_exception const&)
126
        {
127
            HPX_TEST(true);
×
128
        }
×
129
        catch (...)
130
        {
131
            HPX_TEST(false);
×
132
        }
×
133
    }
1✔
134

135
    return hpx::finalize();
1✔
136
}
1✔
137

138
int main(int argc, char* argv[])
2✔
139
{
140
    // Initialize and run HPX
141
    HPX_TEST(hpx::init(argc, argv) == 0);
2✔
142
    return hpx::util::report_errors();
2✔
143
}
×
144

145
#endif
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