Merge pull request #8733 from cmonr/rollup

Rollup PR: Resume testing on PRs with false failures
pull/8680/head
Martin Kojtal 2018-11-14 08:17:27 +00:00 committed by GitHub
commit e237194c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 4535 additions and 1193 deletions

View File

@ -24,10 +24,14 @@ extern std::list<uint32_t> eventFlagsStubNextRetval;
// InternetSocket is an abstract class, so we have to test it via its child.
class stubInternetSocket : public InternetSocket {
protected:
nsapi_error_t return_value = 0;
nsapi_error_t return_value;
public:
stubInternetSocket() {
return_value = 0;
}
virtual nsapi_error_t connect(const SocketAddress &address)
{
_remote_peer = address;
return return_value;
}
virtual nsapi_size_or_error_t send(const void *data, nsapi_size_t size)
@ -227,3 +231,25 @@ TEST_F(TestInternetSocket, sigio)
socket->close(); // Trigger event;
EXPECT_EQ(callback_is_called, true);
}
TEST_F(TestInternetSocket, getpeername)
{
SocketAddress peer;
SocketAddress zero;
stack.return_value = NSAPI_ERROR_OK;
EXPECT_EQ(socket->getpeername(&peer), NSAPI_ERROR_NO_SOCKET);
socket->open((NetworkStack *)&stack);
socket->connect(zero);
EXPECT_EQ(socket->getpeername(&peer), NSAPI_ERROR_NO_CONNECTION);
const nsapi_addr_t saddr = {NSAPI_IPv4, {192, 168, 0, 1} };
const SocketAddress remote(saddr, 1024);
socket->connect(remote);
EXPECT_EQ(socket->getpeername(&peer), NSAPI_ERROR_OK);
EXPECT_EQ(remote, peer);
}

View File

@ -24,7 +24,12 @@
class NetworkStackstub : public NetworkStack {
public:
std::list<nsapi_error_t> return_values;
nsapi_error_t return_value = 0;
nsapi_error_t return_value;
NetworkStackstub() {
return_value = 0;
}
virtual const char *get_ip_address()
{
return "127.0.0.1";

View File

@ -214,3 +214,15 @@ void InternetSocket::attach(Callback<void()> callback)
{
sigio(callback);
}
nsapi_error_t InternetSocket::getpeername(SocketAddress *address)
{
if (!_socket) {
return NSAPI_ERROR_NO_SOCKET;
}
if (!_remote_peer) {
return NSAPI_ERROR_NO_CONNECTION;
}
*address = _remote_peer;
return NSAPI_ERROR_OK;
}

View File

@ -117,6 +117,10 @@ public:
*/
virtual void sigio(mbed::Callback<void()> func);
/** @copydoc Socket::getpeername
*/
virtual nsapi_error_t getpeername(SocketAddress *address);
/** Register a callback on state change of the socket.
*
* @see Socket::sigio

View File

@ -254,6 +254,17 @@ public:
* @return NSAPI_ERROR_OK on success, negative error code on failure
*/
virtual nsapi_error_t listen(int backlog = 1) = 0;
/** Get the remote-end peer associated with this socket.
*
* Copy the remote peer address to a SocketAddress structure pointed by
* address parameter. Socket must be connected to have a peer address
* associated.
*
* @param address Pointer to SocketAddress structure.
* @return NSAPI_ERROR_OK on success, negative error code on failure.
*/
virtual nsapi_error_t getpeername(SocketAddress *address) = 0;
};

View File

@ -577,4 +577,12 @@ nsapi_error_t TLSSocketWrapper::listen(int)
return NSAPI_ERROR_UNSUPPORTED;
}
nsapi_error_t TLSSocketWrapper::getpeername(SocketAddress *address)
{
if (!_handshake_completed) {
return NSAPI_ERROR_NO_CONNECTION;
}
return _transport->getpeername(address);
}
#endif /* MBEDTLS_SSL_CLI_C */

View File

@ -132,6 +132,7 @@ public:
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen);
virtual Socket *accept(nsapi_error_t *error = NULL);
virtual nsapi_error_t listen(int backlog = 1);
virtual nsapi_error_t getpeername(SocketAddress *address);
#if defined(MBEDTLS_X509_CRT_PARSE_C) || defined(DOXYGEN)
/** Get own certificate directly from Mbed TLS

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "string.h"
#include "device.h"
#include "flash_api.h"
#include "memory_zones.h"
@ -22,7 +23,7 @@
* The implementation emulates flash over SRAM.
*/
#define FLASH_PAGE_SIZE 256
#define FLASH_PAGE_SIZE 4U
#define FLASH_OFS_START ZBT_SRAM1_START
#define FLASH_SECTOR_SIZE 0x1000
#define FLASH_OFS_END (ZBT_SRAM1_START + ZBT_SRAM1_SIZE)

View File

@ -134,12 +134,4 @@ void flash_set_target_config(flash_t *obj)
}
#endif // #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
MBED_NONSECURE_ENTRY uint8_t flash_get_erase_value(const flash_t *obj)
{
(void)obj;
return 0xFF;
}
#endif // #if DEVICE_FLASH

File diff suppressed because it is too large Load Diff