tests: set the times on a symlink
This currently fails as reported in https://github.com/rfjakob/gocryptfs/issues/35 . Also remove the spurious sleep in the test.
This commit is contained in:
parent
af5441dcd9
commit
8f1e51789d
@ -16,11 +16,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
"github.com/rfjakob/gocryptfs/internal/syscallcompat"
|
||||||
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
||||||
@ -571,7 +571,7 @@ func TestLchown(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set nanoseconds by path
|
// Set nanoseconds by path, normal file
|
||||||
func TestUtimesNano(t *testing.T) {
|
func TestUtimesNano(t *testing.T) {
|
||||||
path := test_helpers.DefaultPlainDir + "/utimesnano"
|
path := test_helpers.DefaultPlainDir + "/utimesnano"
|
||||||
err := ioutil.WriteFile(path, []byte("foobar"), 0600)
|
err := ioutil.WriteFile(path, []byte("foobar"), 0600)
|
||||||
@ -589,7 +589,6 @@ func TestUtimesNano(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
var st syscall.Stat_t
|
var st syscall.Stat_t
|
||||||
err = syscall.Stat(path, &st)
|
err = syscall.Stat(path, &st)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -603,6 +602,24 @@ func TestUtimesNano(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set nanoseconds by path, symlink
|
||||||
|
func TestUtimesNanoSymlink(t *testing.T) {
|
||||||
|
path := test_helpers.DefaultPlainDir + "/utimesnano_symlink"
|
||||||
|
err := os.Symlink("/some/nonexisting/file", path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// syscall.UtimesNano does not provide a way to pass AT_SYMLINK_NOFOLLOW,
|
||||||
|
// so we call the external utility "touch", which does.
|
||||||
|
cmd := exec.Command("touch", "--no-dereference", path)
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
err = cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set nanoseconds by fd
|
// Set nanoseconds by fd
|
||||||
func TestUtimesNanoFd(t *testing.T) {
|
func TestUtimesNanoFd(t *testing.T) {
|
||||||
path := test_helpers.DefaultPlainDir + "/utimesnanofd"
|
path := test_helpers.DefaultPlainDir + "/utimesnanofd"
|
||||||
|
Loading…
Reference in New Issue
Block a user