-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
639d211
commit 0f3049c
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
|
||
from flightgear_python.fg_if import CtrlsConnection | ||
|
||
|
||
pytestmark = pytest.mark.fg_integration | ||
ctrls_version = 27 # FlightGear-2020.3.19-x86_64.AppImage | ||
|
||
|
||
def test_ctrls_rx_and_tx_integration(): | ||
def rx_cb(ctrls_data, event_pipe): | ||
(run_idx,) = event_pipe.child_recv() | ||
child_callback_version = ctrls_data['version'] | ||
event_pipe.child_send( | ||
( | ||
run_idx, | ||
child_callback_version, | ||
) | ||
) | ||
return ctrls_data | ||
|
||
ctrls_c = CtrlsConnection(ctrls_version) | ||
ctrls_c.connect_rx('localhost', 5503, rx_cb) | ||
ctrls_c.connect_tx('localhost', 5504) | ||
|
||
for i in range(10): | ||
ctrls_c.event_pipe.parent_send((i,)) | ||
# manually call the process instead of having the process spawn | ||
ctrls_c._fg_packet_roundtrip() | ||
run_idx, parent_callback_version = ctrls_c.event_pipe.parent_recv() | ||
assert run_idx == i | ||
assert parent_callback_version == ctrls_version | ||
|
||
# Prevent 'ResourceWarning: unclosed' warning | ||
ctrls_c.fg_rx_sock.close() | ||
ctrls_c.fg_tx_sock.close() |