2024-08-10 07:31:56 +08:00
|
|
|
//go:build !windows
|
2020-12-16 23:26:59 +08:00
|
|
|
|
|
|
|
package copier
|
|
|
|
|
|
|
|
import (
|
2025-04-01 13:26:09 +08:00
|
|
|
"os"
|
2020-12-16 23:26:59 +08:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2025-04-01 13:26:09 +08:00
|
|
|
const (
|
|
|
|
testModeMask = int64(os.ModePerm)
|
|
|
|
testIgnoreSymlinkDates = false
|
|
|
|
)
|
|
|
|
|
2020-12-16 23:26:59 +08:00
|
|
|
func TestPutChroot(t *testing.T) {
|
|
|
|
if uid != 0 {
|
2021-04-14 02:09:21 +08:00
|
|
|
t.Skip("chroot() requires root privileges, skipping")
|
2020-12-16 23:26:59 +08:00
|
|
|
}
|
|
|
|
couldChroot := canChroot
|
|
|
|
canChroot = true
|
|
|
|
testPut(t)
|
|
|
|
canChroot = couldChroot
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStatChroot(t *testing.T) {
|
|
|
|
if uid != 0 {
|
2021-04-14 02:09:21 +08:00
|
|
|
t.Skip("chroot() requires root privileges, skipping")
|
2020-12-16 23:26:59 +08:00
|
|
|
}
|
|
|
|
couldChroot := canChroot
|
|
|
|
canChroot = true
|
|
|
|
testStat(t)
|
|
|
|
canChroot = couldChroot
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetSingleChroot(t *testing.T) {
|
|
|
|
if uid != 0 {
|
2021-04-14 02:09:21 +08:00
|
|
|
t.Skip("chroot() requires root privileges, skipping")
|
2020-12-16 23:26:59 +08:00
|
|
|
}
|
|
|
|
couldChroot := canChroot
|
|
|
|
canChroot = true
|
|
|
|
testGetSingle(t)
|
|
|
|
canChroot = couldChroot
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetMultipleChroot(t *testing.T) {
|
|
|
|
if uid != 0 {
|
2021-04-14 02:09:21 +08:00
|
|
|
t.Skip("chroot() requires root privileges, skipping")
|
2020-12-16 23:26:59 +08:00
|
|
|
}
|
|
|
|
couldChroot := canChroot
|
|
|
|
canChroot = true
|
|
|
|
testGetMultiple(t)
|
|
|
|
canChroot = couldChroot
|
|
|
|
}
|
|
|
|
|
2021-03-03 05:06:27 +08:00
|
|
|
func TestEvalChroot(t *testing.T) {
|
|
|
|
if uid != 0 {
|
2021-04-14 02:09:21 +08:00
|
|
|
t.Skip("chroot() requires root privileges, skipping")
|
2021-03-03 05:06:27 +08:00
|
|
|
}
|
|
|
|
couldChroot := canChroot
|
|
|
|
canChroot = true
|
|
|
|
testEval(t)
|
|
|
|
canChroot = couldChroot
|
|
|
|
}
|
|
|
|
|
2020-12-16 23:26:59 +08:00
|
|
|
func TestMkdirChroot(t *testing.T) {
|
|
|
|
if uid != 0 {
|
2021-04-14 02:09:21 +08:00
|
|
|
t.Skip("chroot() requires root privileges, skipping")
|
2020-12-16 23:26:59 +08:00
|
|
|
}
|
|
|
|
couldChroot := canChroot
|
|
|
|
canChroot = true
|
|
|
|
testMkdir(t)
|
|
|
|
canChroot = couldChroot
|
|
|
|
}
|
2021-04-20 06:01:13 +08:00
|
|
|
|
|
|
|
func TestRemoveChroot(t *testing.T) {
|
|
|
|
if uid != 0 {
|
|
|
|
t.Skip("chroot() requires root privileges, skipping")
|
|
|
|
}
|
|
|
|
couldChroot := canChroot
|
|
|
|
canChroot = true
|
|
|
|
testRemove(t)
|
|
|
|
canChroot = couldChroot
|
|
|
|
}
|