Improve socket handling for -x spawned fenrir instances.

This commit is contained in:
Storm Dragon
2026-05-07 23:24:54 -04:00
parent 0273f9b956
commit 8638bca1d5
53 changed files with 794 additions and 1072 deletions
+62
View File
@@ -216,6 +216,68 @@ class TestRemoteDataFormat:
assert result["success"] is False
assert "Unknown command format" in result["message"]
def test_list_instances_top_level_command(self, mock_environment):
"""Test listing registered Fenrir instances."""
self.manager.initialize(mock_environment)
with patch(
"fenrirscreenreader.core.remoteManager.remoteInstanceRegistry.list_instances",
return_value=[
{
"pid": 123,
"ppid": 100,
"screen_driver": "ptyDriver",
"keyboard_driver": "x11Driver",
"main_socket": True,
"x11_window_id": "0x123",
"socket_files": [
"/tmp/fenrirscreenreader-123.sock",
"/tmp/fenrirscreenreader-deamon.sock",
],
}
],
):
result = self.manager.handle_remote_incomming_with_response("ls")
assert result["success"] is True
assert "pid=123" in result["message"]
assert "x11_window_id=0x123" in result["message"]
assert "/tmp/fenrirscreenreader-123.sock" in result["message"]
def test_remote_incoming_suppresses_command_claimed_by_other_instance(
self, mock_environment, tmp_path
):
"""Test untargeted duplicate remote commands only run in one process."""
self.manager.initialize(mock_environment)
lock_path = tmp_path / "remote-command.lock"
lock_path.write_text("999999 1\n")
with patch.object(
self.manager,
"_get_remote_command_lock_path",
return_value=str(lock_path),
):
self.manager.handle_remote_incomming("command say duplicated")
mock_environment["runtime"]["OutputManager"].speak_text.assert_not_called()
def test_remote_incoming_allows_same_instance_repeat(
self, mock_environment, tmp_path
):
"""Test repeated direct commands to one instance are not suppressed."""
self.manager.initialize(mock_environment)
lock_path = tmp_path / "remote-command.lock"
with patch.object(
self.manager,
"_get_remote_command_lock_path",
return_value=str(lock_path),
):
self.manager.handle_remote_incomming("command say repeat")
self.manager.handle_remote_incomming("command say repeat")
assert mock_environment["runtime"]["OutputManager"].speak_text.call_count == 2
@pytest.mark.integration
@pytest.mark.remote