Documentation
¶
Overview ¶
Package field defines a generic way to reference and assign values to any test field by leveraging reflection and struct field tagging. Struct field tagging is used to check for semantic assignability. A source field is assignable to a destination field if the following two condition applies: - source field go type is assignable and/or convertible to destination field go type - source field is semantically assignable to destination field "Semantically assignable" means that both fields have the same `field_type`. A `field_type` must be assigned to a field via struct field tagging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JoinFieldPathSegments ¶
JoinFieldPathSegments joins the provided field path segments into a single field path.
func Paths ¶
Paths returns the field paths of the fields contained in the provided fieldContainer. fieldContainer's Kind must be Struct; otherwise, the function will panic. A field path is generated for each field that is neither a struct nor a pointer to a struct. For each field whose type has the struct kind, the function recursively invokes itself to provide field paths for each of its eligible subfields. Each field that is a struct pointer is dereferenced and then treated as a field whose type has the struct kind.
Types ¶
type Field ¶
type Field struct {
// Path represents the unique location of a field in the parent container. A Path is composed of one or multiple
// dot-separated field path segments. This addressing mechanism allows to organize fields in a hierarchical way.
Path string
// Value contains the value associated to the field. It can be settable or not, depending on how it is created.
Value reflect.Value
// Type is mainly used to check if a source Field Value can be semantically assigned to a destination Field Value.
// Semantic assignability means that both fields have the same Type. A Type must be assigned to a Field via
// `field_type` struct field tag (e.g.: `field_type:"<field_type>"`).
Type Type
}
Field contains information regarding a field, such as its value and its field type.
type Retriever ¶
type Retriever interface {
// Field returns information related to the field with the provided name.
Field(name string) (*Field, error)
}
Retriever allows to retrieve information regarding fields.
type Type ¶
type Type string
Type represents the type of field.
const ( // TypeUndefined specifies an undefined field type. This is a special value indicating the absence of a Type for a // Field. The value of a Field marked as undefined cannot be assigned nor set to any other Field value. TypeUndefined Type = "undefined" // TypeFD specifies that the field contains a file descriptor. TypeFD Type = "fd" // TypeBuffer specifies that the field contains a buffer. TypeBuffer Type = "buffer" // TypeBufferLen specifies that the field contains a buffer length. TypeBufferLen Type = "buffer_len" // TypeFilePath specifies that the field contains a file path. TypeFilePath Type = "file_path" // TypeOpenFlags specifies that the field contains the open system call flags. TypeOpenFlags Type = "open_flags" // TypeOpenMode specifies that the field contains the open system call modes. TypeOpenMode Type = "open_mode" // TypeOpenHow specifies that the field contains the openat2 system call open_how parameter. TypeOpenHow Type = "open_how" // TypeOpenHowFlags specifies that the field contains the openat2 system call open_how flags. TypeOpenHowFlags Type = "open_how_flags" // TypeOpenHowMode specifies that the field contains the openat2 system call open_how mode. TypeOpenHowMode Type = "open_how_mode" // TypeOpenHowResolve specifies that the field contains the openat2 system call open_how resolve value. TypeOpenHowResolve Type = "open_how_resolve" // TypeLinkAtFlags specifies that the field contains the linkat system call flags. TypeLinkAtFlags Type = "linkat_flags" // TypeModuleParams specifies that the field contains the init_module system call params. TypeModuleParams Type = "module_params" // TypeFinitModuleFlags specifies that the field contains the finit_module system call flags. TypeFinitModuleFlags Type = "finit_module_flags" // TypeDup3Flags specifies that the field contains the dup3 system call flags. TypeDup3Flags Type = "dup3_flags" // TypeSocketAddress specifies that the field contains a sockaddr. TypeSocketAddress Type = "socket_address" // TypeSocketDomain specifies that the field contains the socket system call domain. TypeSocketDomain Type = "socket_domain" // TypeSocketType specifies that the field contains the socket system call type. TypeSocketType Type = "socket_type" // TypeSocketProtocol specifies that the field contains the socket system call protocol. TypeSocketProtocol Type = "socket_protocol" // TypeSendFlags specifies that the field contains the sendto system call flags. TypeSendFlags Type = "send_flags" // TypePID specifies that the field contains a process identifier. TypePID Type = "pid" // TypeSignal specifies that the field contains a signal. TypeSignal Type = "signal" )