tests: Add fifo_test.
Creates, opens, tries to open as directory, then unlinks. The attempt to open as a directory triggers an assertion in the kernel at present (this is #17870.) The next commit will fix that.
This commit is contained in:
@@ -14,6 +14,7 @@ SimpleTest calloc_test : calloc_test.c ;
|
||||
SimpleTest <test>chmod : chmod.cpp ;
|
||||
SimpleTest clearenv : clearenv.cpp ;
|
||||
SimpleTest dirent_test : dirent_test.cpp ;
|
||||
SimpleTest fifo_test : fifo_test.cpp ;
|
||||
SimpleTest flock_test : flock_test.cpp ;
|
||||
SimpleTest fseek_test : fseek_test.cpp ;
|
||||
SimpleTest getsubopt_test : getsubopt_test.cpp ;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
const char* filename = "temp.fifo";
|
||||
|
||||
if (mkfifo("temp.fifo", S_IRWXU) != 0) {
|
||||
perror("mkfifo error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rfd = open(filename, O_RDONLY | O_NONBLOCK);
|
||||
if (rfd < 0) {
|
||||
perror("open() error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
DIR* dir = opendir(filename);
|
||||
if (dir != NULL) {
|
||||
perror("opendir succeeded");
|
||||
return 1;
|
||||
}
|
||||
|
||||
dir = fdopendir(rfd);
|
||||
if (dir != NULL) {
|
||||
perror("fdopendir succeeded");
|
||||
return 1;
|
||||
}
|
||||
|
||||
unlink(filename);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user