tests: copy permissions when copying files

On the failover path, copy the permission bits (a.k.a. file mode),
specially the execution bit.
This commit is contained in:
Mahmood Ali
2020-09-30 12:02:36 -04:00
parent 7b9d6a3552
commit 0f2af169ad

View File

@@ -495,7 +495,10 @@ func copyFile(t *testing.T, src, dst string) {
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
defer in.Close()
out, err := os.Create(dst)
ins, err := in.Stat()
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
out, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, ins.Mode())
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
defer func() {
if err := out.Close(); err != nil {
@@ -633,6 +636,8 @@ func TestExecutor_Start_NonExecutableBinaries(pt *testing.T) {
}
return true, nil
}, func(err error) {
stderr := strings.TrimSpace(string(testExecCmd.stderr.String()))
t.Logf("stderr: %v", stderr)
require.NoError(err)
})
})