summaryrefslogtreecommitdiff
path: root/test/ipc/unixsocket_ipc.cpp
AgeCommit message (Collapse)Author
2021-06-25libcamera/base: Move extended base functionalityKieran Bingham
Move the functionality for the following components to the new base support library: - BoundMethod - EventDispatcher - EventDispatcherPoll - Log - Message - Object - Signal - Semaphore - Thread - Timer While it would be preferable to see these split to move one component per commit, these components are all interdependent upon each other, which leaves us with one big change performing the move for all of them. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25libcamera/base: Move utils to the base libraryKieran Bingham
Move the utils functionality to the libcamera/base library. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-02tests: Add test for IPCPipeUnixSocketPaul Elder
Test the IPC functions of IPCPipeUnixSocket. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
href='#n19'>19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * libcamera V4L2 Subdevice format handling test
 */

#include <iostream>
#include <vector>

#include <libcamera/geometry.h>

#include <libcamera/base/utils.h>

#include "libcamera/internal/v4l2_subdevice.h"

#include "v4l2_subdevice_test.h"

using namespace std;
using namespace libcamera;

/* List image formats on the "Scaler" subdevice of vimc media device.  */

class ListFormatsTest : public V4L2SubdeviceTest
{
protected:
	int run() override;

private:
	void printFormats(unsigned int pad, unsigned code,
			  const std::vector<SizeRange> &sizes);
};

void ListFormatsTest::printFormats(unsigned int pad,
				   unsigned int code,
				   const std::vector<SizeRange> &sizes)
{
	cout << "Enumerate formats on pad " << pad << endl;
	for (const SizeRange &size : sizes) {
		cout << "	mbus code: " << utils::hex(code, 4) << endl;
		cout << "	min width: " << dec << size.min.width << endl;
		cout << "	min height: " << dec << size.min.height << endl;
		cout << "	max width: " << dec << size.max.width << endl;
		cout << "	max height: " << dec << size.max.height << endl;
	}
}

int ListFormatsTest::run()
{
	/* List all formats available on existing "Scaler" pads. */
	V4L2Subdevice::Formats formats;

	formats = scaler_->formats(0);
	if (formats.empty()) {
		cerr << "Failed to list formats on pad 0 of subdevice "
		     << scaler_->entity()->name() << endl;
		return TestFail;
	}
	for (unsigned int code : utils::map_keys(formats))
		printFormats(0, code, formats[code]);

	formats = scaler_->formats(1);
	if (formats.empty()) {
		cerr << "Failed to list formats on pad 1 of subdevice "
		     << scaler_->entity()->name() << endl;
		return TestFail;
	}
	for (unsigned int code : utils::map_keys(formats))
		printFormats(1, code, formats[code]);

	/* List format on a non-existing pad, format vector shall be empty. */
	formats = scaler_->formats(2);
	if (!formats.empty()) {
		cerr << "Listing formats on non-existing pad 2 of subdevice "
		     << scaler_->entity()->name()
		     << " should return an empty format list" << endl;
		return TestFail;
	}

	return TestPass;
}

TEST_REGISTER(ListFormatsTest)