Skip to content
Snippets Groups Projects
Commit bd5afb0c authored by Raphael S. Carvalho's avatar Raphael S. Carvalho Committed by Pekka Enberg
Browse files

tests: Add test case to procfs readdir functionality


Specific output:

Reading directory entries at /proc...
dentry name: .
dentry name: ..
dentry name: self
Reading directory entries at /proc/self...
dentry name: .
dentry name: ..
dentry name: maps

Signed-off-by: default avatarRaphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 6296d671
No related branches found
No related tags found
No related merge requests found
......@@ -11,9 +11,27 @@
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <sys/types.h>
#include <dirent.h>
#define BUF_SIZE 4096
static void proc_readdir(const char *procdir)
{
DIR *dirp;
struct dirent *dp;
if ((dirp = opendir(procdir)) == NULL) {
perror("opendir");
return;
}
printf("Reading directory entries at %s...\n", procdir);
while ((dp = readdir(dirp)) != NULL) {
printf("dentry name: %s\n", dp->d_name);
}
(void) closedir(dirp);
}
int main(int argc, char **argv)
{
unsigned char buf[BUF_SIZE];
......@@ -39,5 +57,9 @@ int main(int argc, char **argv)
if (close(fd) < 0) {
perror("close");
}
proc_readdir("/proc");
proc_readdir("/proc/self");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment