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

!819 fix: codex及合规修复

Merge pull request !819 from Zhaotianyu/cherry-pick-1646726776
......@@ -54,28 +54,6 @@ struct _scenar_028 {
#define NSCENAR (sizeof(g_scenarii028) / sizeof(g_scenarii028[0]))
/* pthread_mutex_destroy 2-2.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* This sample test aims to check the following assertion:
*
* pthread_mutex_init() can be used to re-initialize a destroyed mutex.
* The steps are:
* -> Initialize a mutex with a given attribute.
* -> Destroy the mutex
* -> Initialize again the mutex with another attribute.
*/
static UINT32 Testcase(VOID)
{
int ret;
......@@ -85,25 +63,20 @@ static UINT32 Testcase(VOID)
pthread_mutexattr_t *pma[NSCENAR + 2];
long pshared;
/* System abilities */
pshared = sysconf(_SC_THREAD_PROCESS_SHARED);
/* Initialize the mutex attributes objects */
for (i = 0; i < NSCENAR; i++) {
ret = pthread_mutexattr_init(&ma[i]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
}
/* Default mutexattr object */
ret = pthread_mutexattr_init(&ma[i]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
/* Initialize the pointer array */
/* 2, The loop frequency. */
for (i = 0; i < NSCENAR + 2; i++)
for (i = 0; i < NSCENAR + 2; i++) // 2, The loop frequency.
/* NULL pointer */
pma[i] = NULL;
/* Ok, we can now proceed to the test */
for (i = 0; i < NSCENAR + 2; i++) { // 2, The loop frequency.
for (j = 0; j < NSCENAR + 2; j++) { // 2, The loop frequency.
ret = pthread_mutex_init(&mtx, pma[i]);
......
......@@ -40,51 +40,15 @@ extern "C" {
static pthread_mutex_t g_mutex038;
static sem_t g_sem038;
/* pthread_mutex_lock 4-1.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* This sample test aims to check the following assertion:
*
* If the mutex type is PTHREAD_MUTEX_RECURSIVE,
* then the mutex maintains the concept of a lock count.
* When a thread successfully acquires a mutex for the first time,
* the lock count is set to one. Every time a thread relocks this mutex,
* the lock count is incremented by one.
* Each time the thread unlocks the mutex,
* the lock count is decremented by one.
* When the lock count reaches zero,
* the mutex becomes available and others threads can acquire it.
* The steps are:
* ->Create a mutex with recursive attribute
* ->Create a threads
* ->Parent locks the mutex twice, unlocks once.
* ->Child attempts to lock the mutex.
* ->Parent unlocks the mutex.
* ->Parent unlocks the mutex (shall fail)
* ->Child unlocks the mutex.
*/
static void *TaskF01(void *arg)
{
int ret;
/* Try to lock the mutex once. The call must fail here. */
ret = pthread_mutex_trylock(&g_mutex038);
if (ret == 0) {
ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
}
/* Free the parent thread and lock the mutex (must success) */
if ((ret = sem_post(&g_sem038))) {
ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
}
......@@ -93,12 +57,10 @@ static void *TaskF01(void *arg)
ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
}
/* Wait for the parent to let us go on */
if ((ret = sem_post(&g_sem038))) {
ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
}
/* Unlock and exit */
if ((ret = pthread_mutex_unlock(&g_mutex038))) {
ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
}
......@@ -113,12 +75,10 @@ static UINT32 Testcase(VOID)
pthread_mutexattr_t ma;
pthread_t child;
/* Initialize the semaphore */
if ((ret = sem_init(&g_sem038, 0, 0))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* We initialize the recursive mutex */
if ((ret = pthread_mutexattr_init(&ma))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
......@@ -135,9 +95,6 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* -- The mutex is now ready for testing -- */
/* First, we lock it twice and unlock once */
if ((ret = pthread_mutex_lock(&g_mutex038))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
......@@ -150,40 +107,31 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* Here this thread owns the mutex and the internal count is "1" */
/* We create the child thread */
if ((ret = pthread_create(&child, NULL, TaskF01, NULL))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* then wait for child to be ready */
if ((ret = sem_wait(&g_sem038))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* We can now unlock the mutex */
if ((ret = pthread_mutex_unlock(&g_mutex038))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* We wait for the child to lock the mutex */
if ((ret = sem_wait(&g_sem038))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* Then, try to unlock the mutex (owned by the child or unlocked) */
ret = pthread_mutex_unlock(&g_mutex038);
if (ret == ENOERR) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* Everything seems OK here */
if ((ret = pthread_join(child, NULL))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* Simple loop to double-check */
for (i = 0; i < 50; i++) { // 50, The loop frequency.
if ((ret = pthread_mutex_lock(&g_mutex038))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
......@@ -199,7 +147,6 @@ static UINT32 Testcase(VOID)
if (ret == 0) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
/* The test passed, we destroy the mutex */
if ((ret = pthread_mutex_destroy(&g_mutex038))) {
ICUNIT_ASSERT_EQUAL(1, 0, ret);
}
......
......@@ -39,29 +39,6 @@ extern "C" {
static pthread_mutex_t g_mutex042;
/* pthread_mutex_unlock 5-1.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This sample test aims to check the following assertion:
* If the mutex type is PTHREAD_MUTEX_RECURSIVE,
* and a thread attempts to unlock a mutex that it does not own,
* an uwErr is returned.
* The steps are:
* -> Initialize and lock a recursive mutex
* -> create a child thread which tries to unlock this mutex. *
*/
static void *TaskF01(void *arg)
{
int ret;
......
......@@ -36,31 +36,6 @@ extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
/* pthread_mutex_unlock 5-2.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This sample test aims to check the following assertion:
* If the mutex type is PTHREAD_MUTEX_RECURSIVE,
* and a thread attempts to unlock an unlocked mutex,
* an uwErr is returned.
* The steps are:
* -> Initialize a recursive mutex
* -> Attempt to unlock the mutex when it is unlocked
* and when it has been locked then unlocked.
*/
static UINT32 Testcase(VOID)
{
int ret;
......
......@@ -39,33 +39,6 @@ extern "C" {
static pthread_mutex_t g_mutex045;
/* pthread_mutex_trylock 1-2.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* This sample test aims to check the following assertion:
*
* The pthread_mutex_trylock() function locks the mutex object
* when it is unlocked.
* The steps are:
*
* -> For each kind of mutex,
* -> trylock the mutex. It shall suceed.
* -> trylock the mutex again. It shall fail (except in case of recursive mutex).
* -> create a new child (either thread or process)
* -> the new child trylock the mutex. It shall fail.
* -> undo everything.
*/
static VOID *TaskF01(void *argument)
{
int ret;
......
......@@ -39,36 +39,6 @@ extern "C" {
static pthread_mutex_t g_mutex046;
static UINT32 g_nID;
/* pthread_mutex_trylock 2-1.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* This sample test aims to check the following assertion:
*
* If the mutex is of type PTHREAD_MUTEX_RECURSIVE,
* and the calling thread already owns the mutex,
* the call is successful (the lock count is incremented).
* The steps are:
*
* -> trylock the mutex. It shall suceed.
* -> trylock the mutex again. It shall suceed again
* -> unlock once
* -> create a new child (either thread or process)
* -> the new child trylock the mutex. It shall fail.
* -> Unlock. It shall succeed.
* -> Unlock again. It shall fail.
* -> undo everything.
*/
static void *TaskF01(void *arg)
{
int ret;
......
......@@ -39,31 +39,6 @@ extern "C" {
static pthread_mutex_t g_mutex049;
/* pthread_mutex_trylock 4-2.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* This sample test aims to check the following assertion:
*
* If the mutex was already locked, the call returns EBUSY immediatly.
* The steps are:
* -> Set a timeout.
* -> For each kind of mutex,
* -> Lock the mutex.
* -> create a new child (either thread or process)
* -> the new child trylock the mutex. It shall fail.
* -> undo everything.
*/
static VOID *TaskF01(void *argument)
{
int ret;
......
......@@ -41,38 +41,6 @@ static pthread_mutex_t *g_mtx;
static sem_t g_semA, g_semB;
static pthread_mutex_t g_mtxNull, g_mtxDef;
/* pthread_mutex_init 1-2.c
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* This sample test aims to check the following assertion:
*
* If the mutex attribute pointer passed to pthread_mutex_init is NULL,
* the effects on the mutex are the same as if a default mutex attribute object had been passed.
*
* The steps are:
* * create two mutexes. One is initialized with NULL attribute, the other with a default attribute object.
* * Compare the following features between the two mutexes:
* -> Can it cause / detect a deadlock? (attempt to lock a mutex the thread already owns).
* If detected, do both mutexes cause the same uwErr code?
* -> Is an uwErr returned when unlocking the mutex in unlocked state?
* When unlocking the mutex owned by another thread?
*
* The test will pass if the results of each feature are the same for the two mutexes
* (making no assumption on what is the default behavior).
* The test will be unresolved if any initialization fails.
* The test will fail if a feature differs between the two mutex objects.
*/
static void *TaskF01(void *arg)
{
int ret;
......
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# http://www.apache.org/licenses/LICENSE-2.0
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys
import os
......
#!/bin/bash
#Copyright (c) 2020-2021 Huawei Device Co., Ltd.
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# http://www.apache.org/licenses/LICENSE-2.0
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
LOAD_BASE="0x2000000"
LLVM_ADDR2LINE=llvm-addr2line
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册