-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathchecker.go
94 lines (79 loc) · 2.06 KB
/
checker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (C) 2023 Huawei Technologies Co., Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
// Package checker contains a series of checkers that determine whether a given a module is correct, unsafe, or hangs.
package checker
import (
"context"
)
type Version struct {
major int
minor int
patch int
}
// DumpableModule represents the interface of modules required by the checkers.
type DumpableModule interface {
String() string
}
// Tool interface consists of one function to check the module and return a result.
type Tool interface {
Check(ctx context.Context, m DumpableModule) (CheckResult, error)
GetVersion() string
}
// CheckStatus represents the outcome of a check run
type CheckStatus int
//go:generate go run golang.org/x/tools/cmd/stringer -type=CheckStatus
const (
// CheckUndefined represents a check with outcome Undefined
CheckUndefined CheckStatus = iota
// CheckOK represents a check with outcome OK
CheckOK
// CheckNotSafe represents a check with outcome NotSafe
CheckNotSafe
// CheckNotLive represents a check with outcome NotLive
CheckNotLive
// CheckInvalid represents a check with outcome Invalid
CheckInvalid
// CheckTimeout represents a check with outcome Timeout
CheckTimeout
// CheckRejected represents a check with outcome Rejected
CheckRejected
)
// CheckResult is a pair of CheckStatus and output string
type CheckResult struct {
Status CheckStatus
Output string
NumExecutions int
}
//go:generate go run golang.org/x/tools/cmd/stringer -type=ID
type ID int
const (
// Unknown checker
UnknownID ID = iota
// Dartagnan checker
DartagnanID
// GenMC checker
GenmcID
// Mock checker
MockID
)
func ParseID(s string) ID {
switch s {
case "genmc":
return GenmcID
case "dartagnan":
return DartagnanID
case "mock":
return MockID
default:
return UnknownID
}
}
type OptionsFunc func() []string
var compileOptions = map[ID]OptionsFunc{}
func emptyOptions() []string { return nil }
func CompileOptions(id ID) OptionsFunc {
if foo, has := compileOptions[id]; has {
return foo
}
return emptyOptions
}