Skip to content

Commit e237194

Browse files
authored
Merge pull request #8733 from cmonr/rollup
Rollup PR: Resume testing on PRs with false failures
2 parents aab3ade + 4a5ba7f commit e237194

File tree

12 files changed

+4535
-1193
lines changed

12 files changed

+4535
-1193
lines changed

UNITTESTS/features/netsocket/InternetSocket/test_InternetSocket.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ extern std::list<uint32_t> eventFlagsStubNextRetval;
2424
// InternetSocket is an abstract class, so we have to test it via its child.
2525
class stubInternetSocket : public InternetSocket {
2626
protected:
27-
nsapi_error_t return_value = 0;
27+
nsapi_error_t return_value;
2828
public:
29+
stubInternetSocket() {
30+
return_value = 0;
31+
}
2932
virtual nsapi_error_t connect(const SocketAddress &address)
3033
{
34+
_remote_peer = address;
3135
return return_value;
3236
}
3337
virtual nsapi_size_or_error_t send(const void *data, nsapi_size_t size)
@@ -227,3 +231,25 @@ TEST_F(TestInternetSocket, sigio)
227231
socket->close(); // Trigger event;
228232
EXPECT_EQ(callback_is_called, true);
229233
}
234+
235+
TEST_F(TestInternetSocket, getpeername)
236+
{
237+
SocketAddress peer;
238+
SocketAddress zero;
239+
240+
stack.return_value = NSAPI_ERROR_OK;
241+
242+
EXPECT_EQ(socket->getpeername(&peer), NSAPI_ERROR_NO_SOCKET);
243+
244+
socket->open((NetworkStack *)&stack);
245+
socket->connect(zero);
246+
247+
EXPECT_EQ(socket->getpeername(&peer), NSAPI_ERROR_NO_CONNECTION);
248+
249+
const nsapi_addr_t saddr = {NSAPI_IPv4, {192, 168, 0, 1} };
250+
const SocketAddress remote(saddr, 1024);
251+
socket->connect(remote);
252+
253+
EXPECT_EQ(socket->getpeername(&peer), NSAPI_ERROR_OK);
254+
EXPECT_EQ(remote, peer);
255+
}

UNITTESTS/stubs/NetworkStack_stub.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
class NetworkStackstub : public NetworkStack {
2525
public:
2626
std::list<nsapi_error_t> return_values;
27-
nsapi_error_t return_value = 0;
27+
nsapi_error_t return_value;
28+
29+
NetworkStackstub() {
30+
return_value = 0;
31+
}
32+
2833
virtual const char *get_ip_address()
2934
{
3035
return "127.0.0.1";

features/netsocket/InternetSocket.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,15 @@ void InternetSocket::attach(Callback<void()> callback)
214214
{
215215
sigio(callback);
216216
}
217+
218+
nsapi_error_t InternetSocket::getpeername(SocketAddress *address)
219+
{
220+
if (!_socket) {
221+
return NSAPI_ERROR_NO_SOCKET;
222+
}
223+
if (!_remote_peer) {
224+
return NSAPI_ERROR_NO_CONNECTION;
225+
}
226+
*address = _remote_peer;
227+
return NSAPI_ERROR_OK;
228+
}

features/netsocket/InternetSocket.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ class InternetSocket : public Socket {
117117
*/
118118
virtual void sigio(mbed::Callback<void()> func);
119119

120+
/** @copydoc Socket::getpeername
121+
*/
122+
virtual nsapi_error_t getpeername(SocketAddress *address);
123+
120124
/** Register a callback on state change of the socket.
121125
*
122126
* @see Socket::sigio

features/netsocket/Socket.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ class Socket {
254254
* @return NSAPI_ERROR_OK on success, negative error code on failure
255255
*/
256256
virtual nsapi_error_t listen(int backlog = 1) = 0;
257+
258+
/** Get the remote-end peer associated with this socket.
259+
*
260+
* Copy the remote peer address to a SocketAddress structure pointed by
261+
* address parameter. Socket must be connected to have a peer address
262+
* associated.
263+
*
264+
* @param address Pointer to SocketAddress structure.
265+
* @return NSAPI_ERROR_OK on success, negative error code on failure.
266+
*/
267+
virtual nsapi_error_t getpeername(SocketAddress *address) = 0;
257268
};
258269

259270

features/netsocket/TLSSocketWrapper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,4 +577,12 @@ nsapi_error_t TLSSocketWrapper::listen(int)
577577
return NSAPI_ERROR_UNSUPPORTED;
578578
}
579579

580+
nsapi_error_t TLSSocketWrapper::getpeername(SocketAddress *address)
581+
{
582+
if (!_handshake_completed) {
583+
return NSAPI_ERROR_NO_CONNECTION;
584+
}
585+
return _transport->getpeername(address);
586+
}
587+
580588
#endif /* MBEDTLS_SSL_CLI_C */

features/netsocket/TLSSocketWrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class TLSSocketWrapper : public Socket {
132132
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen);
133133
virtual Socket *accept(nsapi_error_t *error = NULL);
134134
virtual nsapi_error_t listen(int backlog = 1);
135+
virtual nsapi_error_t getpeername(SocketAddress *address);
135136

136137
#if defined(MBEDTLS_X509_CRT_PARSE_C) || defined(DOXYGEN)
137138
/** Get own certificate directly from Mbed TLS

targets/TARGET_ARM_FM/TARGET_FVP_MPS2/flash_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include "string.h"
1718
#include "device.h"
1819
#include "flash_api.h"
1920
#include "memory_zones.h"
@@ -22,7 +23,7 @@
2223
* The implementation emulates flash over SRAM.
2324
*/
2425

25-
#define FLASH_PAGE_SIZE 256
26+
#define FLASH_PAGE_SIZE 4U
2627
#define FLASH_OFS_START ZBT_SRAM1_START
2728
#define FLASH_SECTOR_SIZE 0x1000
2829
#define FLASH_OFS_END (ZBT_SRAM1_START + ZBT_SRAM1_SIZE)

0 commit comments

Comments
 (0)