예제 #1
0
def test_docs():
    env = {
        'sysctl': sysctl.Sysctl(context_wrap(SYSCTL_DOC_TEST)),
        'sysctl_conf': sysctl.SysctlConf(context_wrap(SYSCTL_CONF_TEST)),
        'sysctl_d_conf_etc': sysctl.SysctlDConfEtc(context_wrap(SYSCTL_CONF_TEST)),
        'sysctl_d_conf_usr': sysctl.SysctlDConfUsr(context_wrap(SYSCTL_CONF_TEST)),
        'sysctl_initramfs': sysctl.SysctlConfInitramfs(context_wrap(SYSCTL_CONF_INITRAMFS_TEST))
    }
    failed, total = doctest.testmod(sysctl, globs=env)
    assert failed == 0
예제 #2
0
def test_all_sysctl_conf_different_order():
    conf_1 = sysctl.SysctlConf(
        context_wrap(SYSCTL_CONF_TEST1, path=SYSCTL5_CONF_FILENAME))
    conf_2 = sysctl.SysctlDConfUsr(
        context_wrap(SYSCTL_CONF_TEST2, path=SYSCTL6_CONF_FILENAME))
    conf_3 = sysctl.SysctlDConfEtc(
        context_wrap(SYSCTL_CONF_TEST3, path=SYSCTL2_CONF_FILENAME))
    conf_4 = sysctl.SysctlDConfEtc(
        context_wrap(SYSCTL_CONF_TEST4, path=SYSCTL4_CONF_FILENAME))
    r = sysctl_conf.SysctlConfs(conf_1, [conf_2], [conf_3, conf_4])

    assert r['kernel.domainname'] == 'example.com'
    assert r['kernel.sysrq'] == '16'
    assert r.search("dirty") == {
        "vm.dirty_ratio": "30",
        "vm.dirty_background_ratio": "50"
    }
예제 #3
0
def test_all_sysctl_conf():
    conf_1 = sysctl.SysctlConf(
        context_wrap(SYSCTL_CONF_TEST1, path=SYSCTL5_CONF_FILENAME))
    conf_2 = sysctl.SysctlDConfEtc(
        context_wrap(SYSCTL_CONF_TEST2, path=SYSCTL2_CONF_FILENAME))
    conf_3 = sysctl.SysctlDConfEtc(
        context_wrap(SYSCTL_CONF_TEST3, path=SYSCTL3_CONF_FILENAME))
    r = sysctl_conf.SysctlConfs(conf_1, None, [conf_2, conf_3])

    assert r['kernel.domainname'] == 'example.com'
    assert r['kernel.modprobe'] == '/sbin/mod probe'
    assert 'kernel.domainname.invalid' not in r
    assert r.search("dirty") == {
        "vm.dirty_ratio": "15",
        "vm.dirty_background_ratio": "5"
    }
    assert r.search("test") == {}
예제 #4
0
def test_sysctl_conf():
    r = sysctl.SysctlConf(context_wrap(SYSCTL_CONF_TEST))
    assert keys_in(['kernel.domainname', 'kernel.modprobe'], r.data)
    assert r.data['kernel.domainname'] == 'example.com'
    assert r.data['kernel.modprobe'] == '/sbin/mod probe'