FreeBSD regtest: remove test for version 13+ syscalls
[valgrind.git] / memcheck / tests / freebsd / utimes.c
blob17557986bdd606bd8e9ad7aa6cf1cb2ee1c2807d
1 /*
2 * Tests for the utimes functions
4 * utimes, lutimes, futimes, futimesat
5 */
7 #include <sys/time.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <dirent.h>
12 #include <string.h>
14 int main(void)
16 char tmpfile1[] = "/tmp/testutimes1.XXXXXX";
17 int tmpfd1 = mkstemp(tmpfile1);
19 struct timeval times[2];
20 times[0].tv_sec = 12;
21 times[0].tv_usec = 14142;
22 times[1].tv_sec = 13;
23 times[1].tv_usec = 12345;
24 if (-1 == utimes("utimes.c", NULL)) {
25 perror("utimes failed: ");
28 if (-1 == utimes("utimes.c", times)) {
29 perror("utimes failed: ");
32 times[0].tv_sec = 14;
33 times[0].tv_usec = 70711;
34 times[1].tv_sec = 15;
35 times[1].tv_usec = 23456;
36 if (-1 == futimes(tmpfd1, NULL)) {
37 perror("futimes failed: ");
39 if (-1 == futimes(tmpfd1, times)) {
40 perror("futimes failed: ");
43 char tmpsymlink[] = "/tmp/testutimes2.XXXXXX";
44 mktemp(tmpsymlink);
46 DIR* tmpdir = opendir("/tmp");
47 if (tmpdir) {
48 int tmpdirfd = dirfd(tmpdir);
50 if (-1 == symlinkat(tmpfile1+5, tmpdirfd, tmpsymlink+5)) {
51 perror("symlinkat failed");
54 times[0].tv_sec = 16;
55 times[0].tv_usec = 15708;
56 times[1].tv_sec = 17;
57 times[1].tv_usec = 34567;
59 if (-1 == lutimes(tmpsymlink, NULL)) {
60 perror("lutimes failed: ");
63 if (-1 == lutimes(tmpsymlink, times)) {
64 perror("lutimes failed: ");
67 times[0].tv_sec = 18;
68 times[0].tv_usec = 63662;
69 times[1].tv_sec = 20;
70 times[1].tv_usec = 31831;
72 if (-1 == futimesat(tmpdirfd, tmpfile1+5, NULL)) {
73 perror("fuutimesat failed: ");
76 if (-1 == futimesat(tmpdirfd, tmpfile1+5, times)) {
77 perror("fuutimesat failed: ");
80 closedir(tmpdir);
83 close(tmpfd1);
85 unlink(tmpfile1);
86 unlink(tmpsymlink);
88 // error section
90 char* badstring = strdup("foo");
91 free(badstring);
92 int badint;
94 utimes(badstring, (struct timeval*)badstring);
95 lutimes(badstring, (struct timeval*)badstring);
96 futimes(badint, (struct timeval*)badstring);
97 futimesat(badint, badstring, (struct timeval*)badstring);