diff options
| author | Jakob Unterwurzacher | 2025-01-18 14:46:14 +0100 | 
|---|---|---|
| committer | Jakob Unterwurzacher | 2025-01-18 14:46:14 +0100 | 
| commit | a0105e65cde9f4643a896770a9629da644613a8a (patch) | |
| tree | 3126c2be04ba72c336e5f0e40dcbbcb6a108e42b /tests | |
| parent | 38936cba4e319525875feaa5d44b85819692e056 (diff) | |
tests: reverse: TestMtimePlus10: fix darwin build
Darwin does not have Stat_t.mtim:
+ go test -c -tags without_openssl -o /dev/null github.com/rfjakob/gocryptfs/v2/tests/reverse
Error: tests/reverse/correctness_test.go:407:15: name_stat.Mtim undefined (type syscall.Stat_t has no field or method Mtim)
Error: tests/reverse/correctness_test.go:407:37: long_stat.Mtim undefined (type syscall.Stat_t has no field or method Mtim)
Error: tests/reverse/correctness_test.go:410:15: name_stat.Ctim undefined (type syscall.Stat_t has no field or method Ctim)
Error: tests/reverse/correctness_test.go:410:37: long_stat.Ctim undefined (type syscall.Stat_t has no field or method Ctim)
Error: tests/reverse/correctness_test.go:424:16: diriv_stat.Mtim undefined (type syscall.Stat_t has no field or method Mtim)
Error: tests/reverse/correctness_test.go:424:42: workdirA_stat.Mtim undefined (type syscall.Stat_t has no field or method Mtim)
Error: tests/reverse/correctness_test.go:427:16: diriv_stat.Ctim undefined (type syscall.Stat_t has no field or method Ctim)
Error: tests/reverse/correctness_test.go:427:42: workdirA_stat.Ctim undefined (type syscall.Stat_t has no field or method Ctim)
Switch to os.Stat.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/reverse/correctness_test.go | 29 | 
1 files changed, 11 insertions, 18 deletions
| diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go index c93c32a..e4684df 100644 --- a/tests/reverse/correctness_test.go +++ b/tests/reverse/correctness_test.go @@ -382,13 +382,13 @@ func TestMtimePlus10(t *testing.T) {  	if err := os.WriteFile(long, nil, 0600); err != nil {  		t.Fatal(err)  	} -	var long_stat syscall.Stat_t -	if err := syscall.Stat(long, &long_stat); err != nil { +	long_stat, err := os.Stat(long) +	if err != nil {  		t.Fatal(err)  	} -	var workdirA_stat syscall.Stat_t -	if err := syscall.Stat(workdirA, &workdirA_stat); err != nil { +	workdirA_stat, err := os.Stat(workdirA) +	if err != nil {  		t.Fatal(err)  	} @@ -400,31 +400,24 @@ func TestMtimePlus10(t *testing.T) {  	if len(matches) != 1 {  		t.Fatal(matches)  	} -	var name_stat syscall.Stat_t -	if err := syscall.Stat(matches[0], &name_stat); err != nil { +	name_stat, err := os.Stat(matches[0]) +	if err != nil {  		t.Fatal(err)  	} -	if name_stat.Mtim.Sec != long_stat.Mtim.Sec+10 { +	if name_stat.ModTime().Unix() != long_stat.ModTime().Unix()+10 {  		t.Errorf(".name file should show mtime+10")  	} -	if name_stat.Ctim.Sec != long_stat.Ctim.Sec+10 { -		t.Errorf(".name file should show ctime+10") -	} +	// Check gocryptfs.diriv  	if deterministic_names {  		// No gocryptfs.diriv  		return  	} - -	// Check gocryptfs.diriv -	var diriv_stat syscall.Stat_t -	if err := syscall.Stat(workdirB+"/gocryptfs.diriv", &diriv_stat); err != nil { +	diriv_stat, err := os.Stat(workdirB + "/gocryptfs.diriv") +	if err != nil {  		t.Fatal(err)  	} -	if diriv_stat.Mtim.Sec != workdirA_stat.Mtim.Sec+10 { +	if diriv_stat.ModTime().Unix() != workdirA_stat.ModTime().Unix()+10 {  		t.Errorf("diriv file should show mtime+10")  	} -	if diriv_stat.Ctim.Sec != workdirA_stat.Ctim.Sec+10 { -		t.Errorf("diriv file should show ctime+10") -	}  } | 
