summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Expand)Author
2020-10-07libcamera: ProcessManager: make ProcessManager lifetime explicitly managedPaul Elder
2020-09-21test: Include specific headers instead of libcamera.hLaurent Pinchart
2020-08-25meson: Remove -Wno-unused-parameterLaurent Pinchart
2020-08-14libcamera: request: Make Stream pointer constNiklas Söderlund
2020-08-14libcamera: request: Declare a using directive for map of buffersNiklas Söderlund
2020-08-13test: ipc: unixsocket: Close open fds on error pathsUmang Jain
2020-08-06test: mapped-buffers: Provide MappedBuffer testKieran Bingham
2020-08-05libcamera: camera: Rename name() to id()Niklas Söderlund
2020-08-05libcamera: pipelines: Use sensor ID as camera nameNiklas Söderlund
2020-08-03libcamera: geometry: Add isNull() function to Rectangle classJacopo Mondi
2020-08-03libcamera: utils: Add alignUp and alignDown functionsJacopo Mondi
2020-07-31tests: Add a test case for the Object::deleteLater() API, to verifyUmang Jain
2020-07-28test: Remove list-cameras testLaurent Pinchart
2020-07-27test: process: Test Process::kill()Laurent Pinchart
2020-07-23libcamera: v4l2_subdevice: Replace ImageFormats with a mapNiklas Söderlund
2020-07-17tests: v4l2_compat: Fix v4l2-compliance and v4l2-ctl version parsingPaul Elder
2020-07-17libcamera: ipa_interface: Add support for custom IPA data to configure()Laurent Pinchart
2020-07-15test: file: Add file creation testLaurent Pinchart
2020-07-15test: file: Add read/write testsLaurent Pinchart
2020-07-15libcamera: geometry: Provide in-place versions of the Size helpersLaurent Pinchart
2020-07-15libcamera: geometry: Add helper functions to the Size classLaurent Pinchart
2020-07-13tests: v4l2_compat: Check v4l2-compliance and v4l2-ctl versionsPaul Elder
2020-07-13tests: v4l2_compat: Prettify failure outputPaul Elder
2020-07-10tests: v4l2_compat: Add test for v4l2_compatPaul Elder
2020-07-09libcamera: utils: Add map_keys() functionLaurent Pinchart
2020-07-08libcamera: Use Size::isNull()Laurent Pinchart
2020-06-29libcamera: geometry: Add isNull() function to Size classLaurent Pinchart
2020-06-25libcamera: pixel_format: Replace hex with format namesKaaira Gupta
2020-06-18test: Replace explicit DRM FourCCs with libcamera formatsLaurent Pinchart
2020-06-17tests: Introduce hotplug hot-unplug unit testUmang Jain
2020-06-08test: v4l2_subdevice: list_formats: Port to use utils::hex() output helperUmang Jain
2020-06-08libcamera: IPAManager: remove instance() and make createIPA() staticPaul Elder
2020-06-08libcamera: IPAManager: make IPAManager lifetime explicitly managedPaul Elder
2020-06-04test: log: log_api: Close open fds on error pathsUmang Jain
2020-06-04test: log: log_process: Close open fds on error pathsUmang Jain
2020-06-02test: Fixed the compilation issueMadhavan Krishnan
2020-05-19test: file-descriptor: Add "fd move" constructor testLaurent Pinchart
2020-05-16libcamera: Move IPA headers from include/ipa/ to include/libcamera/ipa/Laurent Pinchart
2020-05-16libcamera: Move internal headers to include/libcamera/internal/Laurent Pinchart
2020-05-13licenses: License all meson files under CC0-1.0Laurent Pinchart
2020-04-30libcamera: v4l2_pixelformat: Move DRM/V4L2 format conversionLaurent Pinchart
2020-04-28libcamera: ipa: Add support for CameraSensorInfoJacopo Mondi
2020-04-28test: camera_sensor: Test the model() functionLaurent Pinchart
2020-04-28libcamera: v4l2_device: Simplify usage of getControls()Laurent Pinchart
2020-04-28test: ipa: ipa_interface: Pass configuration file to IPA init()Laurent Pinchart
2020-04-28ipa: Pass IPA initialization settings to IPAInterface::init()Laurent Pinchart
2020-04-28ipa: Name IPA modules after their source directoryLaurent Pinchart
2020-04-27test: Use float values for brightness, contrast and saturationLaurent Pinchart
2020-04-15test: list-camera: Handle error on starting the CameraManagerUmang Jain
2020-04-15libcamera: utils: Add string join functionLaurent Pinchart
span class="hl kwd">close(fd); unlink(fileName_.c_str()); return TestPass; } int run() { /* 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)