github.com/sentienttechnologies/studio-go-runner@v0.0.0-20201118202441-6d21f2ced8ee/internal/runner/openblas_test.go (about) 1 // Copyright 2020 (c) Cognizant Digital Business, Evolutionary AI. All rights reserved. Issued under the Apache 2.0 License. 2 3 package runner 4 5 import ( 6 "io/ioutil" 7 "os" 8 "path/filepath" 9 "strings" 10 "testing" 11 12 "github.com/go-stack/stack" 13 "github.com/jjeffery/kv" 14 ) 15 16 // TestOpenBlas is used to validate that openblas is available to our python 17 // base installation 18 // 19 func TestOpenBlas(t *testing.T) { 20 // Create a new TMPDIR because the python pip tends to leave dirt behind 21 // when doing pip builds etc 22 tmpDir, errGo := ioutil.TempDir("", "") 23 if errGo != nil { 24 t.Fatal(kv.Wrap(errGo).With("stack", stack.Trace().TrimRuntime())) 25 } 26 defer func() { 27 os.RemoveAll(tmpDir) 28 }() 29 30 // Grab know files from the crypto test library and place them into 31 // our temporary test directory 32 testFiles := map[string]os.FileMode{ 33 filepath.Join("..", "..", "assets", "openblas", "openblas.py"): 0600, 34 filepath.Join("..", "..", "assets", "openblas", "openblas.sh"): 0700, 35 } 36 37 output, err := PythonRun(testFiles, "", 128) 38 if err != nil { 39 t.Fatal(err) 40 } 41 for _, line := range output { 42 if strings.Contains(line, "libraries = ['openblas', 'openblas']") { 43 return 44 } 45 } 46 t.Fatal(kv.NewError("Openblas not detected").With("lines", output, "stack", stack.Trace().TrimRuntime())) 47 }