| 1 |
//go:build !no_antithesis_sdk && linux && amd64 && !cgo |
| 2 |
|
| 3 |
package internal |
| 4 |
|
| 5 |
import ( |
| 6 |
"log" |
| 7 |
"os" |
| 8 |
"path/filepath" |
| 9 |
) |
| 10 |
|
| 11 |
const sdkRunningInDegradedMode = true |
| 12 |
|
| 13 |
type inAntithesisWithoutCgoHandler struct { |
| 14 |
outputFile *os.File |
| 15 |
} |
| 16 |
|
| 17 |
func (h *inAntithesisWithoutCgoHandler) output(message string) { |
| 18 |
if len(message) == 0 { |
| 19 |
return |
| 20 |
} |
| 21 |
h.outputFile.WriteString(message + "\n") |
| 22 |
} |
| 23 |
|
| 24 |
func (h *inAntithesisWithoutCgoHandler) random() uint64 { |
| 25 |
return osRandom() |
| 26 |
} |
| 27 |
|
| 28 |
func (h *inAntithesisWithoutCgoHandler) notify(edge uint64) bool { |
| 29 |
return false |
| 30 |
} |
| 31 |
|
| 32 |
func (h *inAntithesisWithoutCgoHandler) init_coverage(num_edges uint64, symbols string) uint64 { |
| 33 |
return 0 |
| 34 |
} |
| 35 |
|
| 36 |
func (h *inAntithesisWithoutCgoHandler) notify_v2(edge uint64, hits uint64) (uint64, bool) { |
| 37 |
return 0, false |
| 38 |
} |
| 39 |
|
| 40 |
func (h *inAntithesisWithoutCgoHandler) lease_generation() (uint64, bool) { |
| 41 |
return 0, false |
| 42 |
} |
| 43 |
|
| 44 |
func init_in_antithesis() libHandler { |
| 45 |
dir, is_set := os.LookupEnv(outputDirEnvVar) |
| 46 |
if !is_set || len(dir) == 0 { |
| 47 |
return nil |
| 48 |
} |
| 49 |
|
| 50 |
path := filepath.Join(dir, fallbackOutputFilename) |
| 51 |
file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) |
| 52 |
if err != nil { |
| 53 |
log.Printf("%s Failed to open path %s: %v", errorLogLinePrefix, path, err) |
| 54 |
return nil |
| 55 |
} |
| 56 |
|
| 57 |
return &inAntithesisWithoutCgoHandler{file} |
| 58 |
} |