summaryrefslogtreecommitdiff
path: root/utils/ipc/tools/diagnosis
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-03-18 14:59:42 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-03-29 12:33:50 +0100
commit651e3fab6329498a7f46703ce5bb92c49cc37624 (patch)
tree121753ecb9effabac69232fb2917a2057807c9d0 /utils/ipc/tools/diagnosis
parent5718b4d5b7c8808b1d6137f90fc4690e15349c3d (diff)
libcamera: camera: Report function which fails access control
The camera object has a state machine to ensure calls are only made when in the correct state. It isn't easy to identify where things happen when assertions fail so add extra information to make this clearer. The error level of the isAccessAllowed is raised from Debug to Error as this is important information for applications to know if they have made a request in an invalid state. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'utils/ipc/tools/diagnosis')
0 files changed, 0 insertions, 0 deletions
25' href='#n125'>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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 /* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2020, Google Inc. * * Test the buffer cache different operation modes */ #include <iostream> #include <random> #include <vector> #include <libcamera/formats.h> #include <libcamera/stream.h> #include "buffer_source.h" #include "test.h" using namespace libcamera; namespace { class BufferCacheTest : public Test { public: /* * Test that a cache with the same size as there are buffers results in * a sequential run over; 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, ... * * The test is only valid when the cache size is as least as big as the * number of buffers. */ int/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2019, Google Inc. * * signal.cpp - Signal test */ #include <iostream> #include <string.h> #include <libcamera/object.h> #include <libcamera/signal.h> #include "test.h" using namespace std; using namespace libcamera; static int valueStatic_ = 0; static void slotStatic(int value) { valueStatic_ = value; } class SlotObject : public Object { public: void slot() { valueStatic_ = 1; } }; class BaseClass { public: /* * A virtual method is required in the base class, otherwise the compiler * will always store Object before BaseClass in memory. */ virtual ~BaseClass() { } unsigned int data_[32]; }; class SlotMulti : public BaseClass, public Object { public: void slot() { valueStatic_ = 1; } }; class SignalTest : public Test { protected: void slotVoid() { called_ = true; } void slotDisconnect() { called_ = true; signalVoid_.disconnect(this, &SignalTest::slotDisconnect); } void slotInteger1(int value) { values_[0] = value; } void slotInteger2(int value) { values_[1] = value; } void slotMultiArgs(int value, const std::string &name) { values_[2] = value; name_ = name; } int init() { return 0; } int run() { /* ----------------- Signal -> !Object tests ---------------- */ /* Test signal emission and reception. */ called_ = false; signalVoid_.connect(this, &SignalTest::slotVoid); signalVoid_.emit(); if (!called_) { cout << "Signal emission test failed" << endl; return TestFail; } /* Test signal with parameters. */ values_[2] = 0; name_.clear(); signalMultiArgs_.connect(this, &SignalTest::slotMultiArgs); signalMultiArgs_.emit(42, "H2G2"); if (values_[2] != 42 || name_ != "H2G2") { cout << "Signal parameters test failed" << endl; return TestFail; } /* Test signal connected to multiple slots. */ memset(values_, 0, sizeof(values_)); valueStatic_ = 0; signalInt_.connect(this, &SignalTest::slotInteger1); signalInt_.connect(this, &SignalTest::slotInteger2); signalInt_.connect(&slotStatic); signalInt_.emit(42); if (values_[0] != 42 || values_[1] != 42 || values_[2] != 0 || valueStatic_ != 42) { cout << "Signal multi slot test failed" << endl; return TestFail; } /* Test disconnection of a single slot. */ memset(values_, 0, sizeof(values_)); signalInt_.disconnect(this, &SignalTest::slotInteger2); signalInt_.emit(42); if (values_[0] != 42 || values_[1] != 0 || values_[2] != 0) { cout << "Signal slot disconnection test failed" << endl; return TestFail; } /* Test disconnection of a whole object. */ memset(values_, 0, sizeof(values_)); signalInt_.disconnect(this); signalInt_.emit(42); n>ret != TestPass) return ret; const std::vector<std::unique_ptr<FrameBuffer>> &buffers = source.buffers(); if (buffers.size() != numBuffers) { std::cout << "Got " << buffers.size() << " buffers, expected " << numBuffers << std::endl; return TestFail; } /* * Test cache of same size as there are buffers, the cache is * created from a list of buffers and will be pre-populated. */ V4L2BufferCache cacheFromBuffers(buffers); if (testSequential(&cacheFromBuffers, buffers) != TestPass) return TestFail; if (testRandom(&cacheFromBuffers, buffers) != TestPass) return TestFail; if (testHot(&cacheFromBuffers, buffers, numBuffers) != TestPass) return TestFail; /* * Test cache of same size as there are buffers, the cache is * not pre-populated. */ V4L2BufferCache cacheFromNumbers(numBuffers); if (testSequential(&cacheFromNumbers, buffers) != TestPass) return TestFail; if (testRandom(&cacheFromNumbers, buffers) != TestPass) return TestFail; if (testHot(&cacheFromNumbers, buffers, numBuffers) != TestPass) return TestFail; /* * Test cache half the size of number of buffers used, the cache * is not pre-populated. */ V4L2BufferCache cacheHalf(numBuffers / 2); if (testRandom(&cacheHalf, buffers) != TestPass) return TestFail; if (testHot(&cacheHalf, buffers, numBuffers / 2) != TestPass) return TestFail; return TestPass; } private: std::mt19937 generator_; }; } /* namespace */ TEST_REGISTER(BufferCacheTest)