Skip to content

Commit 3771b0d

Browse files
authored
Improved coverage remotery (#467)
Signed-off-by: ahcorde <[email protected]>
1 parent 1157051 commit 3771b0d

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

profiler/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ set(
1010
Profiler_Disabled_TEST.cc
1111
)
1212

13+
if(NOT WIN32)
14+
list(APPEND PROFILER_TESTS Profiler_Error_TEST.cc)
15+
endif()
16+
1317
if(IGN_PROFILER_REMOTERY)
1418
set(
1519
Remotery_SRC
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright (C) 2022 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
#include "gz/common/Profiler.hh" // NOLINT(*)
19+
#include <gtest/gtest.h> // NOLINT(*)
20+
#include "Remotery/lib/Remotery.h"
21+
22+
#include <gz/common/Export.hh>
23+
24+
/// Return the string error message
25+
/// param[in] error the remotery error
26+
std::string rmtErrorToString(rmtError error);
27+
28+
/////////////////////////////////////////////////
29+
TEST(Profiler, ProfilerErrorCodes)
30+
{
31+
EXPECT_EQ("none", rmtErrorToString(RMT_ERROR_NONE));
32+
EXPECT_EQ("Not an error but an internal message to calling code",
33+
rmtErrorToString(RMT_ERROR_RECURSIVE_SAMPLE));
34+
35+
EXPECT_EQ("Malloc call within remotery failed",
36+
rmtErrorToString(RMT_ERROR_MALLOC_FAIL));
37+
EXPECT_EQ("Attempt to allocate thread local storage failed",
38+
rmtErrorToString(RMT_ERROR_TLS_ALLOC_FAIL));
39+
EXPECT_EQ("Failed to create a virtual memory mirror buffer",
40+
rmtErrorToString(RMT_ERROR_VIRTUAL_MEMORY_BUFFER_FAIL));
41+
EXPECT_EQ("Failed to create a thread for the server",
42+
rmtErrorToString(RMT_ERROR_CREATE_THREAD_FAIL));
43+
44+
EXPECT_EQ("Network initialisation failure (e.g. on Win32, WSAStartup fails)",
45+
rmtErrorToString(RMT_ERROR_SOCKET_INIT_NETWORK_FAIL));
46+
EXPECT_EQ("Can't create a socket for connection to the remote viewer",
47+
rmtErrorToString(RMT_ERROR_SOCKET_CREATE_FAIL));
48+
EXPECT_EQ("Can't bind a socket for the server",
49+
rmtErrorToString(RMT_ERROR_SOCKET_BIND_FAIL));
50+
EXPECT_EQ("Created server socket failed to enter a listen state",
51+
rmtErrorToString(RMT_ERROR_SOCKET_LISTEN_FAIL));
52+
EXPECT_EQ("Created server socket failed to switch to a non-blocking state",
53+
rmtErrorToString(RMT_ERROR_SOCKET_SET_NON_BLOCKING_FAIL));
54+
EXPECT_EQ("Poll attempt on an invalid socket",
55+
rmtErrorToString(RMT_ERROR_SOCKET_INVALID_POLL));
56+
EXPECT_EQ("Server failed to call select on socket",
57+
rmtErrorToString(RMT_ERROR_SOCKET_SELECT_FAIL));
58+
EXPECT_EQ("Poll notified that the socket has errors",
59+
rmtErrorToString(RMT_ERROR_SOCKET_POLL_ERRORS));
60+
EXPECT_EQ("Server failed to accept connection from client",
61+
rmtErrorToString(RMT_ERROR_SOCKET_ACCEPT_FAIL));
62+
EXPECT_EQ("Timed out trying to send data",
63+
rmtErrorToString(RMT_ERROR_SOCKET_SEND_TIMEOUT));
64+
EXPECT_EQ("Unrecoverable error occured while client/server tried to send data", //NOLINT
65+
rmtErrorToString(RMT_ERROR_SOCKET_SEND_FAIL));
66+
EXPECT_EQ("No data available when attempting a receive",
67+
rmtErrorToString(RMT_ERROR_SOCKET_RECV_NO_DATA));
68+
EXPECT_EQ("Timed out trying to receive data",
69+
rmtErrorToString(RMT_ERROR_SOCKET_RECV_TIMEOUT));
70+
EXPECT_EQ("Unrecoverable error occured while client/server tried to receive data", //NOLINT
71+
rmtErrorToString(RMT_ERROR_SOCKET_RECV_FAILED));
72+
73+
EXPECT_EQ("WebSocket server handshake failed, not HTTP GET",
74+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_NOT_GET));
75+
EXPECT_EQ("WebSocket server handshake failed, can't locate WebSocket version",
76+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_NO_VERSION));
77+
EXPECT_EQ("WebSocket server handshake failed, unsupported WebSocket version",
78+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_BAD_VERSION));
79+
EXPECT_EQ("WebSocket server handshake failed, can't locate host",
80+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_NO_HOST));
81+
EXPECT_EQ("WebSocket server handshake failed, host is not allowed to connect",
82+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_BAD_HOST));
83+
EXPECT_EQ("WebSocket server handshake failed, can't locate WebSocket key",
84+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_NO_KEY));
85+
EXPECT_EQ("WebSocket server handshake failed, WebSocket key is ill-formed",
86+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_BAD_KEY));
87+
EXPECT_EQ("WebSocket server handshake failed, internal error, bad string code", //NOLINT
88+
rmtErrorToString(RMT_ERROR_WEBSOCKET_HANDSHAKE_STRING_FAIL));
89+
EXPECT_EQ("WebSocket server received a disconnect request and closed the socket", //NOLINT
90+
rmtErrorToString(RMT_ERROR_WEBSOCKET_DISCONNECTED));
91+
EXPECT_EQ("Couldn't parse WebSocket frame header",
92+
rmtErrorToString(RMT_ERROR_WEBSOCKET_BAD_FRAME_HEADER));
93+
EXPECT_EQ("Partially received wide frame header size",
94+
rmtErrorToString(RMT_ERROR_WEBSOCKET_BAD_FRAME_HEADER_SIZE));
95+
EXPECT_EQ("Partially received frame header data mask",
96+
rmtErrorToString(RMT_ERROR_WEBSOCKET_BAD_FRAME_HEADER_MASK));
97+
EXPECT_EQ("Timeout receiving frame header",
98+
rmtErrorToString(RMT_ERROR_WEBSOCKET_RECEIVE_TIMEOUT));
99+
100+
EXPECT_EQ("Remotery object has not been created",
101+
rmtErrorToString(RMT_ERROR_REMOTERY_NOT_CREATED));
102+
EXPECT_EQ("An attempt was made to send an incomplete profile tree to the client", //NOLINT
103+
rmtErrorToString(RMT_ERROR_SEND_ON_INCOMPLETE_PROFILE));
104+
105+
EXPECT_EQ("This indicates that the CUDA driver is in the process of shutting down", //NOLINT
106+
rmtErrorToString(RMT_ERROR_CUDA_DEINITIALIZED));
107+
EXPECT_EQ("This indicates that the CUDA driver has not been initialized with cuInit() or that initialization has failed", //NOLINT
108+
rmtErrorToString(RMT_ERROR_CUDA_NOT_INITIALIZED));
109+
EXPECT_EQ("This most frequently indicates that there is no context bound to the current thread", //NOLINT
110+
rmtErrorToString(RMT_ERROR_CUDA_INVALID_CONTEXT));
111+
EXPECT_EQ("This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values", //NOLINT
112+
rmtErrorToString(RMT_ERROR_CUDA_INVALID_VALUE));
113+
EXPECT_EQ("This indicates that a resource handle passed to the API call was not valid", //NOLINT
114+
rmtErrorToString(RMT_ERROR_CUDA_INVALID_HANDLE));
115+
EXPECT_EQ("The API call failed because it was unable to allocate enough memory to perform the requested operation", //NOLINT
116+
rmtErrorToString(RMT_ERROR_CUDA_OUT_OF_MEMORY));
117+
EXPECT_EQ("This indicates that a resource handle passed to the API call was not valid", //NOLINT
118+
rmtErrorToString(RMT_ERROR_ERROR_NOT_READY));
119+
120+
EXPECT_EQ("Failed to create query for sample",
121+
rmtErrorToString(RMT_ERROR_D3D11_FAILED_TO_CREATE_QUERY));
122+
123+
EXPECT_EQ("Generic OpenGL error, no need to expose detail since app will need an OpenGL error callback registered", //NOLINT
124+
rmtErrorToString(RMT_ERROR_OPENGL_ERROR));
125+
EXPECT_EQ("Unknown CUDA error",
126+
rmtErrorToString(RMT_ERROR_CUDA_UNKNOWN));
127+
EXPECT_EQ("Unknown remotery error",
128+
rmtErrorToString(static_cast<rmtError>(1000)));
129+
}

0 commit comments

Comments
 (0)