update synthetic tests. removed uninit.c because there was not enough diversity. my goal is to have few tests with much diversity.

This commit is contained in:
Daniel Marjamäki 2016-11-03 09:40:22 +01:00
parent c6c17c89c9
commit 0836b999cf
3 changed files with 37 additions and 79 deletions

View File

@ -2,8 +2,7 @@ ifndef CC
CC=gcc CC=gcc
endif endif
all: controlflow.o data.o functions.o
all: controlflow.o data.o functions.o uninit.o
controlflow.o: controlflow.c controlflow.o: controlflow.c
$(CC) -c controlflow.c $(CC) -c controlflow.c
@ -14,8 +13,5 @@ data.o: data.c
functions.o: functions.c functions.o: functions.c
$(CC) -c functions.c $(CC) -c functions.c
uninit.o: uninit.c
$(CC) -std=gnu99 -c uninit.c
clean: clean:
rm -rf controlflow.o data.o functions.o uninit.o rm -rf controlflow.o data.o functions.o uninit.o

View File

@ -1,45 +1,68 @@
int TestData[10]; int TestData[10];
#define TEST(DATA) DATA=1000;TestData[DATA]=0; DATA=0;TestData[0]=100/(DATA);
int global; int global;
void test_global() { void test_global() {
TEST(global); global = 1000;
TestData[global] = 0;
} }
int global_array[10]; int global_array[10];
void test_global_array() { void test_global_array() {
TEST(global_array[3]); global_array[3] = 1000;
TestData[global_array[3]] = 0;
} }
int *global_pointer; int *global_pointer;
void test_global_pointer() { void test_global_pointer() {
TEST(*global_pointer); *global_pointer = 1000;
TestData[*global_pointer] = 0;
} }
void test_local() { void test_local() {
int local; int local;
TEST(local); local = 1000;
TestData[local] = 0;
} }
void test_local_array() { void test_local_array() {
int local_array[10]; int local_array[10];
TEST(local_array[3]); local_array[3] = 1000;
TestData[local_array[3]] = 0;
} }
void test_local_pointer() { void test_local_alias_1() {
int local; int local;
int *local_pointer = &local; int *local_alias = &local;
TEST(*local_pointer); *local_alias = 1000;
TestData[*local_alias] = 0;
} }
void test_local_alias_2() {
int local;
int *local_alias = &local;
local = 1000;
TestData[*local_alias] = 0;
}
struct S { struct ABC {
int member; int a;
int b[10];
int c;
}; };
void test_struct_member(struct S *s) {
TEST(s->member); void test_struct_member_init() {
struct ABC abc = {1000,{0},3};
TestData[abc.a] = 0;
} }
void test_struct_member_assign(struct ABC *abc) {
abc->a = 1000;
TestData[abc->a] = 0;
}
void test_struct_arraymember(struct ABC *abc) {
abc->b[3] = 1000;
TestData[abc->b[3]] = 0;
}

View File

@ -1,61 +0,0 @@
// catch uninit variables..
#define AB1(A,B) A##B
#define AB2(A,B) AB1(A,B)
#define USE_INT_X(STMT) void AB2(use,__LINE__) (void) { int x; STMT; }
void dostuff(int);
// Bugs
USE_INT_X(dostuff(x))
USE_INT_X(dostuff(2+x))
USE_INT_X(x++)
USE_INT_X(x--)
USE_INT_X(++x)
USE_INT_X(--x)
USE_INT_X(-x)
USE_INT_X(+x)
USE_INT_X(!x)
USE_INT_X(~x)
USE_INT_X(if (x>0))
USE_INT_X(if (x>=0))
USE_INT_X(if (x<=0))
USE_INT_X(if (x<0))
USE_INT_X(if (x==0))
USE_INT_X(if (x==0))
USE_INT_X(for (int a=x; a<10; a++))
USE_INT_X(for (int a=0; a<x; a++))
USE_INT_X(for (int a=0; a<10; a+=x))
USE_INT_X(x=x+1)
USE_INT_X(x=x-1)
USE_INT_X(x=x*1)
USE_INT_X(x=x/1)
USE_INT_X(x=x%1)
USE_INT_X(x=x&1)
USE_INT_X(x=x|1)
USE_INT_X(x=x^1)
USE_INT_X(x=x<<1)
USE_INT_X(x=x>>1)
USE_INT_X(x+=1)
USE_INT_X(x-=1)
USE_INT_X(x*=1)
USE_INT_X(x/=1)
USE_INT_X(x%=1)
USE_INT_X(x&=1)
USE_INT_X(x|=1)
USE_INT_X(x^=1)
USE_INT_X(x<<=1)
USE_INT_X(x>>=1)
USE_INT_X(1?x:1)
USE_INT_X(1&&x)
USE_INT_X(x=*(&x)+1)
USE_INT_X(int*p=&x; dostuff(*p))
// No bugs
USE_INT_X(x=0)
USE_INT_X(0?x:1)
USE_INT_X(0&&x)
USE_INT_X(int*p=&x; *p=0; dostuff(x))