aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encoding_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'prog/encoding_test.go')
-rw-r--r--prog/encoding_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/prog/encoding_test.go b/prog/encoding_test.go
index f23a92cc7..f4036b458 100644
--- a/prog/encoding_test.go
+++ b/prog/encoding_test.go
@@ -6,6 +6,7 @@ package prog
import (
"fmt"
"reflect"
+ "regexp"
"sort"
"testing"
)
@@ -93,3 +94,32 @@ func TestCallSetRandom(t *testing.T) {
}
}
}
+
+func TestDeserialize(t *testing.T) {
+ tests := []struct {
+ data string
+ err *regexp.Regexp
+ }{
+ {
+ "syz_test$struct(&(0x7f0000000000)={0x0, {0x0}})",
+ nil,
+ },
+ {
+ "syz_test$struct(&(0x7f0000000000)=0x0)",
+ regexp.MustCompile(`bad const type.*`),
+ },
+ }
+ for _, test := range tests {
+ _, err := Deserialize([]byte(test.data))
+ if err != nil {
+ if test.err == nil {
+ t.Fatalf("deserialization failed with\n%s\ndata:\n%s\n", err, test.data)
+ }
+ if !test.err.MatchString(err.Error()) {
+ t.Fatalf("deserialization failed with\n%s\nwhich doesn't match\n%s\ndata:\n%s\n", err, test.err, test.data)
+ }
+ } else if test.err != nil {
+ t.Fatalf("deserialization should have failed with:\n%s\ndata:\n%s\n", test.err, test.data)
+ }
+ }
+}