MCPcopy
hub / github.com/opencontainers/runc / TestMountCgroupRW

Function TestMountCgroupRW

libcontainer/integration/exec_test.go:881–921  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

879}
880
881func TestMountCgroupRW(t *testing.T) {
882 if testing.Short() {
883 return
884 }
885 config := newTemplateConfig(t, nil)
886 // clear the RO flag from cgroup mount
887 for _, m := range config.Mounts {
888 if m.Device == "cgroup" {
889 m.Flags = defaultMountFlags
890 break
891 }
892 }
893
894 buffers := runContainerOk(t, config, "mount")
895
896 mountInfo := buffers.Stdout.String()
897 lines := strings.SplitSeq(mountInfo, "\n")
898 for l := range lines {
899 if strings.HasPrefix(l, "tmpfs on /sys/fs/cgroup") {
900 if !strings.Contains(l, "rw") ||
901 !strings.Contains(l, "nosuid") ||
902 !strings.Contains(l, "nodev") ||
903 !strings.Contains(l, "noexec") {
904 t.Fatalf("Mode expected to contain 'rw,nosuid,nodev,noexec': %s", l)
905 }
906 if !strings.Contains(l, "mode=755") {
907 t.Fatalf("Mode expected to contain 'mode=755': %s", l)
908 }
909 continue
910 }
911 if !strings.HasPrefix(l, "cgroup") {
912 continue
913 }
914 if !strings.Contains(l, "rw") ||
915 !strings.Contains(l, "nosuid") ||
916 !strings.Contains(l, "nodev") ||
917 !strings.Contains(l, "noexec") {
918 t.Fatalf("Mode expected to contain 'rw,nosuid,nodev,noexec': %s", l)
919 }
920 }
921}
922
923func TestOomScoreAdj(t *testing.T) {
924 if testing.Short() {

Callers

nothing calls this directly

Calls 4

newTemplateConfigFunction · 0.85
runContainerOkFunction · 0.85
ContainsMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…