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
|
2013-06-24 19:06:49 +00:00
|
|
|
from salttesting import skipIf
|
2013-06-27 11:51:04 +00:00
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
|
|
|
# Import salt libs
|
|
|
|
import integration
|
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'
|
|
|
|
)
|
|
|
|
|
2013-02-05 20:57:53 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(SysctlModuleTest)
|