From 873324d52b3b22e5abd4990a0659e78caaaa6c35 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 21 Apr 2018 19:38:40 +0000 Subject: [PATCH] firmware: don't truncate queued RPCs (fixes #985). --- artiq/firmware/runtime/session.rs | 2 +- artiq/test/coredevice/test_stress.py | 29 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 artiq/test/coredevice/test_stress.py diff --git a/artiq/firmware/runtime/session.rs b/artiq/firmware/runtime/session.rs index 1cb26509e..8b42329ee 100644 --- a/artiq/firmware/runtime/session.rs +++ b/artiq/firmware/runtime/session.rs @@ -522,7 +522,7 @@ fn process_kern_queued_rpc(stream: &mut TcpStream, let length = NetworkEndian::read_u32(slice) as usize; host_write(stream, host::Reply::RpcRequest { async: true })?; debug!("{:?}", &slice[4..][..length]); - stream.write(&slice[4..][..length])?; + stream.write_all(&slice[4..][..length])?; Ok(()) }) } diff --git a/artiq/test/coredevice/test_stress.py b/artiq/test/coredevice/test_stress.py new file mode 100644 index 000000000..a7037f156 --- /dev/null +++ b/artiq/test/coredevice/test_stress.py @@ -0,0 +1,29 @@ +import os +import time +import unittest + +from artiq.experiment import * +from artiq.test.hardware_testbench import ExperimentCase + + +artiq_low_latency = os.getenv("ARTIQ_LOW_LATENCY") + + +class _Stress(EnvExperiment): + def build(self): + self.setattr_device("core") + + @rpc(flags={"async"}) + def sink(self, data): + pass + + @kernel + def async_rpc(self, n): + for _ in range(n): + self.sink(b"") + + +class StressTest(ExperimentCase): + def test_async_rpc(self): + exp = self.create(_Stress) + exp.async_rpc(16000)