summaryrefslogtreecommitdiff
path: root/src/cam
AgeCommit message (Expand)Author
2019-11-20cam: Store camera as shared pointer everywhereNiklas Söderlund
2019-11-20cam: BufferWriter: Use the libcamera namespaceNiklas Söderlund
2019-11-19libcamera: camera: Remove explicit stream to buffer map in requestCompleted s...Niklas Söderlund
2019-11-08libcamera: Remove unneeded semicolonsLaurent Pinchart
2019-10-26cam: capture: remove unused local variablePaul Elder
2019-10-23libcamera: Standardise on C compatibility headersLaurent Pinchart
2019-09-14libcamera: Switch to the std::chrono APILaurent Pinchart
2019-08-19libcamera: camera_manager: Construct CameraManager instances manuallyLaurent Pinchart
2019-07-14libcamera: buffer: Add an accessor to the BufferMemoryLaurent Pinchart
2019-07-14libcamera: stream: Shorten access to the bufferPoolJacopo Mondi
2019-07-14libcamera: Stop using Stream::bufferPool to get the number of buffersLaurent Pinchart
2019-07-14libcamera: buffer: Split memory information to BufferMemoryLaurent Pinchart
2019-06-25cam: capture: Stop stream when queueRequest() failsHelen Koike
2019-06-19cam: Support base 16 and base 8 when parsing integer optionsLaurent Pinchart
2019-06-19cam: Add --info option to print information about stream(s)Niklas Söderlund
2019-06-19cam: Validate camera configurationNiklas Söderlund
2019-06-19cam: Move camera configuration preparation to CamAppNiklas Söderlund
2019-06-18cam: Allow selecting cameras by indexLaurent Pinchart
2019-06-10cam: Fix cam --help crashNiklas Söderlund
2019-05-25cam: Add CamApp classNiklas Söderlund
2019-05-25cam: capture: Break out capture to a new classNiklas Söderlund
2019-05-23meson: Create and use a dependency for libcamera and its headersLaurent Pinchart
2019-05-23cam: Rename conf variable referring to command line option to optLaurent Pinchart
2019-05-23libcamera: camera: Add a validation API to the CameraConfiguration classLaurent Pinchart
2019-05-23libcamera: camera: Return a pointer from generateConfiguration()Laurent Pinchart
2019-05-23libcamera: Refactor the camera configuration storage and APILaurent Pinchart
2019-05-23libcamera: Use stream roles directly instead of StreamUsageLaurent Pinchart
2019-05-23libcamera: camera: Rename configureStreams() and streamConfiguration()Laurent Pinchart
2019-04-30libcamera: Use the Size class through libcameraLaurent Pinchart
2019-04-26cam: options: Fix string concatenationLaurent Pinchart
2019-04-26cam: options: Don't initialise variable-length arraysLaurent Pinchart
2019-04-18Install the cam and qcam utilitiesLaurent Pinchart
2019-04-09cam: Allow cameras with more than one streamNiklas Söderlund
2019-04-09cam: Extend request completion handler to deal with multiple streamsNiklas Söderlund
2019-04-09cam: Add support to specify multiple stream configurations with rolesNiklas Söderlund
2019-04-09cam: Extend BufferWriter to include a stream name in file pathNiklas Söderlund
2019-04-09cam: Rename --format to --streamNiklas Söderlund
2019-04-09libcamera: Switch to CameraConfigurationNiklas Söderlund
2019-04-05libcamera: camera: Add support for stream usagesNiklas Söderlund
2019-04-04cam: Rework how streams configuration is preparedNiklas Söderlund
2019-03-27cam: Separate options valid() and empty()Laurent Pinchart
2019-03-27cam: options: Add support for repeatable optionsNiklas Söderlund
2019-03-27cam: options: Add an array data type to OptionValueNiklas Söderlund
2019-03-25cam: options: Create separate enum for OptionValue typesNiklas Söderlund
2019-03-01cam: Don't requeue requests when stopping streamLaurent Pinchart
2019-02-28libcamera: store stream pointers in sets instead of a vectorsNiklas Söderlund
2019-02-28cam: fix order camera is operated onNiklas Söderlund
2019-02-25cam: Improve when usage information is printedNiklas Söderlund
2019-02-25cam: fix printing of camera nameNiklas Söderlund
2019-02-25cam: improve error checking when capturingNiklas Söderlund
l opt">() { /* Test static functions. */ if (!File::exists("/dev/null")) { cerr << "Valid file not found" << endl; return TestFail; } if (File::exists("/dev/null/invalid")) { cerr << "Invalid file should not exist" << endl; return TestFail; } if (File::exists("/dev")) { cerr << "Directories should not be treated as files" << endl; return TestFail; } /* Test unnamed file. */ File file; if (!file.fileName().empty()) { cerr << "Unnamed file has non-empty file name" << endl; return TestFail; } if (file.exists()) { cerr << "Unnamed file exists" << endl; return TestFail; } if (file.isOpen()) { cerr << "File is open after construction" << endl; return TestFail; } if (file.openMode() != File::OpenModeFlag::NotOpen) { cerr << "File has invalid open mode after construction" << endl; return TestFail; } if (file.size() >= 0) { cerr << "Unnamed file has a size" << endl; return TestFail; } if (file.open(File::OpenModeFlag::ReadWrite)) { cerr << "Opening unnamed file succeeded" << endl; return TestFail; } if (file.error() == 0) { cerr << "Open failure didn't set error" << endl; return TestFail; } /* Test named file referring to an invalid file. */ file.setFileName("/dev/null/invalid"); if (file.fileName() != "/dev/null/invalid") { cerr << "File reports incorrect file name" << endl; return TestFail; } if (file.exists()) { cerr << "Invalid file exists" << endl; return TestFail; } if (file.isOpen()) { cerr << "Invalid file is open after construction" << endl; return TestFail; } if (file.openMode() != File::OpenModeFlag::NotOpen) { cerr << "Invalid file has invalid open mode after construction" << endl; return TestFail; } if (file.size() >= 0) { cerr << "Invalid file has a size" << endl; return TestFail; } if (file.open(File::OpenModeFlag::ReadWrite)) { cerr << "Opening invalid file succeeded" << endl; return TestFail; } /* Test named file referring to a valid file. */ file.setFileName("/dev/null"); if (!file.exists()) { cerr << "Valid file does not exist" << endl; return TestFail; } if (file.isOpen()) { cerr << "Valid file is open after construction" << endl; return TestFail; } if (file.openMode() != File::OpenModeFlag::NotOpen) { cerr << "Valid file has invalid open mode after construction" << endl; return TestFail; } if (file.size() >= 0) { cerr << "Invalid file has a size" << endl; return TestFail; } /* Test open and close. */ if (!file.open(File::OpenModeFlag::ReadWrite)) { cerr << "Opening file failed" << endl; return TestFail; } if (!file.isOpen()) { cerr << "Open file reported as closed" << endl; return TestFail; } if (file.openMode() != File::OpenModeFlag::ReadWrite) { cerr << "Open file has invalid open mode" << endl; return TestFail; } file.close(); if (file.isOpen()) { cerr << "Closed file reported as open" << endl; return TestFail; } if (file.openMode() != File::OpenModeFlag::NotOpen) { cerr << "Closed file has invalid open mode" << endl; return TestFail; } /* Test size(). */ file.setFileName(self()); if (file.size() >= 0) { cerr << "File has valid size before open" << endl; return TestFail; } file.open(File::OpenModeFlag::ReadOnly); ssize_t size = file.size(); if (size <= 0) { cerr << "File has invalid size after open" << endl; return TestFail; } file.close(); /* Test file creation. */ file.setFileName(fileName_); if (file.exists()) { cerr << "Temporary file already exists" << endl; return TestFail; } if (file.open(File::OpenModeFlag::ReadOnly)) { cerr << "Read-only open succeeded on nonexistent file" << endl; return TestFail; } if (!file.open(File::OpenModeFlag::WriteOnly)) { cerr << "Write-only open failed on nonexistent file" << endl; return TestFail; } if (!file.exists()) { cerr << "Write-only open failed to create file" << endl; return TestFail; } file.close(); /* Test read and write. */ std::array<uint8_t, 256> buffer = { 0 }; strncpy(reinterpret_cast<char *>(buffer.data()), "libcamera", buffer.size()); if (file.read(buffer) >= 0) { cerr << "Read succeeded on closed file" << endl; return TestFail; } if (file.write(buffer) >= 0) { cerr << "Write succeeded on closed file" << endl; return TestFail; } file.open(File::OpenModeFlag::ReadOnly); if (file.write(buffer) >= 0) { cerr << "Write succeeded on read-only file" << endl; return TestFail; } file.close(); file.open(File::OpenModeFlag::ReadWrite); if (file.write({ buffer.data(), 9 }) != 9) { cerr << "Write test failed" << endl; return TestFail; } if (file.read(buffer) != 0) { cerr << "Read at end of file test failed" << endl; return TestFail; } if (file.seek(0) != 0) { cerr << "Seek test failed" << endl; return TestFail; } if (file.read(buffer) != 9) { cerr << "Read test failed" << endl; return TestFail; } if (file.pos() != 9) { cerr << "Position test failed" << endl; return TestFail; } file.close(); /* Test mapping and unmapping. */ file.setFileName(self()); file.open(File::OpenModeFlag::ReadOnly); Span<uint8_t> data = file.map(); if (data.empty()) { cerr << "Mapping of complete file failed" << endl; return TestFail; } if (data.size() != static_cast<size_t>(size)) { cerr << "Mapping of complete file has invalid size" << endl; return TestFail; } if (!file.unmap(data.data())) { cerr << "Unmapping of complete file failed" << endl; return TestFail; } data = file.map(4096, 8192); if (data.empty()) { cerr << "Mapping of file region failed" << endl; return TestFail; } if (data.size() != 8192) { cerr << "Mapping of file region has invalid size" << endl; return TestFail; } if (!file.unmap(data.data())) { cerr << "Unmapping of file region failed" << endl; return TestFail; } file.close(); /* Test private mapping. */ file.setFileName(fileName_); file.open(File::OpenModeFlag::ReadWrite); data = file.map(0, -1, File::MapFlag::Private); if (data.empty()) { cerr << "Private mapping failed" << endl; return TestFail; } std::string str{ reinterpret_cast<char *>(data.data()), data.size() }; if (str != "libcamera") { cerr << "Invalid contents of private mapping" << endl; return TestFail; } memcpy(data.data(), "LIBCAMERA", 9); if (!file.unmap(data.data())) { cerr << "Private unmapping failed" << endl; return TestFail; } data = file.map(); str = { reinterpret_cast<char *>(data.data()), data.size() }; if (str != "libcamera") { cerr << "Private mapping changed file contents" << endl; return TestFail; } /* Test shared mapping. */ data = file.map(); if (data.empty()) { cerr << "Shared mapping failed" << endl; return TestFail; } memcpy(data.data(), "LIBCAMERA", 9); if (!file.unmap(data.data())) { cerr << "Shared unmapping failed" << endl; return TestFail; } data = file.map(); str = { reinterpret_cast<char *>(data.data()), data.size() }; if (str != "LIBCAMERA") { cerr << "Shared mapping failed to change file contents" << endl; return TestFail; } return TestPass; } void cleanup() { unlink(fileName_.c_str()); } private: std::string fileName_; }; TEST_REGISTER(FileTest)