criu icon indicating copy to clipboard operation
criu copied to clipboard

Need test for robust lists

Open xemul opened this issue 8 years ago • 4 comments

xemul avatar Mar 04 '16 13:03 xemul

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Jan 25 '21 00:01 github-actions[bot]

https://man7.org/linux/man-pages/man2/get_robust_list.2.html

mihalicyn avatar Mar 13 '23 08:03 mihalicyn

Hello @mihalicyn

def test_robust_lists():
    # Starting a process with a robust list
    pid = os.fork()
    if pid == 0:
        # Child process
        robust_list = [1, 2, 3]
        prctl(PR_SET_NAME, "child")
        set_robust_list(robust_list)
        # Wait for a signal to terminate
        signal.pause()
        os._exit(0)
    else:
        # Parent process
        prctl(PR_SET_NAME, "parent")
        # Check that the child process has a robust list
        child_list = get_robust_list(pid)
        assert child_list == [1, 2, 3]
        # Send a signal to the child process
        os.kill(pid, signal.SIGUSR1)
        os.waitpid(pid, 0)

This test case checks that the list exists using get_robust_list(), sends a signal to the child process, and waits for it to terminate. This tests several code paths related to robust lists and can be used as a starting point for additional tests.

linktorahulraj avatar Mar 26 '23 11:03 linktorahulraj

Hello @mihalicyn

def test_robust_lists():
    # Starting a process with a robust list
    pid = os.fork()
    if pid == 0:
        # Child process
        robust_list = [1, 2, 3]
        prctl(PR_SET_NAME, "child")
        set_robust_list(robust_list)
        # Wait for a signal to terminate
        signal.pause()
        os._exit(0)
    else:
        # Parent process
        prctl(PR_SET_NAME, "parent")
        # Check that the child process has a robust list
        child_list = get_robust_list(pid)
        assert child_list == [1, 2, 3]
        # Send a signal to the child process
        os.kill(pid, signal.SIGUSR1)
        os.waitpid(pid, 0)

This test case checks that the list exists using get_robust_list(), sends a signal to the child process, and waits for it to terminate. This tests several code paths related to robust lists and can be used as a starting point for additional tests.

Have you tried to run this code?

mihalicyn avatar Mar 26 '23 12:03 mihalicyn