Skip to content

Commit

Permalink
sys/test: add more tests for bitfields
Browse files Browse the repository at this point in the history
Add tests for issue #1542

The correct results are obtained with the following program:

struct foo {
	unsigned char	f0;
	unsigned int	f1:4;
	unsigned short	f2:4;
};

struct bar {
	char f0;
	struct foo foo;
};

int main() {
	struct bar y;
	memset(&y, 0, sizeof(y));
	y.f0 = 0x12;
	y.foo.f0 = 0x34;
	y.foo.f1 = 0x56;
	y.foo.f2 = 0x78;
	int i;
	for (i = 0; i < sizeof(y); i++)
		printf("%02x", ((unsigned char*)&y)[i]);
	printf("\n");
}
  • Loading branch information
dvyukov committed Dec 13, 2019
1 parent 2a752b7 commit a5c1ab0
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 8 deletions.
8 changes: 4 additions & 4 deletions executor/defs.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions sys/test/exec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ compare_data [
bf1 syz_bf_struct1
bf2 syz_bf_struct2
bf3 syz_bf_struct3
bf4 syz_bf_align[syz_bf_struct4]
bf5 syz_bf_align[syz_bf_struct5]
bf6 syz_bf_align[syz_bf_struct6]
bf7 syz_bf_align[syz_bf_struct7]
bf8 syz_bf_align[syz_bf_struct8]
bf9 syz_bf_align[syz_bf_struct9]
str string
blob array[int8]
arr16be array[int16be]
Expand All @@ -27,3 +33,42 @@ align0 {
f3 int16
f4 int64
}

syz_bf_struct4 {
f0 int8
f1 int32:4
f2 int8
}

syz_bf_struct5 {
f0 int8
f1 int32:4
}

syz_bf_struct6 {
f0 int8
f1 int16:4
f2 int8
}

syz_bf_struct7 {
f0 int8
f1 int16:4
}

syz_bf_struct8 {
f0 int8
f1 int32:4
f2 int16:4
}

syz_bf_struct9 {
f0 int8
f1 int16:4
f2 int16:4
}

type syz_bf_align[T] {
f0 int8
f1 T
}
75 changes: 74 additions & 1 deletion sys/test/gen/32_fork_shmem.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 74 additions & 1 deletion sys/test/gen/32_shmem.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a5c1ab0

Please sign in to comment.