2013-02-05 20:57:53 +00:00
|
|
|
# Import python libs
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Import salt libs
|
2013-06-24 19:06:49 +00:00
|
|
|
try:
|
|
|
|
import integration
|
|
|
|
except ImportError:
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import os
|
|
|
|
sys.path.insert(
|
|
|
|
0, os.path.abspath(
|
|
|
|
os.path.join(
|
|
|
|
os.path.dirname(__file__), '../../'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
import integration
|
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-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')
|
|
|
|
|
2013-04-01 07:28:00 +00:00
|
|
|
@skipIf(not sys.platform.startswith('darwin'), 'Darwin (OS X) specific')
|
|
|
|
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)
|