[libcamera-devel,07/14] test: Get event dispatcher from current thread

Message ID 20190818011329.14499-8-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Assorted fixes for Android camera HAL
Related show

Commit Message

Laurent Pinchart Aug. 18, 2019, 1:13 a.m. UTC
For all tests that don't otherwise require access to the camera manager,
get the event dispatcher from the current thread instead of the camera
manager. This prepares for the removal of CameraManager::instance().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/event-dispatcher.cpp                | 4 ++--
 test/event.cpp                           | 4 ++--
 test/ipc/unixsocket.cpp                  | 6 +++---
 test/log/log_process.cpp                 | 4 ++--
 test/meson.build                         | 6 +++---
 test/object-invoke.cpp                   | 3 +--
 test/process/process_test.cpp            | 4 ++--
 test/timer.cpp                           | 4 ++--
 test/v4l2_videodevice/buffer_sharing.cpp | 4 ++--
 test/v4l2_videodevice/capture_async.cpp  | 4 ++--
 test/v4l2_videodevice/v4l2_m2mdevice.cpp | 4 ++--
 11 files changed, 23 insertions(+), 24 deletions(-)

Comments

Jacopo Mondi Aug. 19, 2019, 9:03 a.m. UTC | #1
Hi Laurent,
  regardless of the discussion on the instance() operation, I think
this is good, but please see a few comments below.

Minors apart:
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

