tests: cli_test: fix fd leak
One fd leak found in TestMountBackground.
This commit is contained in:
parent
22031d7e53
commit
9d7392a5be
@ -3,6 +3,7 @@ package cli
|
|||||||
// Test CLI operations like "-init", "-password" etc
|
// Test CLI operations like "-init", "-password" etc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -20,7 +21,13 @@ var testPw = []byte("test")
|
|||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
test_helpers.ResetTmpDir(false)
|
test_helpers.ResetTmpDir(false)
|
||||||
|
before := test_helpers.ListFds()
|
||||||
r := m.Run()
|
r := m.Run()
|
||||||
|
after := test_helpers.ListFds()
|
||||||
|
if len(before) != len(after) {
|
||||||
|
fmt.Printf("fd leak? before, after:\n%v\n%v\n", before, after)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
os.Exit(r)
|
os.Exit(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,6 +411,7 @@ func TestMountBackground(t *testing.T) {
|
|||||||
// We should get io.EOF when the child closes stdout
|
// We should get io.EOF when the child closes stdout
|
||||||
// and stderr.
|
// and stderr.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
pr.Close()
|
||||||
c1 <- struct{}{}
|
c1 <- struct{}{}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -76,9 +76,7 @@ func TestMain(m *testing.M) {
|
|||||||
r := m.Run()
|
r := m.Run()
|
||||||
after := test_helpers.ListFds()
|
after := test_helpers.ListFds()
|
||||||
if len(before) != len(after) {
|
if len(before) != len(after) {
|
||||||
fmt.Printf("fd leak? before, after:\n")
|
fmt.Printf("fd leak? before, after:\n%v\n%v\n", before, after)
|
||||||
fmt.Printf("%v\n", before)
|
|
||||||
fmt.Printf("%v\n", after)
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
|
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user