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

STEllAR-GROUP / hpx / #867

15 Jan 2023 08:00PM UTC coverage: 86.487% (+0.5%) from 85.951%
#867

push

StellarBot
Merge #6135

6135: Fixing warnings reported by MSVC analysis r=hkaiser a=hkaiser

- adding MSVC specific #pragma's to suppress the benign warnings


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

120 of 120 new or added lines in 33 files covered. (100.0%)

174599 of 201880 relevant lines covered (86.49%)

1945607.64 hits per line

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

3.53
/libs/full/runtime_components/tests/unit/components/get_ptr.cpp
1
//  Copyright (c) 2013 Hartmut Kaiser
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
#include <hpx/hpx_main.hpp>
10
#include <hpx/include/actions.hpp>
11
#include <hpx/include/components.hpp>
12
#include <hpx/include/runtime.hpp>
13
#include <hpx/modules/testing.hpp>
14
#include <hpx/runtime_local/custom_exception_info.hpp>
15

16
#include <cstddef>
17
#include <memory>
18
#include <utility>
19
#include <vector>
20

21
///////////////////////////////////////////////////////////////////////////////
22
struct test_server : hpx::components::component_base<test_server>
8✔
23
{
24
    std::size_t check_ptr() const
×
25
    {
26
        return reinterpret_cast<std::size_t>(this);
×
27
    }
28

29
    HPX_DEFINE_COMPONENT_ACTION(test_server, check_ptr, check_ptr_action)
30
};
31

32
typedef hpx::components::component<test_server> server_type;
33
HPX_REGISTER_COMPONENT(server_type, test_server)
46✔
34

35
typedef test_server::check_ptr_action check_ptr_action;
36
HPX_REGISTER_ACTION_DECLARATION(check_ptr_action)
37
HPX_REGISTER_ACTION(check_ptr_action)
3✔
38

39
struct test_client : hpx::components::client_base<test_client, test_server>
×
40
{
41
    typedef hpx::components::client_base<test_client, test_server> base_type;
42

43
    explicit test_client(hpx::id_type const& id) noexcept
×
44
      : base_type(id)
×
45
    {
×
46
    }
×
47

48
    test_client(hpx::future<hpx::id_type>&& id) noexcept
×
49
      : base_type(std::move(id))
×
50
    {
×
51
    }
×
52

53
    std::size_t check_ptr()
×
54
    {
55
        return check_ptr_action()(this->get_id());
×
56
    }
57
};
58

59
///////////////////////////////////////////////////////////////////////////////
60
bool test_get_ptr1(hpx::id_type id)
×
61
{
62
    test_client t = hpx::new_<test_client>(id);
×
63
    HPX_TEST_NEQ(hpx::invalid_id, t.get_id());
×
64

65
    try
66
    {
67
        hpx::future<std::shared_ptr<test_server>> f =
68
            hpx::get_ptr<test_server>(t.get_id());
×
69

70
        std::shared_ptr<test_server> ptr = f.get();
×
71

72
        HPX_TEST_EQ(reinterpret_cast<test_server*>(t.check_ptr()), ptr.get());
×
73
        return true;
×
74
    }
×
75
    catch (hpx::exception const& e)
76
    {
77
        HPX_TEST_EQ(int(e.get_error()), int(hpx::error::bad_parameter));
×
78
    }
×
79

80
    return false;
×
81
}
×
82

83
bool test_get_ptr2(hpx::id_type id)
×
84
{
85
    test_client t = hpx::new_<test_client>(id);
×
86
    HPX_TEST_NEQ(hpx::invalid_id, t.get_id());
×
87

88
    hpx::future<std::shared_ptr<test_server>> f =
89
        hpx::get_ptr<test_server>(t.get_id());
×
90

91
    f.wait();
×
92
    bool has_exception = f.has_exception();
×
93

94
    hpx::error_code ec;
×
95
    std::shared_ptr<test_server> ptr = f.get(ec);
×
96

97
    // Intel 13 has trouble to generate correct code for if(ec) { ... }
98
    if (ec || !ptr.get())
×
99
    {
100
        HPX_TEST(has_exception);
×
101
        return false;
×
102
    }
103

104
    HPX_TEST(!has_exception);
×
105
    HPX_TEST_EQ(reinterpret_cast<test_server*>(t.check_ptr()), ptr.get());
×
106
    return true;
×
107
}
×
108

109
///////////////////////////////////////////////////////////////////////////////
110
bool test_get_ptr3(hpx::id_type id)
×
111
{
112
    test_client t = hpx::new_<test_client>(id);
×
113
    HPX_TEST_NEQ(hpx::invalid_id, t.get_id());
×
114

115
    try
116
    {
117
        hpx::future<std::shared_ptr<test_server>> f = hpx::get_ptr(t);
×
118
        std::shared_ptr<test_server> ptr = f.get();
×
119

120
        HPX_TEST_EQ(reinterpret_cast<test_server*>(t.check_ptr()), ptr.get());
×
121
        return true;
×
122
    }
×
123
    catch (hpx::exception const& e)
124
    {
125
        HPX_TEST_EQ(int(e.get_error()), int(hpx::error::bad_parameter));
×
126
    }
×
127

128
    return false;
×
129
}
×
130

131
bool test_get_ptr4(hpx::id_type id)
×
132
{
133
    test_client t = hpx::new_<test_client>(id);
×
134
    HPX_TEST_NEQ(hpx::invalid_id, t.get_id());
×
135

136
    hpx::future<std::shared_ptr<test_server>> f = hpx::get_ptr(t);
×
137
    f.wait();
×
138

139
    bool has_exception = f.has_exception();
×
140

141
    hpx::error_code ec;
×
142
    std::shared_ptr<test_server> ptr = f.get(ec);
×
143

144
    // Intel 13 has trouble to generate correct code for if(ec) { ... }
145
    if (ec || !ptr.get())
×
146
    {
147
        HPX_TEST(has_exception);
×
148
        return false;
×
149
    }
150

151
    HPX_TEST(!has_exception);
×
152
    HPX_TEST_EQ(reinterpret_cast<test_server*>(t.check_ptr()), ptr.get());
×
153
    return true;
×
154
}
×
155

156
///////////////////////////////////////////////////////////////////////////////
157
int main()
×
158
{
159
    HPX_TEST(test_get_ptr1(hpx::find_here()));
×
160
    HPX_TEST(test_get_ptr2(hpx::find_here()));
×
161
    HPX_TEST(test_get_ptr3(hpx::find_here()));
×
162
    HPX_TEST(test_get_ptr4(hpx::find_here()));
×
163

164
    std::vector<hpx::id_type> localities = hpx::find_remote_localities();
×
165
    for (hpx::id_type const& id : localities)
×
166
    {
167
        HPX_TEST(!hpx::expect_exception());
×
168

169
        HPX_TEST(!test_get_ptr1(id));
×
170
        HPX_TEST(!test_get_ptr2(id));
×
171
        HPX_TEST(!test_get_ptr3(id));
×
172
        HPX_TEST(!test_get_ptr4(id));
×
173

174
        HPX_TEST(hpx::expect_exception(false));
×
175
    }
176

177
    return hpx::util::report_errors();
×
178
}
×
179
#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