winlin

add reload utest.

... ... @@ -489,7 +489,8 @@ fi
#
# utest, the unit-test cases of srs, base on gtest1.6
MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol"
"srs_utest_kernel" "srs_utest_core" "srs_utest_config")
"srs_utest_kernel" "srs_utest_core" "srs_utest_config"
"srs_utest_reload")
ModuleLibIncs=(${SRS_OBJS} ${LibSTRoot})
ModuleLibFiles=(${LibSTfile} ${LibHttpParserfile} ${LibSSLfile})
MODULE_DEPENDS=("CORE" "KERNEL" "RTMP" "APP")
... ...
... ... @@ -86,7 +86,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// so we remove the srs_freepa utility.
/**
* disable copy constructor of class
* disable copy constructor of class,
* to avoid the memory leak or corrupt by copy instance.
*/
#define disable_default_copy(className)\
private:\
... ...
... ... @@ -101,6 +101,11 @@ int main(int argc, char** argv)
srs_trace("arm tool chain: "SRS_AUTO_EMBEDED_TOOL_CHAIN);
#endif
/**
* we do nothing in the constructor of server,
* and use initialize to create members, set hooks for instance the reload handler,
* all initialize will done in this stage.
*/
if ((ret = _srs_server->initialize()) != ERROR_SUCCESS) {
return ret;
}
... ...
... ... @@ -125,6 +125,8 @@ file
..\utest\srs_utest_kernel.cpp,
..\utest\srs_utest_protocol.hpp,
..\utest\srs_utest_protocol.cpp,
..\utest\srs_utest_reload.hpp,
..\utest\srs_utest_reload.cpp,
research readonly separator,
..\..\research\librtmp\srs_bandwidth_check.c,
..\..\research\librtmp\srs_detect_rtmp.c,
... ... @@ -140,4 +142,3 @@ file
mainconfig
"" = "MAIN";
... ...
... ... @@ -33,6 +33,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_log.hpp>
// enable all utest.
#if 1
#define ENABLE_UTEST_AMF0
#define ENABLE_UTEST_CONFIG
#define ENABLE_UTEST_CORE
#define ENABLE_UTEST_KERNEL
#define ENABLE_UTEST_PROTOCOL
#define ENABLE_UTEST_RELOAD
#endif
// disable some for fast dev, compile and startup.
#if 1
#undef ENABLE_UTEST_AMF0
#undef ENABLE_UTEST_CONFIG
#undef ENABLE_UTEST_CORE
#undef ENABLE_UTEST_KERNEL
#undef ENABLE_UTEST_PROTOCOL
#undef ENABLE_UTEST_RELOAD
#endif
// we add an empty macro for upp to show the smart tips.
#define VOID
... ...
... ... @@ -22,6 +22,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_amf0.hpp>
#ifdef ENABLE_UTEST_AMF0
#include <string>
using namespace std;
... ... @@ -1269,3 +1271,5 @@ VOID TEST(ProtocolAMF0Test, ObjectEcmaStrict)
EXPECT_EQ(0, arr3->to_ecma_array()->count());
}
#endif
... ...
... ... @@ -29,6 +29,47 @@ using namespace std;
#include <srs_kernel_error.hpp>
#include <srs_app_source.hpp>
MockSrsConfigBuffer::MockSrsConfigBuffer(string buf)
{
// read all.
int filesize = (int)buf.length();
if (filesize <= 0) {
return;
}
// create buffer
pos = last = start = new char[filesize];
end = start + filesize;
memcpy(start, buf.data(), filesize);
}
MockSrsConfigBuffer::~MockSrsConfigBuffer()
{
}
int MockSrsConfigBuffer::fullfill(const char* /*filename*/)
{
return ERROR_SUCCESS;
}
MockSrsConfig::MockSrsConfig()
{
}
MockSrsConfig::~MockSrsConfig()
{
}
int MockSrsConfig::parse(string buf)
{
MockSrsConfigBuffer buffer(buf);
return parse_buffer(&buffer);
}
#ifdef ENABLE_UTEST_CONFIG
#define _MIN_OK_CONF "listen 1935; "
// full.conf
... ... @@ -993,45 +1034,6 @@ std::string __full_conf = ""
"} \n"
;
MockSrsConfigBuffer::MockSrsConfigBuffer(string buf)
{
// read all.
int filesize = (int)buf.length();
if (filesize <= 0) {
return;
}
// create buffer
pos = last = start = new char[filesize];
end = start + filesize;
memcpy(start, buf.data(), filesize);
}
MockSrsConfigBuffer::~MockSrsConfigBuffer()
{
}
int MockSrsConfigBuffer::fullfill(const char* /*filename*/)
{
return ERROR_SUCCESS;
}
MockSrsConfig::MockSrsConfig()
{
}
MockSrsConfig::~MockSrsConfig()
{
}
int MockSrsConfig::parse(string buf)
{
MockSrsConfigBuffer buffer(buf);
return parse_buffer(&buffer);
}
VOID TEST(ConfigTest, CheckMacros)
{
#ifndef SRS_CONSTS_LOCALHOST
... ... @@ -5452,3 +5454,5 @@ VOID TEST(ConfigMainTest, CheckConf_pithy_print)
}
}
#endif
... ...
... ... @@ -22,6 +22,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_core.hpp>
#ifdef ENABLE_UTEST_CORE
using namespace std;
#include <srs_core_autofree.hpp>
... ... @@ -67,3 +69,5 @@ VOID TEST(CoreMacroseTest, Check)
#endif
}
#endif
... ...
... ... @@ -199,6 +199,8 @@ int MockBufferReader::read(void* buf, size_t size, ssize_t* nread)
return ERROR_SUCCESS;
}
#ifdef ENABLE_UTEST_KERNEL
VOID TEST(KernelBufferTest, DefaultObject)
{
SrsBuffer b;
... ... @@ -1510,3 +1512,5 @@ VOID TEST(KernelUtilityTest, UtilityString)
EXPECT_TRUE(srs_string_ends_with("Hello", "lo"));
}
#endif
... ...
... ... @@ -203,6 +203,8 @@ int MockBufferIO::read(void* buf, size_t size, ssize_t* nread)
return ERROR_SUCCESS;
}
#ifdef ENABLE_UTEST_PROTOCOL
#ifdef SRS_AUTO_SSL
// verify the sha256
... ... @@ -5598,4 +5600,5 @@ VOID TEST(ProtocolRTMPTest, RTMPHandshakeBytes)
EXPECT_TRUE(bytes.s0s1s2 != NULL);
}
#endif
... ...
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_reload.hpp>
#ifdef ENABLE_UTEST_RELOAD
#endif
... ...
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_UTEST_RELOAD_HPP
#define SRS_UTEST_RELOAD_HPP
/*
#include <srs_utest_reload.hpp>
*/
#include <srs_core.hpp>
#endif
... ...