2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2013-02-05 20:57:53 +00:00
|
|
|
# Import python libs
|
2014-11-21 19:05:13 +00:00
|
|
|
from __future__ import absolute_import
|
2013-02-05 20:57:53 +00:00
|
|
|
import sys
|
|
|
|
|
2013-06-24 22:53:59 +00:00
|
|
|
# Import Salt Testing libs
|
2017-02-27 15:59:04 +00:00
|
|
|
import tests.integration as integration
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import skipIf
|
2013-02-05 20:57:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SysctlModuleTest(integration.ModuleCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(SysctlModuleTest, self).setUp()
|
|
|
|
ret = self.run_function('cmd.has_exec', ['sysctl'])
|
|
|
|
if not ret:
|
|
|
|
self.skipTest('sysctl not found')
|
|
|
|
|
|
|
|
def test_show(self):
|
|
|
|
ret = self.run_function('sysctl.show')
|
|
|
|
self.assertIsInstance(ret, dict, 'sysctl.show return wrong type')
|
|
|
|
self.assertGreater(len(ret), 10, 'sysctl.show return few data')
|
|
|
|
|
|
|
|
@skipIf(not sys.platform.startswith('linux'), 'Linux specific')
|
|
|
|
def test_show_linux(self):
|
|
|
|
ret = self.run_function('sysctl.show')
|
|
|
|
self.assertIn('kernel.ostype', ret, 'kernel.ostype absent')
|
|
|
|
|
|
|
|
@skipIf(not sys.platform.startswith('freebsd'), 'FreeBSD specific')
|
|
|
|
def test_show_freebsd(self):
|
|
|
|
ret = self.run_function('sysctl.show')
|
|
|
|
self.assertIn('vm.vmtotal', ret, 'Multiline variable absent')
|
|
|
|
self.assertGreater(ret.get('vm.vmtotal').splitlines(),
|
|
|
|
1,
|
|
|
|
'Multiline value was parsed wrong')
|
|
|
|
|
2014-09-04 08:23:59 +00:00
|
|
|
@skipIf(not sys.platform.startswith('openbsd'), 'OpenBSD specific')
|
|
|
|
def test_show_openbsd(self):
|
|
|
|
ret = self.run_function('sysctl.show')
|
|
|
|
self.assertIn('kern.ostype', ret, 'kern.ostype absent')
|
|
|
|
self.assertEqual(
|
|
|
|
ret.get('kern.ostype'), 'OpenBSD', 'Incorrect kern.ostype'
|
|
|
|
)
|
|
|
|
|
2016-12-28 21:49:46 +00:00
|
|
|
@skipIf(not sys.platform.startswith('darwin'), 'Darwin (macOS) specific')
|
2013-04-01 07:28:00 +00:00
|
|
|
def test_show_darwin(self):
|
|
|
|
ret = self.run_function('sysctl.show')
|
|
|
|
self.assertIn('kern.ostype', ret, 'kern.ostype absent')
|
2013-06-24 22:53:59 +00:00
|
|
|
self.assertEqual(
|
|
|
|
ret.get('kern.ostype'), 'Darwin', 'Incorrect kern.ostype'
|
|
|
|
)
|