diff options
| author | Jakob Unterwurzacher | 2016-09-25 16:17:26 +0200 | 
|---|---|---|
| committer | Jakob Unterwurzacher | 2016-09-25 16:17:26 +0200 | 
| commit | 8f1e51789dd29b9fae82a059e2890bf9873cdd4c (patch) | |
| tree | d083de71212e21f5a801effa8ac8d5b96bb54bac | |
| parent | af5441dcd9033e81da43ab77887a7b5aac693ab6 (diff) | |
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.
| -rw-r--r-- | tests/matrix/matrix_test.go | 23 | 
1 files changed, 20 insertions, 3 deletions
| diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go index 853fb0e..ebca867 100644 --- a/tests/matrix/matrix_test.go +++ b/tests/matrix/matrix_test.go @@ -16,11 +16,11 @@ import (  	"fmt"  	"io/ioutil"  	"os" +	"os/exec"  	"runtime"  	"sync"  	"syscall"  	"testing" -	"time"  	"github.com/rfjakob/gocryptfs/internal/syscallcompat"  	"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) {  	path := test_helpers.DefaultPlainDir + "/utimesnano"  	err := ioutil.WriteFile(path, []byte("foobar"), 0600) @@ -589,7 +589,6 @@ func TestUtimesNano(t *testing.T) {  	if err != nil {  		t.Fatal(err)  	} -	time.Sleep(1 * time.Second)  	var st syscall.Stat_t  	err = syscall.Stat(path, &st)  	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  func TestUtimesNanoFd(t *testing.T) {  	path := test_helpers.DefaultPlainDir + "/utimesnanofd" | 
