test: 修复llvm升级导致tdd用例部分失败问题

方案描述:
1、llvm升级之后对while(1)死循环和给空指针赋值的场景有错误优化的情况;
   用例中在相关函数之前添加__attribute__((optnone))禁止编译器进行错误优化。

Close:#I6V2LN

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: Ic7150909c12a599aeeb0a55b983dfad7a0631cdc
This commit is contained in:
zhangdengyu
2023-04-28 17:26:17 +08:00
parent 5fb9165c08
commit 577d29aaba
8 changed files with 20 additions and 20 deletions

View File

@@ -30,7 +30,7 @@
*/
#include "it_test_exc.h"
static int TestCase(void)
__attribute__((optnone)) static int TestCase(void)
{
int ret;
int status = 0;

View File

@@ -31,7 +31,7 @@
#include "it_test_exc.h"
#include "pthread.h"
static void *ThreadFunc2(void *arg)
__attribute__((optnone)) static void *ThreadFunc2(void *arg)
{
while (1) {
}
@@ -39,7 +39,7 @@ static void *ThreadFunc2(void *arg)
return nullptr;
}
static void *ThreadFunc1(void *arg)
__attribute__((optnone)) static void *ThreadFunc1(void *arg)
{
int *test = nullptr;
*test = 0x1;
@@ -77,7 +77,8 @@ static int TestThread(void)
return 0;
}
static int TestCase(void)
__attribute__((optnone)) static int TestCase(void)
{
int *test = nullptr;
int count = 5;

View File

@@ -34,14 +34,15 @@
#define TEST_THREAD_COUNT 5
static volatile int g_testCondFlag;
static int g_count[TEST_THREAD_COUNT];
static void *ThreadFunc2(void *arg)
__attribute__((optnone)) static void *ThreadFunc2(void *arg)
{
int count = *(int *)arg;
int *test = nullptr;
g_testCondFlag++;
while (g_testCondFlag < 2) {
while (g_testCondFlag < 2) { /* 2, no special meaning */
}
*test = 0x1;
@@ -83,7 +84,7 @@ static int TestThread(void)
return 0;
}
static int TestCase(void)
__attribute__((optnone)) static int TestCase(void)
{
int *test = nullptr;
int count = 5;

View File

@@ -33,7 +33,7 @@
#define TEST_THREAD_COUNT 5
static int TestThread(void)
__attribute__((optnone)) static int TestThread(void)
{
int ret;
int *test = nullptr; // For triggering an exceptioin
@@ -53,7 +53,7 @@ static int TestThread(void)
return 0;
}
static int TestCase(void)
__attribute__((optnone)) static int TestCase(void)
{
int count = 5;
int status = 0;

View File

@@ -30,7 +30,7 @@
*/
#include "it_test_exc.h"
static void Child(void)
__attribute__((optnone)) static void Child(void)
{
while (1) {
printf("@@@@@@@@@@@@@ pid : %d getppid : %d @@@@@@@@@@@@@@@@\n", getpid(), getppid());
@@ -41,7 +41,7 @@ static void TestKill(int sig)
exit(0);
}
static int TestCase(void)
__attribute__((optnone)) static int TestCase(void)
{
int ret;
void (*retptr)(int) = NULL;