Exemple #1
0
def test_set_inheritable():
    fd1, fd2 = os.pipe()
    rposix.set_inheritable(fd1, True)
    assert rposix.get_inheritable(fd1) == True
    rposix.set_inheritable(fd1, False)
    assert rposix.get_inheritable(fd1) == False
    os.close(fd1)
    os.close(fd2)
Exemple #2
0
def test_set_inheritable():
    fd1, fd2 = os.pipe()
    rposix.set_inheritable(fd1, True)
    assert rposix.get_inheritable(fd1) == True
    rposix.set_inheritable(fd1, False)
    assert rposix.get_inheritable(fd1) == False
    os.close(fd1)
    os.close(fd2)
Exemple #3
0
def test_dup_dup2_non_inheritable():
    for preset in [False, True]:
        fd1, fd2 = os.pipe()
        rposix.set_inheritable(fd1, preset)
        rposix.set_inheritable(fd2, preset)
        fd3 = rposix.dup(fd1, True)
        assert rposix.get_inheritable(fd3) == True
        fd4 = rposix.dup(fd1, False)
        assert rposix.get_inheritable(fd4) == False
        rposix.dup2(fd2, fd4, False)
        assert rposix.get_inheritable(fd4) == False
        rposix.dup2(fd2, fd3, True)
        assert rposix.get_inheritable(fd3) == True
        os.close(fd1)
        os.close(fd2)
        os.close(fd3)
        os.close(fd4)
Exemple #4
0
def test_SetNonInheritableCache():
    cache = rposix.SetNonInheritableCache()
    fd1, fd2 = os.pipe()
    if sys.platform == 'win32':
        rposix.set_inheritable(fd1, True)
        rposix.set_inheritable(fd2, True)
    assert rposix.get_inheritable(fd1) == True
    assert rposix.get_inheritable(fd1) == True
    assert cache.cached_inheritable == -1
    cache.set_non_inheritable(fd1)
    assert cache.cached_inheritable == 1
    cache.set_non_inheritable(fd2)
    assert cache.cached_inheritable == 1
    assert rposix.get_inheritable(fd1) == False
    assert rposix.get_inheritable(fd1) == False
    os.close(fd1)
    os.close(fd2)
Exemple #5
0
def test_dup_dup2_non_inheritable():
    for preset in [False, True]:
        fd1, fd2 = os.pipe()
        rposix.set_inheritable(fd1, preset)
        rposix.set_inheritable(fd2, preset)
        fd3 = rposix.dup(fd1, True)
        assert rposix.get_inheritable(fd3) == True
        fd4 = rposix.dup(fd1, False)
        assert rposix.get_inheritable(fd4) == False
        rposix.dup2(fd2, fd4, False)
        assert rposix.get_inheritable(fd4) == False
        rposix.dup2(fd2, fd3, True)
        assert rposix.get_inheritable(fd3) == True
        os.close(fd1)
        os.close(fd2)
        os.close(fd3)
        os.close(fd4)
Exemple #6
0
def test_SetNonInheritableCache():
    cache = rposix.SetNonInheritableCache()
    fd1, fd2 = os.pipe()
    if sys.platform == 'win32':
        rposix.set_inheritable(fd1, True)
        rposix.set_inheritable(fd2, True)
    assert rposix.get_inheritable(fd1) == True
    assert rposix.get_inheritable(fd1) == True
    assert cache.cached_inheritable == -1
    cache.set_non_inheritable(fd1)
    assert cache.cached_inheritable == 1
    cache.set_non_inheritable(fd2)
    assert cache.cached_inheritable == 1
    assert rposix.get_inheritable(fd1) == False
    assert rposix.get_inheritable(fd1) == False
    os.close(fd1)
    os.close(fd2)