summaryrefslogtreecommitdiff
path: root/pkg/sysinfo/sysinfo_linux_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-21 05:21:09 -0400
committerGitHub <noreply@github.com>2020-04-21 05:21:09 -0400
commit47d99fb6253238e7603fc96d5b9bbb14f1e8c948 (patch)
tree23f7e52d04fe78df60ba1a94c1ef5e7106ff8e82 /pkg/sysinfo/sysinfo_linux_test.go
parent8884f6a4f357ea64ad5f20f791ec0a09bdd36352 (diff)
parent532c7343a9af5fbdcc682f7f93c987b1f1e49b41 (diff)
downloadpodman-47d99fb6253238e7603fc96d5b9bbb14f1e8c948.tar.gz
podman-47d99fb6253238e7603fc96d5b9bbb14f1e8c948.tar.bz2
podman-47d99fb6253238e7603fc96d5b9bbb14f1e8c948.zip
Merge pull request #5647 from rhatdan/containers.conf
Update podmanV2 to use containers.conf
Diffstat (limited to 'pkg/sysinfo/sysinfo_linux_test.go')
-rw-r--r--pkg/sysinfo/sysinfo_linux_test.go104
1 files changed, 0 insertions, 104 deletions
diff --git a/pkg/sysinfo/sysinfo_linux_test.go b/pkg/sysinfo/sysinfo_linux_test.go
deleted file mode 100644
index 860784f2a..000000000
--- a/pkg/sysinfo/sysinfo_linux_test.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package sysinfo
-
-import (
- "io/ioutil"
- "os"
- "path"
- "path/filepath"
- "testing"
-
- "github.com/stretchr/testify/require"
- "golang.org/x/sys/unix"
-)
-
-func TestReadProcBool(t *testing.T) {
- tmpDir, err := ioutil.TempDir("", "test-sysinfo-proc")
- require.NoError(t, err)
- defer os.RemoveAll(tmpDir)
-
- procFile := filepath.Join(tmpDir, "read-proc-bool")
- err = ioutil.WriteFile(procFile, []byte("1"), 0644)
- require.NoError(t, err)
-
- if !readProcBool(procFile) {
- t.Fatal("expected proc bool to be true, got false")
- }
-
- if err := ioutil.WriteFile(procFile, []byte("0"), 0644); err != nil {
- t.Fatal(err)
- }
- if readProcBool(procFile) {
- t.Fatal("expected proc bool to be false, got true")
- }
-
- if readProcBool(path.Join(tmpDir, "no-exist")) {
- t.Fatal("should be false for non-existent entry")
- }
-
-}
-
-func TestCgroupEnabled(t *testing.T) {
- cgroupDir, err := ioutil.TempDir("", "cgroup-test")
- require.NoError(t, err)
- defer os.RemoveAll(cgroupDir)
-
- if cgroupEnabled(cgroupDir, "test") {
- t.Fatal("cgroupEnabled should be false")
- }
-
- err = ioutil.WriteFile(path.Join(cgroupDir, "test"), []byte{}, 0644)
- require.NoError(t, err)
-
- if !cgroupEnabled(cgroupDir, "test") {
- t.Fatal("cgroupEnabled should be true")
- }
-}
-
-func TestNew(t *testing.T) {
- sysInfo := New(false)
- require.NotNil(t, sysInfo)
- checkSysInfo(t, sysInfo)
-
- sysInfo = New(true)
- require.NotNil(t, sysInfo)
- checkSysInfo(t, sysInfo)
-}
-
-func checkSysInfo(t *testing.T, sysInfo *SysInfo) {
- // Check if Seccomp is supported, via CONFIG_SECCOMP.then sysInfo.Seccomp must be TRUE , else FALSE
- if err := unix.Prctl(unix.PR_GET_SECCOMP, 0, 0, 0, 0); err != unix.EINVAL {
- // Make sure the kernel has CONFIG_SECCOMP_FILTER.
- if err := unix.Prctl(unix.PR_SET_SECCOMP, unix.SECCOMP_MODE_FILTER, 0, 0, 0); err != unix.EINVAL {
- require.True(t, sysInfo.Seccomp)
- }
- } else {
- require.False(t, sysInfo.Seccomp)
- }
-}
-
-func TestNewAppArmorEnabled(t *testing.T) {
- // Check if AppArmor is supported. then it must be TRUE , else FALSE
- if _, err := os.Stat("/sys/kernel/security/apparmor"); err != nil {
- t.Skip("App Armor Must be Enabled")
- }
-
- sysInfo := New(true)
- require.True(t, sysInfo.AppArmor)
-}
-
-func TestNewAppArmorDisabled(t *testing.T) {
- // Check if AppArmor is supported. then it must be TRUE , else FALSE
- if _, err := os.Stat("/sys/kernel/security/apparmor"); !os.IsNotExist(err) {
- t.Skip("App Armor Must be Disabled")
- }
-
- sysInfo := New(true)
- require.False(t, sysInfo.AppArmor)
-}
-
-func TestNumCPU(t *testing.T) {
- cpuNumbers := NumCPU()
- if cpuNumbers <= 0 {
- t.Fatal("CPU returned must be greater than zero")
- }
-}