summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/meson.build2
-rw-r--r--test/serialization/ipa_data_serializer_test.cpp14
-rw-r--r--test/shared-fd.cpp (renamed from test/file-descriptor.cpp)46
3 files changed, 31 insertions, 31 deletions
diff --git a/test/meson.build b/test/meson.build
index 42dfbc1f..daaa3862 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -40,7 +40,6 @@ internal_tests = [
['event-dispatcher', 'event-dispatcher.cpp'],
['event-thread', 'event-thread.cpp'],
['file', 'file.cpp'],
- ['file-descriptor', 'file-descriptor.cpp'],
['flags', 'flags.cpp'],
['hotplug-cameras', 'hotplug-cameras.cpp'],
['mapped-buffer', 'mapped-buffer.cpp'],
@@ -49,6 +48,7 @@ internal_tests = [
['object-delete', 'object-delete.cpp'],
['object-invoke', 'object-invoke.cpp'],
['pixel-format', 'pixel-format.cpp'],
+ ['shared-fd', 'shared-fd.cpp'],
['signal-threads', 'signal-threads.cpp'],
['threads', 'threads.cpp'],
['timer', 'timer.cpp'],
diff --git a/test/serialization/ipa_data_serializer_test.cpp b/test/serialization/ipa_data_serializer_test.cpp
index 5fcdcb8e..d2050a86 100644
--- a/test/serialization/ipa_data_serializer_test.cpp
+++ b/test/serialization/ipa_data_serializer_test.cpp
@@ -53,7 +53,7 @@ template<typename T>
int testPodSerdes(T in)
{
std::vector<uint8_t> buf;
- std::vector<FileDescriptor> fds;
+ std::vector<SharedFD> fds;
std::tie(buf, fds) = IPADataSerializer<T>::serialize(in);
T out = IPADataSerializer<T>::deserialize(buf, fds);
@@ -72,7 +72,7 @@ int testVectorSerdes(const std::vector<T> &in,
ControlSerializer *cs = nullptr)
{
std::vector<uint8_t> buf;
- std::vector<FileDescriptor> fds;
+ std::vector<SharedFD> fds;
std::tie(buf, fds) = IPADataSerializer<std::vector<T>>::serialize(in, cs);
std::vector<T> out = IPADataSerializer<std::vector<T>>::deserialize(buf, fds, cs);
@@ -92,7 +92,7 @@ int testMapSerdes(const std::map<K, V> &in,
ControlSerializer *cs = nullptr)
{
std::vector<uint8_t> buf;
- std::vector<FileDescriptor> fds;
+ std::vector<SharedFD> fds;
std::tie(buf, fds) = IPADataSerializer<std::map<K, V>>::serialize(in, cs);
std::map<K, V> out = IPADataSerializer<std::map<K, V>>::deserialize(buf, fds, cs);
@@ -198,7 +198,7 @@ private:
ControlSerializer cs(ControlSerializer::Role::Proxy);
/*
- * We don't test FileDescriptor serdes because it dup()s, so we
+ * We don't test SharedFD serdes because it dup()s, so we
* can't check for equality.
*/
std::vector<uint8_t> vecUint8 = { 1, 2, 3, 4, 5, 6 };
@@ -219,7 +219,7 @@ private:
};
std::vector<uint8_t> buf;
- std::vector<FileDescriptor> fds;
+ std::vector<SharedFD> fds;
if (testVectorSerdes(vecUint8) != TestPass)
return TestFail;
@@ -291,7 +291,7 @@ private:
{ { "a", { 1, 2, 3 } }, { "b", { 4, 5, 6 } }, { "c", { 7, 8, 9 } } };
std::vector<uint8_t> buf;
- std::vector<FileDescriptor> fds;
+ std::vector<SharedFD> fds;
if (testMapSerdes(mapUintStr) != TestPass)
return TestFail;
@@ -359,7 +359,7 @@ private:
std::string strEmpty = "";
std::vector<uint8_t> buf;
- std::vector<FileDescriptor> fds;
+ std::vector<SharedFD> fds;
if (testPodSerdes(u32min) != TestPass)
return TestFail;
diff --git a/test/file-descriptor.cpp b/test/shared-fd.cpp
index 76badc4c..60e5d0aa 100644
--- a/test/file-descriptor.cpp
+++ b/test/shared-fd.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * file_descriptor.cpp - FileDescriptor test
+ * shared_fd.cpp - SharedFD test
*/
#include <fcntl.h>
@@ -11,7 +11,7 @@
#include <sys/types.h>
#include <unistd.h>
-#include <libcamera/base/file_descriptor.h>
+#include <libcamera/base/shared_fd.h>
#include <libcamera/base/utils.h>
#include "test.h"
@@ -19,7 +19,7 @@
using namespace libcamera;
using namespace std;
-class FileDescriptorTest : public Test
+class SharedFDTest : public Test
{
protected:
int init()
@@ -43,8 +43,8 @@ protected:
int run()
{
- /* Test creating empty FileDescriptor. */
- desc1_ = new FileDescriptor();
+ /* Test creating empty SharedFD. */
+ desc1_ = new SharedFD();
if (desc1_->fd() != -1) {
std::cout << "Failed fd numerical check (default constructor)"
@@ -56,10 +56,10 @@ protected:
desc1_ = nullptr;
/*
- * Test creating FileDescriptor by copying numerical file
+ * Test creating SharedFD by copying numerical file
* descriptor.
*/
- desc1_ = new FileDescriptor(fd_);
+ desc1_ = new SharedFD(fd_);
if (desc1_->fd() == fd_) {
std::cout << "Failed fd numerical check (lvalue ref constructor)"
<< std::endl;
@@ -84,13 +84,13 @@ protected:
}
/*
- * Test creating FileDescriptor by taking ownership of
+ * Test creating SharedFD by taking ownership of
* numerical file descriptor.
*/
int dupFd = dup(fd_);
int dupFdCopy = dupFd;
- desc1_ = new FileDescriptor(std::move(dupFd));
+ desc1_ = new SharedFD(std::move(dupFd));
if (desc1_->fd() != dupFdCopy) {
std::cout << "Failed fd numerical check (rvalue ref constructor)"
<< std::endl;
@@ -114,9 +114,9 @@ protected:
return TestFail;
}
- /* Test creating FileDescriptor from other FileDescriptor. */
- desc1_ = new FileDescriptor(fd_);
- desc2_ = new FileDescriptor(*desc1_);
+ /* Test creating SharedFD from other SharedFD. */
+ desc1_ = new SharedFD(fd_);
+ desc2_ = new SharedFD(*desc1_);
if (desc1_->fd() == fd_ || desc2_->fd() == fd_ || desc1_->fd() != desc2_->fd()) {
std::cout << "Failed fd numerical check (copy constructor)"
@@ -142,10 +142,10 @@ protected:
delete desc2_;
desc2_ = nullptr;
- /* Test creating FileDescriptor by taking over other FileDescriptor. */
- desc1_ = new FileDescriptor(fd_);
+ /* Test creating SharedFD by taking over other SharedFD. */
+ desc1_ = new SharedFD(fd_);
fd = desc1_->fd();
- desc2_ = new FileDescriptor(std::move(*desc1_));
+ desc2_ = new SharedFD(std::move(*desc1_));
if (desc1_->fd() != -1 || desc2_->fd() != fd) {
std::cout << "Failed fd numerical check (move constructor)"
@@ -164,9 +164,9 @@ protected:
delete desc2_;
desc2_ = nullptr;
- /* Test creating FileDescriptor by copy assignment. */
- desc1_ = new FileDescriptor();
- desc2_ = new FileDescriptor(fd_);
+ /* Test creating SharedFD by copy assignment. */
+ desc1_ = new SharedFD();
+ desc2_ = new SharedFD(fd_);
fd = desc2_->fd();
*desc1_ = *desc2_;
@@ -188,9 +188,9 @@ protected:
delete desc2_;
desc2_ = nullptr;
- /* Test creating FileDescriptor by move assignment. */
- desc1_ = new FileDescriptor();
- desc2_ = new FileDescriptor(fd_);
+ /* Test creating SharedFD by move assignment. */
+ desc1_ = new SharedFD();
+ desc2_ = new SharedFD(fd_);
fd = desc2_->fd();
*desc1_ = std::move(*desc2_);
@@ -237,7 +237,7 @@ private:
int fd_;
ino_t inodeNr_;
- FileDescriptor *desc1_, *desc2_;
+ SharedFD *desc1_, *desc2_;
};
-TEST_REGISTER(FileDescriptorTest)
+TEST_REGISTER(SharedFDTest)