blob: b85e4c7422d226f356acddbfbfdb50101df9cea1 [file] [log] [blame]
sslobodrd6e07e72019-01-31 16:07:20 -05001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16// The template for the tester.
17// This template is filled in by the
18// test driver based on the configuration.
19
20package main
21
22import (
23 "os"
24 //"time"
25 "fmt"
26 "os/exec"
27 "io/ioutil"
28 "github.com/opencord/voltha-go/common/log"
29)
30
31func main() {
32 var cmd *exec.Cmd
33 var cmdStr string
34 // Setup logging
35 if _, err := log.SetDefaultLogger(log.JSON, 0, nil); err != nil {
36 log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
37 }
38
39 defer log.CleanUp()
40
41 log.Info("Running tests")
42 {{range .}}
43 if err:= os.Chdir(os.Args[1]); err != nil {
44 log.Error("Could not change directory to %s: %v", os.Args[1], err)
45 }
46 cmdStr = "./"+"{{.}}"[:len("{{.}}")-5]
47 log.Infof("Running test %s",cmdStr)
48 cmd = exec.Command(cmdStr, "results.txt")
49 cmd.Stdin = os.Stdin
50 cmd.Stdout = os.Stdout
51 cmd.Stderr = os.Stderr
52 if err := cmd.Run(); err != nil {
53 log.Errorf("Test '%s' failed", cmdStr)
54 }
55 {{end}}
56 // Open the results file and output it.
57 if resFile, err := ioutil.ReadFile("results.txt"); err == nil {
58 fmt.Println(string(resFile))
59 } else {
60 log.Error("Could not load the results file 'results.txt'")
61 }
62 log.Info("Tests complete")
63}