lotus/testplans/lotus-soup/sanity.go

35 lines
901 B
Go
Raw Normal View History

package main
import (
"fmt"
"os"
)
func sanityCheck() {
enhanceMsg := func(msg string, a ...interface{}) string {
return fmt.Sprintf("sanity check: "+msg+"; if running on local:exec, make sure to run `make` from the root of the oni repo", a...)
}
dir := "/var/tmp/filecoin-proof-parameters"
stat, err := os.Stat(dir)
if os.IsNotExist(err) {
panic(enhanceMsg("proofs parameters not available in /var/tmp/filecoin-proof-parameters"))
}
if err != nil {
panic(enhanceMsg("failed to stat /var/tmp/filecoin-proof-parameters: %s", err))
}
if !stat.IsDir() {
panic(enhanceMsg("/var/tmp/filecoin-proof-parameters is not a directory; aborting"))
}
files, err := os.ReadDir(dir)
if err != nil {
panic(enhanceMsg("failed list directory /var/tmp/filecoin-proof-parameters: %s", err))
}
if len(files) == 0 {
panic(enhanceMsg("no files in /var/tmp/filecoin-proof-parameters"))
}
}