new file mode 100644
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * media_device_basic.cpp - Test basic functions of MediaDevice
+ */
+
+#include "media_device_test.h"
+
+using namespace libcamera;
+
+class MediaDeviceBasic : public MediaDeviceTest
+{
+ int testAcquire()
+ {
+ if (!media_->acquire())
+ return TestFail;
+
+ if (media_->acquire())
+ return TestFail;
+
+ media_->release();
+
+ if (!media_->acquire())
+ return TestFail;
+
+ media_->release();
+
+ return TestPass;
+ }
+
+ int run()
+ {
+ if (testAcquire() != TestPass)
+ return TestFail;
+
+ return TestPass;
+ }
+};
+
+TEST_REGISTER(MediaDeviceBasic);
@@ -113,17 +113,6 @@ int MediaDevicePrintTest::testMediaDevice(const string deviceNode)
MediaDevice dev(deviceNode);
int ret;
- /* Fuzzy open/close sequence. */
- ret = dev.open();
- if (ret)
- return ret;
-
- ret = dev.open();
- if (!ret)
- return ret;
-
- dev.close();
-
ret = dev.populate();
if (ret)
return ret;
@@ -1,4 +1,5 @@
media_device_tests = [
+ ['media_device_basic', 'media_device_basic.cpp'],
['media_device_print_test', 'media_device_print_test.cpp'],
['media_device_link_test', 'media_device_link_test.cpp'],
]
The interfaces MediaDevice::{open,close}() are about to be made private, replace them with a test of MediaDevice::{acquire,release}() instead. The new test will implicitly tests the open() and close() methods as they are about to be move inside acquire() and release() which will remain public. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- test/media_device/media_device_basic.cpp | 41 +++++++++++++++++++ test/media_device/media_device_print_test.cpp | 11 ----- test/media_device/meson.build | 1 + 3 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 test/media_device/media_device_basic.cpp