[botanist] Copy output files mentioned in summary JSON.

These output files were first added in
https://fuchsia-review.googlesource.com/c/zircon/+/154838

Tested somewhat here: https://play.golang.org/p/qTpuQ8tXMEZ

Bug: INTK-364 #comment
Change-Id: Ifc062929a28c2c09b8969c2562d4ddaa897afbe1
diff --git a/cmd/botanist/main.go b/cmd/botanist/main.go
index 233ba9d..c034321 100644
--- a/cmd/botanist/main.go
+++ b/cmd/botanist/main.go
@@ -86,6 +86,27 @@
 		OutputFile string `json:"output_file"`
 		Result     string `json:"result"`
 	} `json:"tests"`
+	Outputs map[string]string `json:"outputs,omitempty"`
+}
+
+func writeFileToTar(client *tftp.Client, tftpAddr *net.UDPAddr, tw *tar.Writer, testDir string, outputFile string) error {
+	writer, err := client.Receive(tftpAddr, path.Join(testDir, outputFile))
+	if err != nil {
+		return fmt.Errorf("failed to receive file %s: %v\n", outputFile, err)
+	}
+	hdr := &tar.Header{
+		Name: outputFile,
+		Size: writer.(tftp.Session).Size(),
+		Mode: 0666,
+	}
+	if err := tw.WriteHeader(hdr); err != nil {
+		return fmt.Errorf("failed to write file header: %v\n", err)
+	}
+	if _, err := writer.WriteTo(tw); err != nil {
+		return fmt.Errorf("failed to write file content: %v\n", err)
+	}
+
+	return nil
 }
 
 func runTests(ctx context.Context, config *Config, kernel, ramdisk string, args []string) error {
@@ -108,13 +129,13 @@
 
 	// Transfer kernel, ramdisk, and command line args onto the node.
 	client := tftp.NewClient()
-	tftpaddr := &net.UDPAddr{
+	tftpAddr := &net.UDPAddr{
 		IP:   addr.IP,
 		Port: tftp.ClientPort,
 		Zone: addr.Zone,
 	}
 
-	if err := transferFiles(client, tftpaddr, kernel, ramdisk, args); err != nil {
+	if err := transferFiles(client, tftpAddr, kernel, ramdisk, args); err != nil {
 		return fmt.Errorf("cannot transfer files: %v\n", err)
 	}
 
@@ -154,7 +175,7 @@
 	var buffer bytes.Buffer
 	var writer io.WriterTo
 	err = retry.Retry(ctx, retry.NewConstantBackoff(filePollInterval), func() error {
-		writer, err = client.Receive(tftpaddr, path.Join(testdir, fileName))
+		writer, err = client.Receive(tftpAddr, path.Join(testdir, fileName))
 		return err
 	})
 	if err != nil {
@@ -196,21 +217,14 @@
 	log.Printf("copying test output\n")
 
 	// Copy test output from the node.
+	for _, path := range result.Outputs {
+		if err = writeFileToTar(client, tftpAddr, tw, testdir, path); err != nil {
+			return err
+		}
+	}
 	for _, test := range result.Tests {
-		writer, err := client.Receive(tftpaddr, path.Join(testdir, test.OutputFile))
-		if err != nil {
-			return fmt.Errorf("failed to receive file %s: %v\n", test.OutputFile, err)
-		}
-		hdr := &tar.Header{
-			Name: test.OutputFile,
-			Size: writer.(tftp.Session).Size(),
-			Mode: 0666,
-		}
-		if err := tw.WriteHeader(hdr); err != nil {
-			return fmt.Errorf("failed to write file header: %v\n", err)
-		}
-		if _, err := writer.WriteTo(tw); err != nil {
-			return fmt.Errorf("failed to write file content: %v\n", err)
+		if err = writeFileToTar(client, tftpAddr, tw, testdir, test.OutputFile); err != nil {
+			return err
 		}
 	}