1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/3rdparty/st-srs/tools/verify/verify.c

65 lines
1.2 KiB
C
Raw Normal View History

2021-10-02 00:54:53 +00:00
/* SPDX-License-Identifier: MIT */
2023-01-01 00:45:39 +00:00
/* Copyright (c) 2013-2023 Winlin */
2021-10-02 00:54:53 +00:00
#include <stdio.h>
#include <st.h>
#include <assert.h>
2021-10-02 00:54:53 +00:00
st_mutex_t lock;
st_cond_t cond;
2021-10-02 00:54:53 +00:00
void* start(void* arg)
2021-10-02 00:54:53 +00:00
{
printf("ST: thread run\n");
2021-10-02 00:54:53 +00:00
printf("ST: thread wait for a while\n");
st_usleep(1.5 * 1000 * 1000);
printf("ST: thread wait done\n");
2021-10-02 00:54:53 +00:00
int r0 = st_cond_signal(cond);
printf("ST: thread cond signal, r0=%d\n", r0);
printf("ST: thread lock\n");
r0 = st_mutex_lock(lock);
assert(r0 == 0);
r0 = st_mutex_unlock(lock);
printf("ST: thread unlock\n");
return NULL;
2021-10-02 00:54:53 +00:00
}
int main(int argc, char** argv)
2021-10-02 00:54:53 +00:00
{
int r0 = st_init();
assert(r0 == 0);
printf("ST: main init ok\n");
lock = st_mutex_new();
cond = st_cond_new();
st_thread_t trd = st_thread_create(start, NULL, 1, 0);
printf("ST: main create ok\n");
2021-10-02 00:54:53 +00:00
printf("ST: main lock\n");
r0 = st_mutex_lock(lock);
assert(r0 == 0);
2021-10-02 00:54:53 +00:00
printf("ST: main cond waiting\n");
r0 = st_cond_wait(cond);
printf("ST: main cond wait ok, r0=%d\n", r0);
2021-10-02 00:54:53 +00:00
r0 = st_mutex_unlock(lock);
printf("ST: main unlock\n");
st_thread_join(trd, NULL);
printf("ST: main done\n");
st_mutex_destroy(lock);
st_cond_destroy(cond);
return 0;
2021-10-02 00:54:53 +00:00
}