On Sun, Aug 18, 2019 at 04:13:22AM +0300, Laurent Pinchart wrote:
> For all tests that don't otherwise require access to the camera manager,
> get the event dispatcher from the current thread instead of the camera
> manager. This prepares for the removal of CameraManager::instance().
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  test/event-dispatcher.cpp                | 4 ++--
>  test/event.cpp                           | 4 ++--
>  test/ipc/unixsocket.cpp                  | 6 +++---
>  test/log/log_process.cpp                 | 4 ++--
>  test/meson.build                         | 6 +++---
>  test/object-invoke.cpp                   | 3 +--
>  test/process/process_test.cpp            | 4 ++--
>  test/timer.cpp                           | 4 ++--
>  test/v4l2_videodevice/buffer_sharing.cpp | 4 ++--
>  test/v4l2_videodevice/capture_async.cpp  | 4 ++--
>  test/v4l2_videodevice/v4l2_m2mdevice.cpp | 4 ++--
>  11 files changed, 23 insertions(+), 24 deletions(-)
>
> diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp
> index e8818dcab4ad..f243ec39bc28 100644
> --- a/test/event-dispatcher.cpp
> +++ b/test/event-dispatcher.cpp
> @@ -9,11 +9,11 @@
>  #include <signal.h>
>  #include <sys/time.h>
>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/timer.h>
>
>  #include "test.h"
> +#include "thread.h"
>
>  using namespace std;
>  using namespace libcamera;
> @@ -33,7 +33,7 @@ protected:
>
>  	int init()
>  	{
> -		dispatcher = CameraManager::instance()->eventDispatcher();
> +		dispatcher = Thread::current()->eventDispatcher();
>
>  		struct sigaction sa = {};
>  		sa.sa_handler = &sigAlarmHandler;
> diff --git a/test/event.cpp b/test/event.cpp
> index 9bd876153a18..816060cc44a2 100644
> --- a/test/event.cpp
> +++ b/test/event.cpp
> @@ -9,12 +9,12 @@
>  #include <string.h>
>  #include <unistd.h>
>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/event_notifier.h>
>  #include <libcamera/timer.h>
>
>  #include "test.h"
> +#include "thread.h"
>
>  using namespace std;
>  using namespace libcamera;
> @@ -35,7 +35,7 @@ protected:
>
>  	int run()
>  	{
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		std::string data("H2G2");
>  		Timer timeout;
>  		ssize_t ret;
> diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp
> index 40a3a84a87d2..f53042b88720 100644
> --- a/test/ipc/unixsocket.cpp
> +++ b/test/ipc/unixsocket.cpp
> @@ -15,12 +15,12 @@
>  #include <sys/wait.h>
>  #include <unistd.h>
>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/timer.h>
>
>  #include "ipc_unixsocket.h"
>  #include "test.h"
> +#include "thread.h"
>  #include "utils.h"
>
>  #define CMD_CLOSE	0
> @@ -47,7 +47,7 @@ public:
>  	UnixSocketTestSlave()
>  		: exitCode_(EXIT_FAILURE), exit_(false)
>  	{
> -		dispatcher_ = CameraManager::instance()->eventDispatcher();
> +		dispatcher_ = Thread::current()->eventDispatcher();
>  		ipc_.readyRead.connect(this, &UnixSocketTestSlave::readyRead);
>  	}
>
> @@ -436,7 +436,7 @@ private:
>  				return -ETIMEDOUT;
>  			}
>
> -			CameraManager::instance()->eventDispatcher()->processEvents();
> +			Thread::current()->eventDispatcher()->processEvents();
>  		}
>
>  		callResponse_ = nullptr;
> diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp
> index 36d25b27bfea..2df4aa43713c 100644
> --- a/test/log/log_process.cpp
> +++ b/test/log/log_process.cpp
> @@ -14,7 +14,6 @@
>  #include <unistd.h>
>  #include <vector>
>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/logging.h>
>  #include <libcamera/timer.h>
> @@ -22,6 +21,7 @@
>  #include "log.h"
>  #include "process.h"
>  #include "test.h"
> +#include "thread.h"
>  #include "utils.h"
>
>  using namespace std;
> @@ -65,7 +65,7 @@ protected:
>
>  	int run()
>  	{
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		Timer timeout;
>
>  		int exitCode = 42;
> diff --git a/test/meson.build b/test/meson.build
> index 05265b7d4976..84722cceb35d 100644
> --- a/test/meson.build
> +++ b/test/meson.build
> @@ -13,22 +13,22 @@ subdir('v4l2_subdevice')
>  subdir('v4l2_videodevice')
>
>  public_tests = [
> -    ['event',                           'event.cpp'],
> -    ['event-dispatcher',                'event-dispatcher.cpp'],
>      ['geometry',                        'geometry.cpp'],
>      ['list-cameras',                    'list-cameras.cpp'],
>      ['signal',                          'signal.cpp'],
> -    ['timer',                           'timer.cpp'],
>  ]
>
>  internal_tests = [
>      ['camera-sensor',                   'camera-sensor.cpp'],
> +    ['event',                           'event.cpp'],
> +    ['event-dispatcher',                'event-dispatcher.cpp'],
>      ['event-thread',                    'event-thread.cpp'],
>      ['message',                         'message.cpp'],
>      ['object',                          'object.cpp'],
>      ['object-invoke',                   'object-invoke.cpp'],
>      ['signal-threads',                  'signal-threads.cpp'],
>      ['threads',                         'threads.cpp'],
> +    ['timer',                           'timer.cpp'],
>      ['timer-thread',                    'timer-thread.cpp'],
>  ]
>
This seems unrelated...

> diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
> index 7221930f4380..9fb93e140305 100644
> --- a/test/object-invoke.cpp
> +++ b/test/object-invoke.cpp
> @@ -9,7 +9,6 @@
>  #include <iostream>
>  #include <thread>
>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/object.h>

While at it, could you re-sort the following:

#include "thread.h"
#include "test.h"

>
> @@ -61,7 +60,7 @@ class ObjectInvokeTest : public Test
>  protected:
>  	int run()
>  	{
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		InvokedObject object;
>
>  		/*
> diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp
> index acb161454e2e..d264555e545f 100644
> --- a/test/process/process_test.cpp
> +++ b/test/process/process_test.cpp
> @@ -9,12 +9,12 @@
>  #include <unistd.h>
>  #include <vector>
>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/timer.h>
>
>  #include "process.h"
>  #include "test.h"
> +#include "thread.h"
>  #include "utils.h"
>
>  using namespace std;
> @@ -41,7 +41,7 @@ public:
>  protected:
>  	int run()
>  	{
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		Timer timeout;
>
>  		int exitCode = 42;
> diff --git a/test/timer.cpp b/test/timer.cpp
> index addebce3c784..c30709d4109a 100644
> --- a/test/timer.cpp
> +++ b/test/timer.cpp
> @@ -7,11 +7,11 @@
>
>  #include <iostream>
>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/timer.h>
>
>  #include "test.h"
> +#include "thread.h"
>
>  using namespace std;
>  using namespace libcamera;
> @@ -62,7 +62,7 @@ protected:
>
>  	int run()
>  	{
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		ManagedTimer timer;
>  		ManagedTimer timer2;
>
> diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp
> index 12ec88f2d8e6..1629f34cfa6c 100644
> --- a/test/v4l2_videodevice/buffer_sharing.cpp
> +++ b/test/v4l2_videodevice/buffer_sharing.cpp
> @@ -13,10 +13,10 @@
>  #include <iostream>
>
>  #include <libcamera/buffer.h>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/timer.h>
>
> +#include "thread.h"
>  #include "v4l2_videodevice_test.h"
>
>  class BufferSharingTest : public V4L2VideoDeviceTest
> @@ -116,7 +116,7 @@ protected:
>
>  	int run()
>  	{
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		Timer timeout;
>  		int ret;
>
> diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp
> index 4909f71a3f34..17eb528b12fd 100644
> --- a/test/v4l2_videodevice/capture_async.cpp
> +++ b/test/v4l2_videodevice/capture_async.cpp
> @@ -6,12 +6,12 @@
>   */
>
>  #include <libcamera/buffer.h>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/timer.h>
>
>  #include <iostream>
>
> +#include "thread.h"
>  #include "v4l2_videodevice_test.h"
>
>  class CaptureAsyncTest : public V4L2VideoDeviceTest
> @@ -34,7 +34,7 @@ protected:
>  	{
>  		const unsigned int bufferCount = 8;
>
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		Timer timeout;
>  		int ret;
>
> diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
> index d132b1db2432..4d3644c2d287 100644
> --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp
> +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
> @@ -8,12 +8,12 @@
>  #include <iostream>
>
>  #include <libcamera/buffer.h>
> -#include <libcamera/camera_manager.h>
>  #include <libcamera/event_dispatcher.h>
>  #include <libcamera/timer.h>
>
>  #include "device_enumerator.h"
>  #include "media_device.h"
> +#include "thread.h"
>  #include "v4l2_videodevice.h"
>
>  #include "test.h"
> @@ -80,7 +80,7 @@ protected:
>  	{
>  		constexpr unsigned int bufferCount = 4;
>
> -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
>  		int ret;
>
>  		MediaEntity *entity = media_->getEntityByName("vim2m-source");
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Aug. 19, 2019, 3:10 p.m. UTC | #2
Hi Jacopo,

On Mon, Aug 19, 2019 at 11:03:20AM +0200, Jacopo Mondi wrote:
> Hi Laurent,
>   regardless of the discussion on the instance() operation, I think
> this is good, but please see a few comments below.
> 
> Minors apart:
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> 
> On Sun, Aug 18, 2019 at 04:13:22AM +0300, Laurent Pinchart wrote:
> > For all tests that don't otherwise require access to the camera manager,
> > get the event dispatcher from the current thread instead of the camera
> > manager. This prepares for the removal of CameraManager::instance().
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  test/event-dispatcher.cpp                | 4 ++--
> >  test/event.cpp                           | 4 ++--
> >  test/ipc/unixsocket.cpp                  | 6 +++---
> >  test/log/log_process.cpp                 | 4 ++--
> >  test/meson.build                         | 6 +++---
> >  test/object-invoke.cpp                   | 3 +--
> >  test/process/process_test.cpp            | 4 ++--
> >  test/timer.cpp                           | 4 ++--
> >  test/v4l2_videodevice/buffer_sharing.cpp | 4 ++--
> >  test/v4l2_videodevice/capture_async.cpp  | 4 ++--
> >  test/v4l2_videodevice/v4l2_m2mdevice.cpp | 4 ++--
> >  11 files changed, 23 insertions(+), 24 deletions(-)
> >
> > diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp
> > index e8818dcab4ad..f243ec39bc28 100644
> > --- a/test/event-dispatcher.cpp
> > +++ b/test/event-dispatcher.cpp
> > @@ -9,11 +9,11 @@
> >  #include <signal.h>
> >  #include <sys/time.h>
> >
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/timer.h>
> >
> >  #include "test.h"
> > +#include "thread.h"
> >
> >  using namespace std;
> >  using namespace libcamera;
> > @@ -33,7 +33,7 @@ protected:
> >
> >  	int init()
> >  	{
> > -		dispatcher = CameraManager::instance()->eventDispatcher();
> > +		dispatcher = Thread::current()->eventDispatcher();
> >
> >  		struct sigaction sa = {};
> >  		sa.sa_handler = &sigAlarmHandler;
> > diff --git a/test/event.cpp b/test/event.cpp
> > index 9bd876153a18..816060cc44a2 100644
> > --- a/test/event.cpp
> > +++ b/test/event.cpp
> > @@ -9,12 +9,12 @@
> >  #include <string.h>
> >  #include <unistd.h>
> >
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/event_notifier.h>
> >  #include <libcamera/timer.h>
> >
> >  #include "test.h"
> > +#include "thread.h"
> >
> >  using namespace std;
> >  using namespace libcamera;
> > @@ -35,7 +35,7 @@ protected:
> >
> >  	int run()
> >  	{
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		std::string data("H2G2");
> >  		Timer timeout;
> >  		ssize_t ret;
> > diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp
> > index 40a3a84a87d2..f53042b88720 100644
> > --- a/test/ipc/unixsocket.cpp
> > +++ b/test/ipc/unixsocket.cpp
> > @@ -15,12 +15,12 @@
> >  #include <sys/wait.h>
> >  #include <unistd.h>
> >
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/timer.h>
> >
> >  #include "ipc_unixsocket.h"
> >  #include "test.h"
> > +#include "thread.h"
> >  #include "utils.h"
> >
> >  #define CMD_CLOSE	0
> > @@ -47,7 +47,7 @@ public:
> >  	UnixSocketTestSlave()
> >  		: exitCode_(EXIT_FAILURE), exit_(false)
> >  	{
> > -		dispatcher_ = CameraManager::instance()->eventDispatcher();
> > +		dispatcher_ = Thread::current()->eventDispatcher();
> >  		ipc_.readyRead.connect(this, &UnixSocketTestSlave::readyRead);
> >  	}
> >
> > @@ -436,7 +436,7 @@ private:
> >  				return -ETIMEDOUT;
> >  			}
> >
> > -			CameraManager::instance()->eventDispatcher()->processEvents();
> > +			Thread::current()->eventDispatcher()->processEvents();
> >  		}
> >
> >  		callResponse_ = nullptr;
> > diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp
> > index 36d25b27bfea..2df4aa43713c 100644
> > --- a/test/log/log_process.cpp
> > +++ b/test/log/log_process.cpp
> > @@ -14,7 +14,6 @@
> >  #include <unistd.h>
> >  #include <vector>
> >
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/logging.h>
> >  #include <libcamera/timer.h>
> > @@ -22,6 +21,7 @@
> >  #include "log.h"
> >  #include "process.h"
> >  #include "test.h"
> > +#include "thread.h"
> >  #include "utils.h"
> >
> >  using namespace std;
> > @@ -65,7 +65,7 @@ protected:
> >
> >  	int run()
> >  	{
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		Timer timeout;
> >
> >  		int exitCode = 42;
> > diff --git a/test/meson.build b/test/meson.build
> > index 05265b7d4976..84722cceb35d 100644
> > --- a/test/meson.build
> > +++ b/test/meson.build
> > @@ -13,22 +13,22 @@ subdir('v4l2_subdevice')
> >  subdir('v4l2_videodevice')
> >
> >  public_tests = [
> > -    ['event',                           'event.cpp'],
> > -    ['event-dispatcher',                'event-dispatcher.cpp'],
> >      ['geometry',                        'geometry.cpp'],
> >      ['list-cameras',                    'list-cameras.cpp'],
> >      ['signal',                          'signal.cpp'],
> > -    ['timer',                           'timer.cpp'],
> >  ]
> >
> >  internal_tests = [
> >      ['camera-sensor',                   'camera-sensor.cpp'],
> > +    ['event',                           'event.cpp'],
> > +    ['event-dispatcher',                'event-dispatcher.cpp'],
> >      ['event-thread',                    'event-thread.cpp'],
> >      ['message',                         'message.cpp'],
> >      ['object',                          'object.cpp'],
> >      ['object-invoke',                   'object-invoke.cpp'],
> >      ['signal-threads',                  'signal-threads.cpp'],
> >      ['threads',                         'threads.cpp'],
> > +    ['timer',                           'timer.cpp'],
> >      ['timer-thread',                    'timer-thread.cpp'],
> >  ]
> >
>
> This seems unrelated...

No really, the tests now use the thread.h header to retrieve the event
dispatcher from the thread, so they need access to internal headers.

> > diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
> > index 7221930f4380..9fb93e140305 100644
> > --- a/test/object-invoke.cpp
> > +++ b/test/object-invoke.cpp
> > @@ -9,7 +9,6 @@
> >  #include <iostream>
> >  #include <thread>
> >
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/object.h>
> 
> While at it, could you re-sort the following:
> 
> #include "thread.h"
> #include "test.h"

OK

> > @@ -61,7 +60,7 @@ class ObjectInvokeTest : public Test
> >  protected:
> >  	int run()
> >  	{
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		InvokedObject object;
> >
> >  		/*
> > diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp
> > index acb161454e2e..d264555e545f 100644
> > --- a/test/process/process_test.cpp
> > +++ b/test/process/process_test.cpp
> > @@ -9,12 +9,12 @@
> >  #include <unistd.h>
> >  #include <vector>
> >
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/timer.h>
> >
> >  #include "process.h"
> >  #include "test.h"
> > +#include "thread.h"
> >  #include "utils.h"
> >
> >  using namespace std;
> > @@ -41,7 +41,7 @@ public:
> >  protected:
> >  	int run()
> >  	{
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		Timer timeout;
> >
> >  		int exitCode = 42;
> > diff --git a/test/timer.cpp b/test/timer.cpp
> > index addebce3c784..c30709d4109a 100644
> > --- a/test/timer.cpp
> > +++ b/test/timer.cpp
> > @@ -7,11 +7,11 @@
> >
> >  #include <iostream>
> >
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/timer.h>
> >
> >  #include "test.h"
> > +#include "thread.h"
> >
> >  using namespace std;
> >  using namespace libcamera;
> > @@ -62,7 +62,7 @@ protected:
> >
> >  	int run()
> >  	{
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		ManagedTimer timer;
> >  		ManagedTimer timer2;
> >
> > diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp
> > index 12ec88f2d8e6..1629f34cfa6c 100644
> > --- a/test/v4l2_videodevice/buffer_sharing.cpp
> > +++ b/test/v4l2_videodevice/buffer_sharing.cpp
> > @@ -13,10 +13,10 @@
> >  #include <iostream>
> >
> >  #include <libcamera/buffer.h>
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/timer.h>
> >
> > +#include "thread.h"
> >  #include "v4l2_videodevice_test.h"
> >
> >  class BufferSharingTest : public V4L2VideoDeviceTest
> > @@ -116,7 +116,7 @@ protected:
> >
> >  	int run()
> >  	{
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		Timer timeout;
> >  		int ret;
> >
> > diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp
> > index 4909f71a3f34..17eb528b12fd 100644
> > --- a/test/v4l2_videodevice/capture_async.cpp
> > +++ b/test/v4l2_videodevice/capture_async.cpp
> > @@ -6,12 +6,12 @@
> >   */
> >
> >  #include <libcamera/buffer.h>
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/timer.h>
> >
> >  #include <iostream>
> >
> > +#include "thread.h"
> >  #include "v4l2_videodevice_test.h"
> >
> >  class CaptureAsyncTest : public V4L2VideoDeviceTest
> > @@ -34,7 +34,7 @@ protected:
> >  	{
> >  		const unsigned int bufferCount = 8;
> >
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		Timer timeout;
> >  		int ret;
> >
> > diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
> > index d132b1db2432..4d3644c2d287 100644
> > --- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp
> > +++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
> > @@ -8,12 +8,12 @@
> >  #include <iostream>
> >
> >  #include <libcamera/buffer.h>
> > -#include <libcamera/camera_manager.h>
> >  #include <libcamera/event_dispatcher.h>
> >  #include <libcamera/timer.h>
> >
> >  #include "device_enumerator.h"
> >  #include "media_device.h"
> > +#include "thread.h"
> >  #include "v4l2_videodevice.h"
> >
> >  #include "test.h"
> > @@ -80,7 +80,7 @@ protected:
> >  	{
> >  		constexpr unsigned int bufferCount = 4;
> >
> > -		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
> > +		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
> >  		int ret;
> >
> >  		MediaEntity *entity = media_->getEntityByName("vim2m-source");

Patch

diff --git a/test/event-dispatcher.cpp b/test/event-dispatcher.cpp
index e8818dcab4ad..f243ec39bc28 100644
--- a/test/event-dispatcher.cpp
+++ b/test/event-dispatcher.cpp
@@ -9,11 +9,11 @@ 
 #include <signal.h>
 #include <sys/time.h>
 
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/timer.h>
 
 #include "test.h"
+#include "thread.h"
 
 using namespace std;
 using namespace libcamera;
@@ -33,7 +33,7 @@  protected:
 
 	int init()
 	{
-		dispatcher = CameraManager::instance()->eventDispatcher();
+		dispatcher = Thread::current()->eventDispatcher();
 
 		struct sigaction sa = {};
 		sa.sa_handler = &sigAlarmHandler;
diff --git a/test/event.cpp b/test/event.cpp
index 9bd876153a18..816060cc44a2 100644
--- a/test/event.cpp
+++ b/test/event.cpp
@@ -9,12 +9,12 @@ 
 #include <string.h>
 #include <unistd.h>
 
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/event_notifier.h>
 #include <libcamera/timer.h>
 
 #include "test.h"
+#include "thread.h"
 
 using namespace std;
 using namespace libcamera;
@@ -35,7 +35,7 @@  protected:
 
 	int run()
 	{
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		std::string data("H2G2");
 		Timer timeout;
 		ssize_t ret;
diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp
index 40a3a84a87d2..f53042b88720 100644
--- a/test/ipc/unixsocket.cpp
+++ b/test/ipc/unixsocket.cpp
@@ -15,12 +15,12 @@ 
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/timer.h>
 
 #include "ipc_unixsocket.h"
 #include "test.h"
+#include "thread.h"
 #include "utils.h"
 
 #define CMD_CLOSE	0
@@ -47,7 +47,7 @@  public:
 	UnixSocketTestSlave()
 		: exitCode_(EXIT_FAILURE), exit_(false)
 	{
-		dispatcher_ = CameraManager::instance()->eventDispatcher();
+		dispatcher_ = Thread::current()->eventDispatcher();
 		ipc_.readyRead.connect(this, &UnixSocketTestSlave::readyRead);
 	}
 
@@ -436,7 +436,7 @@  private:
 				return -ETIMEDOUT;
 			}
 
-			CameraManager::instance()->eventDispatcher()->processEvents();
+			Thread::current()->eventDispatcher()->processEvents();
 		}
 
 		callResponse_ = nullptr;
diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp
index 36d25b27bfea..2df4aa43713c 100644
--- a/test/log/log_process.cpp
+++ b/test/log/log_process.cpp
@@ -14,7 +14,6 @@ 
 #include <unistd.h>
 #include <vector>
 
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/logging.h>
 #include <libcamera/timer.h>
@@ -22,6 +21,7 @@ 
 #include "log.h"
 #include "process.h"
 #include "test.h"
+#include "thread.h"
 #include "utils.h"
 
 using namespace std;
@@ -65,7 +65,7 @@  protected:
 
 	int run()
 	{
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		Timer timeout;
 
 		int exitCode = 42;
diff --git a/test/meson.build b/test/meson.build
index 05265b7d4976..84722cceb35d 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -13,22 +13,22 @@  subdir('v4l2_subdevice')
 subdir('v4l2_videodevice')
 
 public_tests = [
-    ['event',                           'event.cpp'],
-    ['event-dispatcher',                'event-dispatcher.cpp'],
     ['geometry',                        'geometry.cpp'],
     ['list-cameras',                    'list-cameras.cpp'],
     ['signal',                          'signal.cpp'],
-    ['timer',                           'timer.cpp'],
 ]
 
 internal_tests = [
     ['camera-sensor',                   'camera-sensor.cpp'],
+    ['event',                           'event.cpp'],
+    ['event-dispatcher',                'event-dispatcher.cpp'],
     ['event-thread',                    'event-thread.cpp'],
     ['message',                         'message.cpp'],
     ['object',                          'object.cpp'],
     ['object-invoke',                   'object-invoke.cpp'],
     ['signal-threads',                  'signal-threads.cpp'],
     ['threads',                         'threads.cpp'],
+    ['timer',                           'timer.cpp'],
     ['timer-thread',                    'timer-thread.cpp'],
 ]
 
diff --git a/test/object-invoke.cpp b/test/object-invoke.cpp
index 7221930f4380..9fb93e140305 100644
--- a/test/object-invoke.cpp
+++ b/test/object-invoke.cpp
@@ -9,7 +9,6 @@ 
 #include <iostream>
 #include <thread>
 
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/object.h>
 
@@ -61,7 +60,7 @@  class ObjectInvokeTest : public Test
 protected:
 	int run()
 	{
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		InvokedObject object;
 
 		/*
diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp
index acb161454e2e..d264555e545f 100644
--- a/test/process/process_test.cpp
+++ b/test/process/process_test.cpp
@@ -9,12 +9,12 @@ 
 #include <unistd.h>
 #include <vector>
 
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/timer.h>
 
 #include "process.h"
 #include "test.h"
+#include "thread.h"
 #include "utils.h"
 
 using namespace std;
@@ -41,7 +41,7 @@  public:
 protected:
 	int run()
 	{
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		Timer timeout;
 
 		int exitCode = 42;
diff --git a/test/timer.cpp b/test/timer.cpp
index addebce3c784..c30709d4109a 100644
--- a/test/timer.cpp
+++ b/test/timer.cpp
@@ -7,11 +7,11 @@ 
 
 #include <iostream>
 
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/timer.h>
 
 #include "test.h"
+#include "thread.h"
 
 using namespace std;
 using namespace libcamera;
@@ -62,7 +62,7 @@  protected:
 
 	int run()
 	{
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		ManagedTimer timer;
 		ManagedTimer timer2;
 
diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp
index 12ec88f2d8e6..1629f34cfa6c 100644
--- a/test/v4l2_videodevice/buffer_sharing.cpp
+++ b/test/v4l2_videodevice/buffer_sharing.cpp
@@ -13,10 +13,10 @@ 
 #include <iostream>
 
 #include <libcamera/buffer.h>
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/timer.h>
 
+#include "thread.h"
 #include "v4l2_videodevice_test.h"
 
 class BufferSharingTest : public V4L2VideoDeviceTest
@@ -116,7 +116,7 @@  protected:
 
 	int run()
 	{
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		Timer timeout;
 		int ret;
 
diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp
index 4909f71a3f34..17eb528b12fd 100644
--- a/test/v4l2_videodevice/capture_async.cpp
+++ b/test/v4l2_videodevice/capture_async.cpp
@@ -6,12 +6,12 @@ 
  */
 
 #include <libcamera/buffer.h>
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/timer.h>
 
 #include <iostream>
 
+#include "thread.h"
 #include "v4l2_videodevice_test.h"
 
 class CaptureAsyncTest : public V4L2VideoDeviceTest
@@ -34,7 +34,7 @@  protected:
 	{
 		const unsigned int bufferCount = 8;
 
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		Timer timeout;
 		int ret;
 
diff --git a/test/v4l2_videodevice/v4l2_m2mdevice.cpp b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
index d132b1db2432..4d3644c2d287 100644
--- a/test/v4l2_videodevice/v4l2_m2mdevice.cpp
+++ b/test/v4l2_videodevice/v4l2_m2mdevice.cpp
@@ -8,12 +8,12 @@ 
 #include <iostream>
 
 #include <libcamera/buffer.h>
-#include <libcamera/camera_manager.h>
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/timer.h>
 
 #include "device_enumerator.h"
 #include "media_device.h"
+#include "thread.h"
 #include "v4l2_videodevice.h"
 
 #include "test.h"
@@ -80,7 +80,7 @@  protected:
 	{
 		constexpr unsigned int bufferCount = 4;
 
-		EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
+		EventDispatcher *dispatcher = Thread::current()->eventDispatcher();
 		int ret;
 
 		MediaEntity *entity = media_->getEntityByName("vim2m-source");