Skip to content

Commit

Permalink
[FAB-12167] build scc plugins with race as needed
Browse files Browse the repository at this point in the history
Change-Id: Ifc4e66de1bf0ce3c67d84e736f5871b67a4439e9
Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
  • Loading branch information
sykesm committed Sep 28, 2018
1 parent b0dc46c commit 940fd0f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/scc/loadsysccs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ func TestLoadSCCPluginInvalid(t *testing.T) {
assert.Panics(t, func() { loadPlugin("missing.so") }, "expected panic with invalid path")
}

// raceEnabled is set to true when the race build tag is enabled.
// see race_test.go
var raceEnabled bool

func buildExamplePlugin(t *testing.T, path, pluginPackage string) {
cmd := exec.Command("go", "build", "-tags", goBuildTags, "-o", path, "-buildmode=plugin", pluginPackage)
cmd := exec.Command("go", "build", "-tags", goBuildTags, "-o", path, "-buildmode=plugin")
if raceEnabled {
cmd.Args = append(cmd.Args, "-race")
}
cmd.Args = append(cmd.Args, pluginPackage)
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Error: %s, Could not build plugin: %s", err, output)
Expand Down
14 changes: 14 additions & 0 deletions core/scc/race_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// +build race
// +build pluginsenabled,cgo
// +build darwin,go1.10 linux,go1.10 linux,go1.9,!ppc64le

/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package scc

func init() {
raceEnabled = true
}

0 comments on commit 940fd0f

Please sign in to comment.