未验证 提交 cc4c26cc 编写于 作者: O openharmony_ci 提交者: Gitee

!525 fix 3 test cases

Merge pull request !525 from maweiye/fix-libctest
......@@ -14,7 +14,7 @@
static void *threadfunc(void *parm)
{
sleep(5); // allow main program to set the thread name
sleep(1); // allow main program to set the thread name
return NULL;
}
......@@ -24,8 +24,8 @@ int main(int argc, char **argv)
int rc;
char thread_name[NAMELEN];
char set_thread_name[] = "THREADFOO";
char default_name[] = "pthread_getname_np";
char default_name[] = "pthread_getname";
rc = pthread_getname_np(pthread_self(), thread_name, NAMELEN);
if (rc != 0) errExitEN(rc, "pthread_getname_np failed");
if(strcmp(thread_name, default_name) != 0) perror("pthread name comparison failed");
......@@ -36,8 +36,6 @@ int main(int argc, char **argv)
rc = pthread_setname_np(thread, (argc > 1) ? argv[1] : set_thread_name);
if (rc != 0) errExitEN(rc, "pthread_setname_np failed");
sleep(2);
rc = pthread_getname_np(thread, thread_name, (argc > 2) ? atoi(argv[1]) : NAMELEN);
if (rc != 0) errExitEN(rc, "pthread_getname_np failed");
if(strcmp(thread_name, set_thread_name) != 0) perror("pthread name comparison failed");
......
......@@ -7,29 +7,22 @@
#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0))
static pthread_mutex_t mutex ;
void* pthread_test(void* arg)
{
pthread_mutex_lock(&mutex);
*((pid_t *)arg) = gettid();
pthread_mutex_unlock(&mutex);
return NULL;
}
int main(int argc, char const *argv[])
{
pthread_mutex_init(&mutex, NULL);
TEST(gettid() == pthread_gettid_np(pthread_self()),"pthread_gettid_np() is failed\n");
pthread_mutex_lock(&mutex);
pid_t tid;
pthread_t t;
pthread_create(&t,NULL,pthread_test,&tid);
pid_t recv_result = pthread_gettid_np(t);
TEST(0 == pthread_join(t,NULL),"pthread_join is failed\n");
pthread_mutex_unlock(&mutex);
TEST(tid == recv_result,"the tid of pthread or tid of pthread_gettid_np() is wrong\n");
return 0;
}
\ No newline at end of file
......@@ -72,6 +72,9 @@ do
|| [ -d $file ]
then
continue
elif [ "$file" = "tgkill" ]
then
src/common/runtest -w '' $dir/$file 12345 34567 >> src/REPORT
else
# echo file=$dir/$file
src/common/runtest -w '' $dir/$file >> src/REPORT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册