summaryrefslogtreecommitdiff
path: root/test/pipeline/meson.build
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2019-08-06 16:56:29 +0200
committerJacopo Mondi <jacopo@jmondi.org>2019-08-12 10:34:13 +0200
commit3c658acf820bd634557c34c1d0e9f558e1b5405d (patch)
tree0b23c8fa123303eee8201eb55fd0e8f5a6429766 /test/pipeline/meson.build
parentc64b898a35134090c165cfc085dd6556fdb2347f (diff)
licenses: add Apache-2.0 license
All the Android camera stack code used by the libcamera camera HAL adaptation layer is licensed under the Apache-2.0 license. Add the Apache-2.0 license text to the licenses directory. The associated SPDX header is "Apache-2.0" and the license text is copied from: https://www.apache.org/licenses/LICENSE-2.0.txt Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'test/pipeline/meson.build')
0 files changed, 0 insertions, 0 deletions
a> 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2018, Google Inc.
 *
 * ByteStreamBuffer tests
 */

#include <array>
#include <iostream>

#include "libcamera/internal/byte_stream_buffer.h"

#include "test.h"

using namespace std;
using namespace libcamera;

class ByteStreamBufferTest : public Test
{
protected:
	int run()
	{
		/*
		 * gcc 11.1.0 incorrectly raises a maybe-uninitialized warning
		 * when calling data.size() below (if the address sanitizer is
		 * disabled). Silence it by initializing the array.
		 */
		std::array<uint8_t, 100> data = {};
		unsigned int i;
		uint32_t value;
		int ret;

		/*
		 * Write mode.
		 */
		ByteStreamBuffer wbuf(data.data(), data.size());

		if (wbuf.base() != data.data() || wbuf.size() != data.size() ||
		    wbuf.offset() != 0 || wbuf.overflow()) {
			cerr << "Write buffer incorrectly constructed" << endl;
			return TestFail;
		}

		/* Test write. */
		value = 0x12345678;
		ret = wbuf.write(&value);
		if (ret || wbuf.offset() != 4 || wbuf.overflow() ||
		    *reinterpret_cast<uint32_t *>(data.data()) != 0x12345678) {
			cerr << "Write failed on write buffer" << endl;
			return TestFail;
		}

		/* Test write carve out. */
		ByteStreamBuffer wco = wbuf.carveOut(10);
		if (wco.base() != wbuf.base() + 4 || wco.size() != 10 ||
		    wco.offset() != 0 || wco.overflow() || wbuf.offset() != 14 ||
		    wbuf.overflow()) {
			cerr << "Carving out write buffer failed" << endl;
			return TestFail;