Cthulhu is no longer a fork. Now it is a screen reader written in Golang.
This commit is contained in:
1 parent
a998fe67de
commit
069fc674dc
708 files changed
+112482
-532
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package tentacle
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDelegatedReaderParent(t *testing.T) {
|
||||
parent, err := delegated_parent("0::/user.slice/test.service/reader\n")
|
||||
if err != nil || parent != "/sys/fs/cgroup/user.slice/test.service" {
|
||||
t.Fatalf("%s %v", parent, err)
|
||||
}
|
||||
for _, path := range []string{"0::/", "0::/test.service", "0::/session.scope/reader", "0::/test.service/../reader", "1:cpu:/test.service/reader"} {
|
||||
if _, err := delegated_parent(path); err == nil {
|
||||
t.Fatalf("accepted %q", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalLaunchListValidation(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "tentacles.json")
|
||||
for _, data := range []string{
|
||||
`[{"ID":"echo","Program":["/bin/true"]}]`,
|
||||
`[{"ID":"echo","Program":["relative"]}]`,
|
||||
`[{"ID":"echo","Program":["/bin/true"]},{"ID":"echo","Program":["/bin/true"]}]`,
|
||||
strings.Repeat(" ", MaxFrameBytes+1),
|
||||
`[{"ID":"echo","ID":"other","Program":["/bin/true"]}]`,
|
||||
} {
|
||||
if err := os.WriteFile(path, []byte(data), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
specs, err := LoadLocalSpecs(path)
|
||||
valid := data == `[{"ID":"echo","Program":["/bin/true"]}]`
|
||||
if (err == nil) != valid {
|
||||
t.Fatalf("validation: %v", err)
|
||||
}
|
||||
if valid && len(specs) != 1 {
|
||||
t.Fatal(specs)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user