File: test_env.py

package info (click to toggle)
mpich 4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,184 kB
  • sloc: ansic: 1,040,629; cpp: 82,270; javascript: 40,763; perl: 27,933; python: 16,041; sh: 14,676; xml: 14,418; f90: 12,916; makefile: 9,270; fortran: 8,046; java: 4,635; asm: 324; ruby: 103; awk: 27; lisp: 19; php: 8; sed: 4
file content (40 lines) | stat: -rw-r--r-- 1,587 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest
import subprocess
import ctypes


def is_ibv_fork_support_needed():
    '''
    determine whether ibv(rdma-core)'s fork support is needed
    '''
    IBV_FORK_UNNEEDED = 2    # this value was taken from /usr/include/infiniband/verbs.h
    libibverbs = ctypes.cdll.LoadLibrary("libibverbs.so")
    # ibv (rdma-core)'s fork support is needed when
    # kernel space fork support is not available.
    # Newer version of rdma-core provided an API
    #      ibv_is_fork_initialized()
    # to query whether rdma-core's fork support is needed.
    # Older verison of rdma-core does not support this
    # API, so we always consider the fork support to
    # be needed.
    if hasattr(libibverbs, "ibv_is_fork_initialized"):
        return libibverbs.ibv_is_fork_initialized() != IBV_FORK_UNNEEDED
    else:
        return True


@pytest.mark.unit
def test_fork_huge_page_both_set(cmdline_args):
    """
    verify that when FI_EFA_FORK_SAFE and FI_EFA_USE_HUGE_PAGE was both set,
    application will abort
    """
    command = cmdline_args.populate_command("fi_mr_test", "host", additional_environment="FI_EFA_FORK_SAFE=1 FI_EFA_USE_HUGE_PAGE=1")
    process = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if is_ibv_fork_support_needed():
        assert process.returncode != 0
        err_msg = process.stderr.decode("utf-8")
        assert "The usage of huge page is incompatible with rdma-core's fork support" in err_msg
        assert "Your application will now abort" in err_msg
    else:
        assert process.returncode == 0