test: Remove uses of O_TMPFILE
`O_TMPFILE` requires file system support, which may not be available in certain environments, usually containerized ones. So do not use it. A new function is added for tests to be able to create unnamed temporary files using `libcamera::MemFd` as the implementation. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
@@ -109,18 +109,17 @@ protected:
|
||||
|
||||
int testFile()
|
||||
{
|
||||
int fd = open("/tmp", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
if (fd < 0) {
|
||||
UniqueFD fd = test::createTemporaryFile();
|
||||
if (!fd.isValid()) {
|
||||
cerr << "Failed to open tmp log file" << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
char path[32];
|
||||
snprintf(path, sizeof(path), "/proc/self/fd/%u", fd);
|
||||
snprintf(path, sizeof(path), "/proc/self/fd/%u", fd.get());
|
||||
|
||||
if (logSetFile(path) < 0) {
|
||||
cerr << "Failed to set log file" << endl;
|
||||
close(fd);
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
@@ -128,13 +127,11 @@ protected:
|
||||
|
||||
char buf[1000];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
if (read(fd, buf, sizeof(buf)) < 0) {
|
||||
lseek(fd.get(), 0, SEEK_SET);
|
||||
if (read(fd.get(), buf, sizeof(buf)) < 0) {
|
||||
cerr << "Failed to read tmp log file" << endl;
|
||||
close(fd);
|
||||
return TestFail;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
istringstream iss(buf);
|
||||
return verifyOutput(iss);
|
||||
|
||||
Reference in New Issue
Block a user