Skip to content

Commit

Permalink
Inline ifs and change log.Fatalf + Error() calls by log.Fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi committed May 4, 2021
1 parent c1aa284 commit 0e2c492
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
5 changes: 2 additions & 3 deletions testbed/testbed/child_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,8 @@ func (cp *ChildProcess) WatchResourceConsumption() error {
cp.fetchCPUUsage()

if err := cp.checkAllowedResourceUsage(); err != nil {
_, errStop := cp.Stop()
if errStop != nil {
log.Printf("Failed to stop child process: %v", errStop)
if _, errStop := cp.Stop(); errStop != nil {
log.Printf("Failed to stop child process: %v", err)
}
return err
}
Expand Down
13 changes: 6 additions & 7 deletions testbed/testbed/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ func (r *PerformanceResults) Init(resultsDir string) {
r.perTestResults = []*PerformanceTestResult{}

// Create resultsSummary file
var err error
err = os.MkdirAll(resultsDir, os.FileMode(0755))
if err != nil {
log.Fatalf(err.Error())
if err := os.MkdirAll(resultsDir, os.FileMode(0755)); err != nil {
log.Fatal(err)
}
var err error
r.resultsFile, err = os.Create(path.Join(r.resultsDir, "TESTRESULTS.md"))
if err != nil {
log.Fatalf(err.Error())
log.Fatal(err)
}

// Write the header
Expand Down Expand Up @@ -149,12 +148,12 @@ func (r *CorrectnessResults) Init(resultsDir string) {

// Create resultsSummary file
if err := os.MkdirAll(resultsDir, os.FileMode(0755)); err != nil {
log.Fatalf(err.Error())
log.Fatal(err)
}
var err error
r.resultsFile, err = os.Create(path.Join(r.resultsDir, "CORRECTNESSRESULTS.md"))
if err != nil {
log.Fatalf(err.Error())
log.Fatal(err)
}

// Write the header
Expand Down
3 changes: 1 addition & 2 deletions testbed/testbed/test_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ func (tc *TestCase) StartAgent(args ...string) {

// StopAgent stops agent process.
func (tc *TestCase) StopAgent() {
_, err := tc.agentProc.Stop()
if err != nil {
if _, err := tc.agentProc.Stop(); err != nil {
tc.indicateError(err)
}
}
Expand Down

0 comments on commit 0e2c492

Please sign in to comment.