From 1cf59fd2c04ac3aa468af3fb19bcdcaa15aebf1f Mon Sep 17 00:00:00 2001 From: deadprogram Date: Wed, 3 May 2017 10:53:40 +0200 Subject: [PATCH] aio: avoid race condition on starting test Signed-off-by: deadprogram --- drivers/aio/analog_sensor_driver_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/aio/analog_sensor_driver_test.go b/drivers/aio/analog_sensor_driver_test.go index c20bad37..eed5da6f 100644 --- a/drivers/aio/analog_sensor_driver_test.go +++ b/drivers/aio/analog_sensor_driver_test.go @@ -40,8 +40,6 @@ func TestAnalogSensorDriverStart(t *testing.T) { a := newAioTestAdaptor() d := NewAnalogSensorDriver(a, "1") - gobottest.Assert(t, d.Start(), nil) - // expect data to be received d.Once(d.Event(Data), func(data interface{}) { gobottest.Assert(t, data.(int), 100) @@ -54,6 +52,8 @@ func TestAnalogSensorDriverStart(t *testing.T) { return }) + gobottest.Assert(t, d.Start(), nil) + select { case <-sem: case <-time.After(1 * time.Second):