Skip to content

Commit

Permalink
3.10 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-usielski committed Nov 22, 2024
1 parent b6c4ba8 commit 400d2fc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, 3.13]
exclude:
- python-version: "3.7"
runs-on: macos-latest
# python-version: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, 3.13]
python-version: ["3.10", 3.11, 3.12, 3.13]
env:
MOLER_DEBUG_THREADS: True
PYTHON_COVERAGE: '3.13'
Expand Down
14 changes: 7 additions & 7 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

__author__ = 'Grzegorz Latuszek, Marcin Usielski, Michal Ernst'
__copyright__ = 'Copyright (C) 2018-2023, Nokia'
__copyright__ = 'Copyright (C) 2018-2024, Nokia'
__email__ = '[email protected], [email protected], [email protected]'

from pytest import fixture
Expand All @@ -21,20 +21,20 @@


current_process = psutil.Process()
if platform.system() == 'Linux':
(max_open_files_limit_soft, max_open_files_limit_hard) = current_process.rlimit(psutil.RLIMIT_NOFILE)
else:
if platform.system() == 'Windows':
# https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio?view=vs-2019
(max_open_files_limit_soft, max_open_files_limit_hard) = (510, 512) # TODO: any way on Win?
else:
(max_open_files_limit_soft, max_open_files_limit_hard) = current_process.rlimit(psutil.RLIMIT_NOFILE)


def system_resources_usage():
if platform.system() == 'Linux':
curr_fds_open = current_process.num_fds()
else:
if platform.system() == 'Windows':
ofiles = current_process.open_files()
osockets = current_process.connections(kind="all")
curr_fds_open = len(ofiles) + len(osockets) # TODO: any better way on Win?
else:
curr_fds_open = current_process.num_fds()
curr_threads_nb = threading.active_count()
return curr_fds_open, curr_threads_nb

Expand Down
23 changes: 23 additions & 0 deletions test/crt/test_unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from moler.event_awaiter import EventAwaiter


@pytest.mark.skipif('Darwin' == platform.system(), reason="No ip on Macos on Github")
def test_many_commands_wait(unix_terminal):
unix = unix_terminal
cmd_ip_link = unix.get_cmd(cmd_name="ip_link", cmd_params={'action': 'show'})
Expand All @@ -29,13 +30,34 @@ def test_many_commands_wait(unix_terminal):
assert "PWD" in env_ret


def test_many_commands_wait_ping(unix_terminal):
unix = unix_terminal
count_ping_1 = 1
count_ping_2 = 2
cmd_ping_1 = unix.get_cmd(cmd_name="ping", cmd_params={'options': f"-c {count_ping_1}", 'destination': '127.0.0.1'})
cmd_ping_2 = unix.get_cmd(cmd_name="ping", cmd_params={'options': f"-c {count_ping_2}", 'destination': '127.0.0.1'})
cmd_whoami = unix.get_cmd(cmd_name="whoami")
cmd_ping_1.start()
cmd_ping_2.start()
cmd_whoami.start()
assert True is EventAwaiter.wait_for_all(timeout=10, events=[cmd_ping_1, cmd_ping_2, cmd_whoami])
ret_whoami = cmd_whoami.result()
assert getpass.getuser() == ret_whoami['USER']
assert cmd_ping_1.result() is not None
assert cmd_ping_1.result()['packets_transmitted'] == count_ping_1
assert cmd_ping_2.result() is not None
assert cmd_ping_2.result()['packets_transmitted'] == count_ping_2


@pytest.mark.skipif('Darwin' == platform.system(), reason="No ip on Macos on Github")
def test_ip_link(unix_terminal):
unix = unix_terminal
cmd_ip = unix.get_cmd(cmd_name="ip_link", cmd_params={'action': 'show'})
ret = cmd_ip()
assert ret is not None


@pytest.mark.skipif('Darwin' == platform.system(), reason="No ip on Macos on Github")
def test_ip_neigh(unix_terminal):
unix = unix_terminal
cmd_ip = unix.get_cmd(cmd_name="ip_neigh", cmd_params={'options': 'show'})
Expand Down Expand Up @@ -104,6 +126,7 @@ def test_7z(unix_terminal):
assert cmd_7z is not None


@pytest.mark.skipif('Darwin' == platform.system(), reason="No md5sum on Macos on Github")
def test_cp_md5sum_cat_mv_rm_ls(unix_terminal):
unix = unix_terminal
f = tempfile.NamedTemporaryFile(delete=False)
Expand Down
4 changes: 4 additions & 0 deletions test/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import time
import pytest
import sys
import skip


pytestmark = pytest.mark.skipif('Linux' != platform.system(), reason="Skip for no Linux system.")


def test_job():
Expand Down

0 comments on commit 400d2fc

Please sign in to comment.