mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Support MIPS 64bits for loongson 3A4000/3B3000. v5.0.34
This commit is contained in:
parent
aba6667357
commit
1589858cb0
16 changed files with 543 additions and 185 deletions
114
trunk/3rdparty/st-srs/utest/st_utest.cpp
vendored
114
trunk/3rdparty/st-srs/utest/st_utest.cpp
vendored
|
@ -6,6 +6,14 @@
|
|||
#include <st.h>
|
||||
#include <assert.h>
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const ErrorObject* err) {
|
||||
if (!err) return out;
|
||||
if (err->r0_) out << "r0=" << err->r0_;
|
||||
if (err->errno_) out << ", errno=" << err->errno_;
|
||||
if (!err->message_.empty()) out << ", msg=" << err->message_;
|
||||
return out;
|
||||
}
|
||||
|
||||
// We could do something in the main of utest.
|
||||
// Copy from gtest-1.6.0/src/gtest_main.cc
|
||||
GTEST_API_ int main(int argc, char **argv) {
|
||||
|
@ -25,7 +33,7 @@ GTEST_API_ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
// basic test and samples.
|
||||
VOID TEST(SampleTest, FastSampleInt64Test)
|
||||
VOID TEST(SampleTest, ExampleIntSizeTest)
|
||||
{
|
||||
EXPECT_EQ(1, (int)sizeof(int8_t));
|
||||
EXPECT_EQ(2, (int)sizeof(int16_t));
|
||||
|
@ -33,107 +41,3 @@ VOID TEST(SampleTest, FastSampleInt64Test)
|
|||
EXPECT_EQ(8, (int)sizeof(int64_t));
|
||||
}
|
||||
|
||||
void* pfn_coroutine(void* /*arg*/)
|
||||
{
|
||||
st_usleep(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID TEST(SampleTest, StartCoroutine)
|
||||
{
|
||||
st_thread_t trd = st_thread_create(pfn_coroutine, NULL, 1, 0);
|
||||
EXPECT_TRUE(trd != NULL);
|
||||
|
||||
// Wait for joinable coroutine to quit.
|
||||
st_thread_join(trd, NULL);
|
||||
}
|
||||
|
||||
VOID TEST(SampleTest, StartCoroutineX3)
|
||||
{
|
||||
st_thread_t trd0 = st_thread_create(pfn_coroutine, NULL, 1, 0);
|
||||
st_thread_t trd1 = st_thread_create(pfn_coroutine, NULL, 1, 0);
|
||||
st_thread_t trd2 = st_thread_create(pfn_coroutine, NULL, 1, 0);
|
||||
EXPECT_TRUE(trd0 != NULL && trd1 != NULL && trd2 != NULL);
|
||||
|
||||
// Wait for joinable coroutine to quit.
|
||||
st_thread_join(trd1, NULL);
|
||||
st_thread_join(trd2, NULL);
|
||||
st_thread_join(trd0, NULL);
|
||||
}
|
||||
|
||||
void* pfn_coroutine_add(void* arg)
|
||||
{
|
||||
int v = 0;
|
||||
int* pi = (int*)arg;
|
||||
|
||||
// Load the change of arg.
|
||||
while (v != *pi) {
|
||||
v = *pi;
|
||||
st_usleep(0);
|
||||
}
|
||||
|
||||
// Add with const.
|
||||
v += 100;
|
||||
*pi = v;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID TEST(SampleTest, StartCoroutineAdd)
|
||||
{
|
||||
int v = 0;
|
||||
st_thread_t trd = st_thread_create(pfn_coroutine_add, &v, 1, 0);
|
||||
EXPECT_TRUE(trd != NULL);
|
||||
|
||||
// Wait for joinable coroutine to quit.
|
||||
st_thread_join(trd, NULL);
|
||||
|
||||
EXPECT_EQ(100, v);
|
||||
}
|
||||
|
||||
VOID TEST(SampleTest, StartCoroutineAddX3)
|
||||
{
|
||||
int v = 0;
|
||||
st_thread_t trd0 = st_thread_create(pfn_coroutine_add, &v, 1, 0);
|
||||
st_thread_t trd1 = st_thread_create(pfn_coroutine_add, &v, 1, 0);
|
||||
st_thread_t trd2 = st_thread_create(pfn_coroutine_add, &v, 1, 0);
|
||||
EXPECT_TRUE(trd0 != NULL && trd1 != NULL && trd2 != NULL);
|
||||
|
||||
// Wait for joinable coroutine to quit.
|
||||
st_thread_join(trd0, NULL);
|
||||
st_thread_join(trd1, NULL);
|
||||
st_thread_join(trd2, NULL);
|
||||
|
||||
EXPECT_EQ(300, v);
|
||||
}
|
||||
|
||||
int pfn_coroutine_params_x4(int a, int b, int c, int d)
|
||||
{
|
||||
int e = 0;
|
||||
|
||||
st_usleep(0);
|
||||
|
||||
e += a + b + c + d;
|
||||
e += 100;
|
||||
return e;
|
||||
}
|
||||
|
||||
void* pfn_coroutine_params(void* arg)
|
||||
{
|
||||
int r0 = pfn_coroutine_params_x4(1, 2, 3, 4);
|
||||
*(int*)arg = r0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID TEST(SampleTest, StartCoroutineParams)
|
||||
{
|
||||
int r0 = 0;
|
||||
st_thread_t trd = st_thread_create(pfn_coroutine_params, &r0, 1, 0);
|
||||
EXPECT_TRUE(trd != NULL);
|
||||
|
||||
// Wait for joinable coroutine to quit.
|
||||
st_thread_join(trd, NULL);
|
||||
|
||||
EXPECT_EQ(110, r0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue