apps: testing: ostest: nxstyle fixes
fixes for errors reported by nxstyle Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
parent
7f0c835edf
commit
e0499fea49
@ -216,7 +216,9 @@ int main(int argc, FAR char *argv[])
|
||||
double iters_per_nsec;
|
||||
double iters_per_msec;
|
||||
uint64_t timer_resolution;
|
||||
double slope_m, slope_b, slope_r2;
|
||||
double slope_m;
|
||||
double slope_b;
|
||||
double slope_r2;
|
||||
int min_step;
|
||||
int loop_count;
|
||||
double duration;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* apps/examples/¨usrsocktest/usrsocktest_basic_connect.c
|
||||
* apps/examples/usrsocktest/usrsocktest_basic_connect.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -63,7 +63,7 @@ static int sd;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ConnectReceive
|
||||
* Name: connectreceive
|
||||
*
|
||||
* Description:
|
||||
* Non-blocking connect and receive
|
||||
@ -79,7 +79,7 @@ static int sd;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
static void connectreceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
{
|
||||
int flags;
|
||||
int count;
|
||||
@ -121,7 +121,7 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(O_RDWR, flags & O_RDWR);
|
||||
TEST_ASSERT_EQUAL(O_NONBLOCK, flags & O_NONBLOCK);
|
||||
|
||||
/* Poll for input (instant timeout). */
|
||||
/* poll for input (instant timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -144,7 +144,8 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(0, ret);
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_active_sockets());
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_connected_sockets());
|
||||
TEST_ASSERT_EQUAL(0, usrsocktest_daemon_get_num_waiting_connect_sockets());
|
||||
TEST_ASSERT_EQUAL(0,
|
||||
usrsocktest_daemon_get_num_waiting_connect_sockets());
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_recv_empty_sockets());
|
||||
}
|
||||
else
|
||||
@ -154,7 +155,8 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_active_sockets());
|
||||
TEST_ASSERT_EQUAL(0, usrsocktest_daemon_get_num_connected_sockets());
|
||||
|
||||
for (count = 0; usrsocktest_daemon_get_num_connected_sockets() != 1; count++)
|
||||
for (count = 0;
|
||||
usrsocktest_daemon_get_num_connected_sockets() != 1; count++)
|
||||
{
|
||||
TEST_ASSERT_TRUE(count <= 3);
|
||||
usleep(25 * 1000);
|
||||
@ -168,7 +170,7 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_recv_empty_sockets());
|
||||
}
|
||||
|
||||
/* Poll for input (instant timeout). */
|
||||
/* poll for input (instant timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -176,7 +178,7 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
ret = poll(&pfd, 1, 0);
|
||||
TEST_ASSERT_EQUAL(0, ret);
|
||||
|
||||
/* Poll for input (with timeout). */
|
||||
/* poll for input (with timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -184,7 +186,7 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
ret = poll(&pfd, 1, 10);
|
||||
TEST_ASSERT_EQUAL(0, ret);
|
||||
|
||||
/* Poll for input (no timeout). */
|
||||
/* poll for input (no timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -206,7 +208,7 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(3, usrsocktest_daemon_get_recv_bytes());
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_recv_empty_sockets());
|
||||
|
||||
/* Poll for input (instant timeout). */
|
||||
/* poll for input (instant timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -217,14 +219,16 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
/* Make more data avail */
|
||||
|
||||
TEST_ASSERT_TRUE(usrsocktest_send_delayed_command('r', 0));
|
||||
for (count = 0; usrsocktest_daemon_get_num_recv_empty_sockets() > 0; count++)
|
||||
for (count = 0;
|
||||
usrsocktest_daemon_get_num_recv_empty_sockets() > 0; count++)
|
||||
{
|
||||
TEST_ASSERT_TRUE(count <= 3);
|
||||
usleep(5 * 1000);
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL(0, usrsocktest_daemon_get_num_recv_empty_sockets());
|
||||
|
||||
/* Poll for input (no timeout). */
|
||||
/* poll for input (no timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -265,7 +269,7 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ConnectSend
|
||||
* Name: connectsend
|
||||
*
|
||||
* Description:
|
||||
* Non-blocking connect and receive
|
||||
@ -281,7 +285,7 @@ static void ConnectReceive(struct usrsocktest_daemon_conf_s *dconf)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void ConnectSend(struct usrsocktest_daemon_conf_s *dconf)
|
||||
static void connectsend(struct usrsocktest_daemon_conf_s *dconf)
|
||||
{
|
||||
int flags;
|
||||
ssize_t ret;
|
||||
@ -323,7 +327,7 @@ static void ConnectSend(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(O_RDWR, flags & O_RDWR);
|
||||
TEST_ASSERT_EQUAL(O_NONBLOCK, flags & O_NONBLOCK);
|
||||
|
||||
/* Poll for input (instant timeout). */
|
||||
/* poll for input (instant timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -347,8 +351,10 @@ static void ConnectSend(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(0, usrsocktest_daemon_get_num_connected_sockets());
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_waiting_connect_sockets());
|
||||
|
||||
/* Poll for input (no timeout). As send is ready after established connection,
|
||||
* poll will exit with POLLOUT. */
|
||||
/* poll for input (no timeout).
|
||||
* As send is ready after established connection,
|
||||
* poll will exit with POLLOUT.
|
||||
*/
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
TEST_ASSERT_TRUE(usrsocktest_send_delayed_command('E', 100));
|
||||
@ -398,10 +404,10 @@ static void ConnectSend(struct usrsocktest_daemon_conf_s *dconf)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: DaemonAbort
|
||||
* Name: daemonabort
|
||||
*
|
||||
* Description:
|
||||
* Poll with daemon abort
|
||||
* poll with daemon abort
|
||||
*
|
||||
* Input Parameters:
|
||||
* dconf - socket daemon configuration
|
||||
@ -414,7 +420,7 @@ static void ConnectSend(struct usrsocktest_daemon_conf_s *dconf)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void DaemonAbort(struct usrsocktest_daemon_conf_s *dconf)
|
||||
static void daemonabort(struct usrsocktest_daemon_conf_s *dconf)
|
||||
{
|
||||
int flags;
|
||||
ssize_t ret;
|
||||
@ -454,7 +460,7 @@ static void DaemonAbort(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(O_RDWR, flags & O_RDWR);
|
||||
TEST_ASSERT_EQUAL(O_NONBLOCK, flags & O_NONBLOCK);
|
||||
|
||||
/* Poll for input (instant timeout). */
|
||||
/* poll for input (instant timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -478,7 +484,7 @@ static void DaemonAbort(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(0, usrsocktest_daemon_get_num_connected_sockets());
|
||||
TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_waiting_connect_sockets());
|
||||
|
||||
/* Poll for input (no timeout). Stop daemon forcefully. */
|
||||
/* poll for input (no timeout). Stop daemon forcefully. */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
TEST_ASSERT_TRUE(usrsocktest_send_delayed_command('S', 100));
|
||||
@ -498,7 +504,7 @@ static void DaemonAbort(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(0, usrsocktest_endp_malloc_cnt);
|
||||
TEST_ASSERT_EQUAL(0, usrsocktest_dcmd_malloc_cnt);
|
||||
|
||||
/* Poll for input (no timeout). */
|
||||
/* poll for input (no timeout). */
|
||||
|
||||
memset(&pfd, 0, sizeof(pfd));
|
||||
pfd.fd = sd;
|
||||
@ -517,11 +523,12 @@ static void DaemonAbort(struct usrsocktest_daemon_conf_s *dconf)
|
||||
TEST_ASSERT_EQUAL(-ENODEV, usrsocktest_daemon_get_num_active_sockets());
|
||||
TEST_ASSERT_EQUAL(-ENODEV, usrsocktest_daemon_get_num_connected_sockets());
|
||||
TEST_ASSERT_EQUAL(-ENODEV, usrsocktest_daemon_get_send_bytes());
|
||||
TEST_ASSERT_EQUAL(-ENODEV, usrsocktest_daemon_get_num_recv_empty_sockets());
|
||||
TEST_ASSERT_EQUAL(-ENODEV,
|
||||
usrsocktest_daemon_get_num_recv_empty_sockets());
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: Poll test group setup
|
||||
* Name: poll test group setup
|
||||
*
|
||||
* Description:
|
||||
* Setup function executed before each testcase in this test group
|
||||
@ -537,14 +544,14 @@ static void DaemonAbort(struct usrsocktest_daemon_conf_s *dconf)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
TEST_SETUP(Poll)
|
||||
TEST_SETUP(poll)
|
||||
{
|
||||
sd = -1;
|
||||
started = false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: Poll test group teardown
|
||||
* Name: poll test group teardown
|
||||
*
|
||||
* Description:
|
||||
* Setup function executed after each testcase in this test group
|
||||
@ -560,7 +567,7 @@ TEST_SETUP(Poll)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
TEST_TEAR_DOWN(Poll)
|
||||
TEST_TEAR_DOWN(poll)
|
||||
{
|
||||
int ret;
|
||||
if (sd >= 0)
|
||||
@ -568,6 +575,7 @@ TEST_TEAR_DOWN(Poll)
|
||||
ret = close(sd);
|
||||
assert(ret >= 0);
|
||||
}
|
||||
|
||||
if (started)
|
||||
{
|
||||
ret = usrsocktest_daemon_stop();
|
||||
@ -575,55 +583,55 @@ TEST_TEAR_DOWN(Poll)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Poll, ConnectReceive)
|
||||
TEST(poll, connectreceive)
|
||||
{
|
||||
usrsocktest_daemon_config = usrsocktest_daemon_defconf;
|
||||
ConnectReceive(&usrsocktest_daemon_config);
|
||||
connectreceive(&usrsocktest_daemon_config);
|
||||
}
|
||||
|
||||
TEST(Poll, ConnectReceiveDelay)
|
||||
TEST(poll, connectreceivedelay)
|
||||
{
|
||||
usrsocktest_daemon_config = usrsocktest_daemon_defconf;
|
||||
usrsocktest_daemon_config.delay_all_responses = true;
|
||||
ConnectReceive(&usrsocktest_daemon_config);
|
||||
connectreceive(&usrsocktest_daemon_config);
|
||||
}
|
||||
|
||||
TEST(Poll, ConnectSend)
|
||||
TEST(poll, connectsend)
|
||||
{
|
||||
usrsocktest_daemon_config = usrsocktest_daemon_defconf;
|
||||
ConnectSend(&usrsocktest_daemon_config);
|
||||
connectsend(&usrsocktest_daemon_config);
|
||||
}
|
||||
|
||||
TEST(Poll, ConnectSendDelay)
|
||||
TEST(poll, connectsenddelay)
|
||||
{
|
||||
usrsocktest_daemon_config = usrsocktest_daemon_defconf;
|
||||
usrsocktest_daemon_config.delay_all_responses = true;
|
||||
ConnectSend(&usrsocktest_daemon_config);
|
||||
connectsend(&usrsocktest_daemon_config);
|
||||
}
|
||||
|
||||
TEST(Poll, DaemonAbort)
|
||||
TEST(poll, daemonabort)
|
||||
{
|
||||
usrsocktest_daemon_config = usrsocktest_daemon_defconf;
|
||||
DaemonAbort(&usrsocktest_daemon_config);
|
||||
daemonabort(&usrsocktest_daemon_config);
|
||||
}
|
||||
|
||||
TEST(Poll, DaemonAbortDelay)
|
||||
TEST(poll, daemonabortdelay)
|
||||
{
|
||||
usrsocktest_daemon_config = usrsocktest_daemon_defconf;
|
||||
usrsocktest_daemon_config.delay_all_responses = true;
|
||||
DaemonAbort(&usrsocktest_daemon_config);
|
||||
daemonabort(&usrsocktest_daemon_config);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
TEST_GROUP(Poll)
|
||||
TEST_GROUP(poll)
|
||||
{
|
||||
RUN_TEST_CASE(Poll, ConnectReceive);
|
||||
RUN_TEST_CASE(Poll, ConnectReceiveDelay);
|
||||
RUN_TEST_CASE(Poll, ConnectSend);
|
||||
RUN_TEST_CASE(Poll, ConnectSendDelay);
|
||||
RUN_TEST_CASE(Poll, DaemonAbort);
|
||||
RUN_TEST_CASE(Poll, DaemonAbortDelay);
|
||||
RUN_TEST_CASE(poll, connectreceive);
|
||||
RUN_TEST_CASE(poll, connectreceivedelay);
|
||||
RUN_TEST_CASE(poll, connectsend);
|
||||
RUN_TEST_CASE(poll, connectsenddelay);
|
||||
RUN_TEST_CASE(poll, daemonabort);
|
||||
RUN_TEST_CASE(poll, daemonabortdelay);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* usrsocktest/usrsocktest_remote_disconnect.c
|
||||
* apps/usrsocktest/usrsocktest_remote_disconnect.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -67,7 +67,7 @@ static int sd;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ConnectReceive
|
||||
* Name: connectreceive
|
||||
*
|
||||
* Description:
|
||||
* Remote end is unreachable
|
||||
|
@ -54,13 +54,16 @@ static void cleanup(FAR void * data)
|
||||
#ifndef CONFIG_CANCELLATION_POINTS
|
||||
if (status == EPERM)
|
||||
{
|
||||
printf("pthread_cleanup: thread did not have mutex locked: %d\n", status);
|
||||
printf("pthread_cleanup: thread did not have mutex locked: %d\n",
|
||||
status);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_unlock in cleanup handler. "
|
||||
printf("pthread_cleanup:"
|
||||
"ERROR pthread_mutex_unlock in cleanup handler. "
|
||||
"Status: %d\n", status);
|
||||
}
|
||||
}
|
||||
@ -73,18 +76,20 @@ static void *cleanup_thread(FAR void * data)
|
||||
status = pthread_mutex_lock(&sync->lock);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_lock, status=%d\n", status);
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_lock, status=%d\n",
|
||||
status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pthread_cleanup_push(&cleanup, sync);
|
||||
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
status = pthread_cond_wait(&sync->cond, &sync->lock);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR wait returned. Status: %d\n", status);
|
||||
printf("pthread_cleanup: ERROR wait returned. Status: %d\n",
|
||||
status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +129,8 @@ static void test_cleanup(void)
|
||||
}
|
||||
else if (result != PTHREAD_CANCELED)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR pthread_join returned wrong result: %p\n", result);
|
||||
printf("pthread_cleanup: "
|
||||
"ERROR pthread_join returned wrong result: %p\n", result);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CANCELLATION_POINTS
|
||||
@ -133,13 +139,15 @@ static void test_cleanup(void)
|
||||
status = pthread_mutex_trylock(&sync.lock);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_trylock, status=%d\n", status);
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_trylock, status=%d\n",
|
||||
status);
|
||||
}
|
||||
|
||||
status = pthread_mutex_unlock(&sync.lock);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_unlock, status=%d\n", status);
|
||||
printf("pthread_cleanup: ERROR pthread_mutex_unlock, status=%d\n",
|
||||
status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ static void * timeout_thread1(FAR void * data)
|
||||
struct timespec time;
|
||||
int status;
|
||||
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &time);
|
||||
time.tv_sec += 1;
|
||||
@ -54,7 +54,8 @@ static void * timeout_thread1(FAR void * data)
|
||||
status = pthread_rwlock_timedrdlock(sync->write_lock, &time);
|
||||
if (status != ETIMEDOUT)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR Acquired held write_lock. Status: %d\n", status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR Acquired held write_lock. Status: %d\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +76,8 @@ static void * timeout_thread2(FAR void * data)
|
||||
status = pthread_rwlock_timedrdlock(sync->read_lock, &time);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: Failed to acquire read_lock. Status: %d\n", status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"Failed to acquire read_lock. Status: %d\n", status);
|
||||
}
|
||||
|
||||
sched_yield(); /* Not a cancellation point. */
|
||||
@ -85,7 +87,8 @@ static void * timeout_thread2(FAR void * data)
|
||||
status = pthread_rwlock_unlock(sync->read_lock);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: Failed to release read_lock. Status: %d\n", status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"Failed to release read_lock. Status: %d\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,7 +99,8 @@ static void * timeout_thread2(FAR void * data)
|
||||
if (status != ETIMEDOUT)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR Acquired held read_lock for writing. Status: %d\n", status);
|
||||
"ERROR Acquired held read_lock for writing."
|
||||
" Status: %d\n", status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,35 +112,37 @@ static void test_timeout(void)
|
||||
pthread_rwlock_t read_lock;
|
||||
pthread_rwlock_t write_lock;
|
||||
struct sync_s sync;
|
||||
pthread_t thread1, thread2;
|
||||
int status, i;
|
||||
pthread_t thread1;
|
||||
pthread_t thread2;
|
||||
int status;
|
||||
int i;
|
||||
|
||||
status = pthread_rwlock_init(&read_lock, NULL);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_rwlock_init(read_lock), status=%d\n",
|
||||
status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_rwlock_init(read_lock), status=%d\n", status);
|
||||
}
|
||||
|
||||
status = pthread_rwlock_init(&write_lock, NULL);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_rwlock_init(write_lock), status=%d\n",
|
||||
status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_rwlock_init(write_lock), status=%d\n", status);
|
||||
}
|
||||
|
||||
status = pthread_rwlock_rdlock(&read_lock);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_rwlock_rdlock, status=%d\n",
|
||||
status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_rwlock_rdlock, status=%d\n", status);
|
||||
}
|
||||
|
||||
status = pthread_rwlock_wrlock(&write_lock);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_rwlock_wrlock, status=%d\n",
|
||||
status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_rwlock_wrlock, status=%d\n", status);
|
||||
}
|
||||
|
||||
sync.read_lock = &read_lock;
|
||||
@ -145,13 +151,15 @@ static void test_timeout(void)
|
||||
status = pthread_create(&thread1, NULL, timeout_thread1, &sync);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_create, status=%d\n", status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_create, status=%d\n", status);
|
||||
}
|
||||
|
||||
status = pthread_create(&thread2, NULL, timeout_thread2, &sync);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_create, status=%d\n", status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_create, status=%d\n", status);
|
||||
}
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
@ -162,20 +170,23 @@ static void test_timeout(void)
|
||||
status = pthread_cancel(thread1);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_cancel, status=%d\n", status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_cancel, status=%d\n", status);
|
||||
}
|
||||
|
||||
status = pthread_cancel(thread2);
|
||||
if (status != 0)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: ERROR pthread_cancel, status=%d\n", status);
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR pthread_cancel, status=%d\n", status);
|
||||
}
|
||||
|
||||
pthread_join(thread1, NULL);
|
||||
pthread_join(thread2, NULL);
|
||||
|
||||
/* Do some operations on locks in order to check if they are still in
|
||||
* usable state after deferred cancellation. */
|
||||
* usable state after deferred cancellation.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||
#ifdef CONFIG_CANCELLATION_POINTS
|
||||
@ -183,16 +194,16 @@ static void test_timeout(void)
|
||||
if (status != EBUSY)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR able to acquire write lock when write lock already acquired, "
|
||||
"status=%d\n", status);
|
||||
"ERROR able to acquire write lock when write lock already "
|
||||
"acquired, status=%d\n", status);
|
||||
}
|
||||
|
||||
status = pthread_rwlock_tryrdlock(&write_lock);
|
||||
if (status != EBUSY)
|
||||
{
|
||||
printf("pthread_rwlock_cancel: "
|
||||
"ERROR able to acquire read lock when write lock already acquired, "
|
||||
"status=%d\n", status);
|
||||
"ERROR able to acquire read lock when write lock already "
|
||||
"acquired, status=%d\n", status);
|
||||
}
|
||||
|
||||
status = pthread_rwlock_unlock(&read_lock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user