cmd/bent: added a simple first test

This ensures that initialization works and that ALL the
benchmark and sample configuration files parse.

2nd patch -- add copyright and build tags for 1.16

Change-Id: Ic3fb90063175dda8dc8a3edf02e7f913614c262c
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/320970
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
diff --git a/cmd/bent/bent_test.go b/cmd/bent/bent_test.go
new file mode 100644
index 0000000..c52d26b
--- /dev/null
+++ b/cmd/bent/bent_test.go
@@ -0,0 +1,90 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build go1.16
+// +build go1.16
+
+package main_test
+
+import (
+	"fmt"
+	"os"
+	"os/exec"
+	"path/filepath"
+	"sync"
+	"testing"
+)
+
+const dataDir = "testdata"
+
+var binary, dir string
+
+// We implement TestMain so remove the test binary when all is done.
+func TestMain(m *testing.M) {
+	os.Exit(testMain(m))
+}
+
+func testMain(m *testing.M) int {
+	var err error
+	dir, err = os.MkdirTemp("", "bent_test")
+	if err != nil {
+		fmt.Fprintln(os.Stderr, err)
+		return 1
+	}
+	defer os.RemoveAll(dir)
+	binary = filepath.Join(dir, "testbent.exe")
+	return m.Run()
+}
+
+var (
+	built    = false // We have built the binary.
+	failed   = false // We have failed to build the binary, don't try again.
+	onlyOnce sync.Once
+)
+
+func build(t *testing.T) {
+	onlyOnce.Do(func() {
+		cmd := exec.Command("go", "build", "-o", binary)
+		output, err := cmd.CombinedOutput()
+		if err != nil {
+			failed = true
+			fmt.Fprintf(os.Stderr, "%s\n", output)
+			t.Fatal(err)
+		}
+		built = true
+	})
+	if failed {
+		t.Skip("cannot run on this environment")
+	}
+}
+
+func TestBent(t *testing.T) {
+	build(t)
+	cmd := exec.Command(binary, "-I")
+	cmd.Dir = dir
+	output, err := cmd.CombinedOutput()
+	if err != nil {
+		failed = true
+		fmt.Fprintf(os.Stderr, "%s\n", output)
+		t.Fatal(err)
+	}
+	t.Log(string(output))
+	Cs := []string{"sample", "cronjob", "cmpjob", "gollvm"}
+	Bs := []string{"all", "50", "gc", "gcplus", "trial"}
+	for _, c := range Cs {
+		for _, b := range Bs {
+			cmd = exec.Command(binary, "-l", "-C=configurations-"+c+".toml", "-B=benchmarks-"+b+".toml")
+			cmd.Dir = dir
+			output, err = cmd.CombinedOutput()
+			if err != nil {
+				failed = true
+				fmt.Fprintf(os.Stderr, "%s\n", output)
+				t.Fatal(err)
+			}
+			t.Log(string(output))
+		}
+		Bs = Bs[:1] // truncate Bs for remaining configurations
+	}
+
+}
diff --git a/cmd/bent/configs/benchmarks-all.toml b/cmd/bent/configs/benchmarks-all.toml
index e05283d..849de21 100644
--- a/cmd/bent/configs/benchmarks-all.toml
+++ b/cmd/bent/configs/benchmarks-all.toml
@@ -95,10 +95,6 @@
 
 [[Benchmarks]]
   Name = "gonum_lapack_native"
-<<<<<<< HEAD
-  Repo = "gonum.org/v1/gonum/lapack/gonum"
-=======
->>>>>>> 8dbe4b9 (cmd/bent: refactor common benchmark info into "suites.toml"; add versions)
   Benchmarks = "Benchmark"
 
 [[Benchmarks]]