FreeBSD regtest: remove test for version 13+ syscalls
[valgrind.git] / memcheck / tests / freebsd / stat.c
blob3fea9a2b24afeba5bec26f58b56067e8714d24c4
1 /*
2 * Tests for various stat functions
4 * stat - tests fstatat with 1st arg AT_FDCWD
5 * fstatat
6 */
9 #include <sys/stat.h>
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include <assert.h>
14 #include <fcntl.h>
15 #include <dirent.h>
16 #include <unistd.h>
18 int main()
20 struct stat sb;
22 if (-1 == stat("stat.c", &sb))
24 perror("stat failed:");
27 assert(sb.st_size == 1161);
29 int fd = openat(AT_FDCWD, "stat.c", O_RDONLY);
30 if (-1 == fd)
32 perror("openat failed:");
35 if (-1 == fstat(fd, &sb))
37 perror("fstat failed:");
40 DIR* cwd = opendir(".");
41 if (cwd)
43 int cwdfd = dirfd(cwd);
44 fstatat(cwdfd, "stat.c", &sb, 0);
45 closedir(cwd);
48 // error section
49 char *badfilename = strdup("stat.c");
50 free(badfilename);
52 stat(badfilename, &sb);
54 struct stat* badpsb = malloc(sizeof(struct stat));
55 free(badpsb);
57 stat("stat.c", badpsb);
59 badpsb = malloc(sizeof(struct stat));
60 free(badpsb);
61 fstat(fd, badpsb);
63 int badfd;
64 fstat(badfd, &sb);
66 fstatat(badfd, "stat.c", &sb, 0);
67 fstatat(fd, "stat.c", &sb, badfd);
69 close(fd);