aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/testdata
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-03-17 08:05:11 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-03-17 21:19:13 +0100
commit8bec3911ad478b6fef8df96e4dc89f8080229133 (patch)
treef7219cc336de08b708b776722588e090e745130a /pkg/compiler/testdata
parent924f7606047a430a9b313c135b782e1e8f852bec (diff)
pkg/compiler: add tests for generation phase
Add errors3.txt with tests for errors that are produced during generation phase. Refactor tests to reduce duplication. Tidy struct/union size errors: better locations and make testable.
Diffstat (limited to 'pkg/compiler/testdata')
-rw-r--r--pkg/compiler/testdata/errors.txt2
-rw-r--r--pkg/compiler/testdata/errors2.txt2
-rw-r--r--pkg/compiler/testdata/errors3.txt20
3 files changed, 24 insertions, 0 deletions
diff --git a/pkg/compiler/testdata/errors.txt b/pkg/compiler/testdata/errors.txt
index e0b003481..d5611a531 100644
--- a/pkg/compiler/testdata/errors.txt
+++ b/pkg/compiler/testdata/errors.txt
@@ -1,6 +1,8 @@
# Copyright 2017 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+# Errors that happen during type checking phase.
+
foo$0(x fileoff, y int8, z buffer[in])
foo$1(x "bar") ### unexpected string "bar", expect type
foo$2(x 123, y "bar") ### unexpected int 123, expect type ### unexpected string "bar", expect type
diff --git a/pkg/compiler/testdata/errors2.txt b/pkg/compiler/testdata/errors2.txt
index b5ab19ebf..2b24d3628 100644
--- a/pkg/compiler/testdata/errors2.txt
+++ b/pkg/compiler/testdata/errors2.txt
@@ -1,6 +1,8 @@
# Copyright 2017 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+# Errors that happen during checking phase.
+
# Recursive resources.
resource r0[r0] ### recursive resource r0->r0
diff --git a/pkg/compiler/testdata/errors3.txt b/pkg/compiler/testdata/errors3.txt
new file mode 100644
index 000000000..65bd20092
--- /dev/null
+++ b/pkg/compiler/testdata/errors3.txt
@@ -0,0 +1,20 @@
+# Copyright 2020 syzkaller project authors. All rights reserved.
+# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+# Errors that happen during description generation phase.
+
+discrimination(a int32)
+discrimination$1(a int16) ### discrimination$1 arg a is redeclared with size 2, previously declared with size 4 at LOCATION
+
+bad_size_attr_struct {
+ a int64
+} [size[4]] ### struct bad_size_attr_struct has size attribute 4 which is less than struct size 8
+
+bad_size_attr_union [
+ a int8
+ b int16
+ c int32 ### union bad_size_attr_union has size attribute 2 which is less than field int32 size 4
+ d int64 ### union bad_size_attr_union has size attribute 2 which is less than field int64 size 8
+] [size[2]]
+
+bad_size_call(a ptr[in, bad_size_attr_struct], b ptr[in, bad_size_attr_union])