mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-02 23:27:31 -04:00
unix: add Renameat on dragonfly
Also add a test now that all unices have Renameat. Change-Id: I9098662569e9910122dc686559bbd04be06328fa Reviewed-on: https://go-review.googlesource.com/c/157898 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
a457fd0364
commit
5552a988b7
@@ -623,6 +623,29 @@ func TestMkdev(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenameat(t *testing.T) {
|
||||
defer chtmpdir(t)()
|
||||
|
||||
from, to := "renamefrom", "renameto"
|
||||
|
||||
touch(t, from)
|
||||
|
||||
err := unix.Renameat(unix.AT_FDCWD, from, unix.AT_FDCWD, to)
|
||||
if err != nil {
|
||||
t.Fatalf("Renameat: unexpected error: %v", err)
|
||||
}
|
||||
|
||||
_, err = os.Stat(to)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
_, err = os.Stat(from)
|
||||
if err == nil {
|
||||
t.Errorf("Renameat: stat of renamed file %q unexpectedly suceeded", from)
|
||||
}
|
||||
}
|
||||
|
||||
// mktmpfifo creates a temporary FIFO and provides a cleanup function.
|
||||
func mktmpfifo(t *testing.T) (*os.File, func()) {
|
||||
err := unix.Mkfifo("fifo", 0666)
|
||||
|
||||
Reference in New Issue
Block a user