Skip to content

Commit a0105e6

Browse files
committed
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.
1 parent 38936cb commit a0105e6

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

tests/reverse/correctness_test.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ func TestMtimePlus10(t *testing.T) {
382382
if err := os.WriteFile(long, nil, 0600); err != nil {
383383
t.Fatal(err)
384384
}
385-
var long_stat syscall.Stat_t
386-
if err := syscall.Stat(long, &long_stat); err != nil {
385+
long_stat, err := os.Stat(long)
386+
if err != nil {
387387
t.Fatal(err)
388388
}
389389

390-
var workdirA_stat syscall.Stat_t
391-
if err := syscall.Stat(workdirA, &workdirA_stat); err != nil {
390+
workdirA_stat, err := os.Stat(workdirA)
391+
if err != nil {
392392
t.Fatal(err)
393393
}
394394

@@ -400,31 +400,24 @@ func TestMtimePlus10(t *testing.T) {
400400
if len(matches) != 1 {
401401
t.Fatal(matches)
402402
}
403-
var name_stat syscall.Stat_t
404-
if err := syscall.Stat(matches[0], &name_stat); err != nil {
403+
name_stat, err := os.Stat(matches[0])
404+
if err != nil {
405405
t.Fatal(err)
406406
}
407-
if name_stat.Mtim.Sec != long_stat.Mtim.Sec+10 {
407+
if name_stat.ModTime().Unix() != long_stat.ModTime().Unix()+10 {
408408
t.Errorf(".name file should show mtime+10")
409409
}
410-
if name_stat.Ctim.Sec != long_stat.Ctim.Sec+10 {
411-
t.Errorf(".name file should show ctime+10")
412-
}
413410

411+
// Check gocryptfs.diriv
414412
if deterministic_names {
415413
// No gocryptfs.diriv
416414
return
417415
}
418-
419-
// Check gocryptfs.diriv
420-
var diriv_stat syscall.Stat_t
421-
if err := syscall.Stat(workdirB+"/gocryptfs.diriv", &diriv_stat); err != nil {
416+
diriv_stat, err := os.Stat(workdirB + "/gocryptfs.diriv")
417+
if err != nil {
422418
t.Fatal(err)
423419
}
424-
if diriv_stat.Mtim.Sec != workdirA_stat.Mtim.Sec+10 {
420+
if diriv_stat.ModTime().Unix() != workdirA_stat.ModTime().Unix()+10 {
425421
t.Errorf("diriv file should show mtime+10")
426422
}
427-
if diriv_stat.Ctim.Sec != workdirA_stat.Ctim.Sec+10 {
428-
t.Errorf("diriv file should show ctime+10")
429-
}
430423
}

0 commit comments

Comments
 (0)