跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

rooted_casefold_linux_test.go

61 行 · 1.7 KB历史下载
1//go:build linux
2
3package reversesshfs
4
5import (
6 "os"
7 "os/exec"
8 "path/filepath"
9 "strings"
10 "testing"
11)
12
13// Every spelling of ".git" that a casefold directory (ext4, f2fs, tmpfs with the feature) takes as
14// the same entry is the same name for sameName. The directory is made under $CASEFOLD_DIR, or the
15// temporary folder; the test is skipped where that is not a file system with the feature.
16// To get one: mke2fs -t ext4 -O casefold -E encoding=utf8 image, mounted.
17func TestSameNameCasefold(t *testing.T) {
18 if testing.Short() {
19 t.Skip("short")
20 }
21 base := os.Getenv("CASEFOLD_DIR")
22 if base == "" {
23 base = t.TempDir()
24 }
25 dir := filepath.Join(base, "cf")
26 if err := os.MkdirAll(dir, 0o755); err != nil {
27 t.Skip(err)
28 }
29 t.Cleanup(func() { os.RemoveAll(dir) })
30 if out, err := exec.Command("chattr", "+F", dir).CombinedOutput(); err != nil {
31 t.Skipf("no casefold directory here: %v: %s", err, out)
32 }
33 if err := os.Mkdir(filepath.Join(dir, ".git"), 0o755); err != nil {
34 t.Fatal(err)
35 }
36 if _, err := os.Lstat(filepath.Join(dir, ".GIT")); err != nil {
37 t.Skip("the directory is case sensitive")
38 }
39 var found int
40 for r := rune(0x80); r <= 0x10ffff; r++ {
41 if r >= 0xd800 && r <= 0xdfff {
42 continue
43 }
44 s := string(r)
45 for _, name := range []string{".g" + s + "it", ".gi" + s + "t", ".git" + s, s + ".git", s + "git", ".g" + s + "t", ".gi" + s, "." + s + "it"} {
46 if strings.Contains(name, "/") {
47 continue
48 }
49 if _, err := os.Lstat(filepath.Join(dir, name)); err != nil {
50 continue
51 }
52 found++
53 if !sameName(name, ".git") {
54 t.Errorf("%+q is .git on this file system, and sameName says it is not", name)
55 }
56 }
57 }
58 if found == 0 {
59 t.Error("no spelling found: the test does not reach the file system")
60 }
61}