github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/tool/flags_fuzz.go (about)

     1  // Copyright 2020 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package tool
     5  
     6  import (
     7  	"reflect"
     8  	"strings"
     9  )
    10  
    11  func FuzzParseFlags(data []byte) int {
    12  	flags, err := deserializeFlags(string(data))
    13  	if err != nil {
    14  		return 0
    15  	}
    16  	value := serializeFlags(flags)
    17  	if strings.IndexByte(value, ' ') != -1 {
    18  		panic("flags contain space")
    19  	}
    20  	flags1, err := deserializeFlags(value)
    21  	if err != nil {
    22  		panic(err)
    23  	}
    24  	if !reflect.DeepEqual(flags, flags1) {
    25  		panic("changed")
    26  	}
    27  	return 1
    28  }