mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
refine utest, move the mock io to handshake where actually use it.
This commit is contained in:
parent
94cf0c1069
commit
7c7920698d
4 changed files with 91 additions and 91 deletions
|
@ -36,67 +36,6 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext();
|
||||||
SrsConfig* _srs_config = NULL;
|
SrsConfig* _srs_config = NULL;
|
||||||
SrsServer* _srs_server = NULL;
|
SrsServer* _srs_server = NULL;
|
||||||
|
|
||||||
MockEmptyIO::MockEmptyIO()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MockEmptyIO::~MockEmptyIO()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MockEmptyIO::is_never_timeout(int64_t /*timeout_us*/)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MockEmptyIO::read_fully(void* /*buf*/, size_t /*size*/, ssize_t* /*nread*/)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MockEmptyIO::write(void* /*buf*/, size_t /*size*/, ssize_t* /*nwrite*/)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MockEmptyIO::set_recv_timeout(int64_t /*timeout_us*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t MockEmptyIO::get_recv_timeout()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t MockEmptyIO::get_recv_bytes()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MockEmptyIO::set_send_timeout(int64_t /*timeout_us*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t MockEmptyIO::get_send_timeout()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t MockEmptyIO::get_send_bytes()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MockEmptyIO::writev(const iovec */*iov*/, int /*iov_size*/, ssize_t* /*nwrite*/)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MockEmptyIO::read(void* /*buf*/, size_t /*size*/, ssize_t* /*nread*/)
|
|
||||||
{
|
|
||||||
return ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// basic test and samples.
|
// basic test and samples.
|
||||||
VOID TEST(SampleTest, FastSampleInt64Test)
|
VOID TEST(SampleTest, FastSampleInt64Test)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,34 +49,4 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual): Tests that two double values are almost equal.
|
// * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual): Tests that two double values are almost equal.
|
||||||
// * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error): Tests that v1 and v2 are within the given distance to each other.
|
// * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error): Tests that v1 and v2 are within the given distance to each other.
|
||||||
|
|
||||||
#include <srs_protocol_io.hpp>
|
|
||||||
|
|
||||||
class MockEmptyIO : public ISrsProtocolReaderWriter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MockEmptyIO();
|
|
||||||
virtual ~MockEmptyIO();
|
|
||||||
// for protocol
|
|
||||||
public:
|
|
||||||
virtual bool is_never_timeout(int64_t timeout_us);
|
|
||||||
// for handshake.
|
|
||||||
public:
|
|
||||||
virtual int read_fully(void* buf, size_t size, ssize_t* nread);
|
|
||||||
virtual int write(void* buf, size_t size, ssize_t* nwrite);
|
|
||||||
// for protocol
|
|
||||||
public:
|
|
||||||
virtual void set_recv_timeout(int64_t timeout_us);
|
|
||||||
virtual int64_t get_recv_timeout();
|
|
||||||
virtual int64_t get_recv_bytes();
|
|
||||||
// for protocol
|
|
||||||
public:
|
|
||||||
virtual void set_send_timeout(int64_t timeout_us);
|
|
||||||
virtual int64_t get_send_timeout();
|
|
||||||
virtual int64_t get_send_bytes();
|
|
||||||
virtual int writev(const iovec *iov, int iov_size, ssize_t* nwrite);
|
|
||||||
// for protocol/amf0/msg-codec
|
|
||||||
public:
|
|
||||||
virtual int read(void* buf, size_t size, ssize_t* nread);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,67 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_core_autofree.hpp>
|
#include <srs_core_autofree.hpp>
|
||||||
#include <srs_protocol_utility.hpp>
|
#include <srs_protocol_utility.hpp>
|
||||||
|
|
||||||
|
MockEmptyIO::MockEmptyIO()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MockEmptyIO::~MockEmptyIO()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MockEmptyIO::is_never_timeout(int64_t /*timeout_us*/)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MockEmptyIO::read_fully(void* /*buf*/, size_t /*size*/, ssize_t* /*nread*/)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MockEmptyIO::write(void* /*buf*/, size_t /*size*/, ssize_t* /*nwrite*/)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MockEmptyIO::set_recv_timeout(int64_t /*timeout_us*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t MockEmptyIO::get_recv_timeout()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t MockEmptyIO::get_recv_bytes()
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MockEmptyIO::set_send_timeout(int64_t /*timeout_us*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t MockEmptyIO::get_send_timeout()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t MockEmptyIO::get_send_bytes()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MockEmptyIO::writev(const iovec */*iov*/, int /*iov_size*/, ssize_t* /*nwrite*/)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MockEmptyIO::read(void* /*buf*/, size_t /*size*/, ssize_t* /*nread*/)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SRS_AUTO_SSL
|
#ifdef SRS_AUTO_SSL
|
||||||
|
|
||||||
// verify the sha256
|
// verify the sha256
|
||||||
|
|
|
@ -36,4 +36,34 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
using namespace srs;
|
using namespace srs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <srs_protocol_io.hpp>
|
||||||
|
|
||||||
|
class MockEmptyIO : public ISrsProtocolReaderWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MockEmptyIO();
|
||||||
|
virtual ~MockEmptyIO();
|
||||||
|
// for protocol
|
||||||
|
public:
|
||||||
|
virtual bool is_never_timeout(int64_t timeout_us);
|
||||||
|
// for handshake.
|
||||||
|
public:
|
||||||
|
virtual int read_fully(void* buf, size_t size, ssize_t* nread);
|
||||||
|
virtual int write(void* buf, size_t size, ssize_t* nwrite);
|
||||||
|
// for protocol
|
||||||
|
public:
|
||||||
|
virtual void set_recv_timeout(int64_t timeout_us);
|
||||||
|
virtual int64_t get_recv_timeout();
|
||||||
|
virtual int64_t get_recv_bytes();
|
||||||
|
// for protocol
|
||||||
|
public:
|
||||||
|
virtual void set_send_timeout(int64_t timeout_us);
|
||||||
|
virtual int64_t get_send_timeout();
|
||||||
|
virtual int64_t get_send_bytes();
|
||||||
|
virtual int writev(const iovec *iov, int iov_size, ssize_t* nwrite);
|
||||||
|
// for protocol/amf0/msg-codec
|
||||||
|
public:
|
||||||
|
virtual int read(void* buf, size_t size, ssize_t* nread);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue