}
if (ftruncate(fd, size) != 0) {
printf("failure: ftruncate [\n%s\n]\n", strerror(errno));
+ close(fd);
return false;
}
if (fstat(fd, &st) != 0) {
printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno));
+ close(fd);
return false;
}
if (st.st_size != size) {
printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n",
(int)st.st_size, size);
+ close(fd);
return false;
}
unlink(TESTFILE);
printf("success: ftruncate\n");
+ close(fd);
return true;
}
x = strndup("bla", 10);
if (strcmp(x, "bla") != 0) {
printf("failure: strndup [\ninvalid\n]\n");
+ free(x);
return false;
}
free(x);
printf("failure: utime [\n"
"fstat (1) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
printf("failure: utime [\n"
"utime(&u) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
printf("failure: utime [\n"
"fstat (2) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
printf("failure: utime [\n"
"utime(NULL) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
printf("failure: utime [\n"
"fstat (3) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
"%s: %s(%d) %s %s(%d)\n]\n", \
__location__, \
#a, (int)a, #c, #b, (int)b); \
+ close(fd); \
return false; \
} \
} while(0)
unlink(TESTFILE);
printf("success: utime\n");
+ close(fd);
return true;
}
printf("failure: utimes [\n"
"fstat (1) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
printf("failure: utimes [\n"
"utimes(tv) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
printf("failure: utimes [\n"
"fstat (2) failed - %s\n]\n",
strerror(errno));
+ close(fd);
return false;
}
"%s: %s(%d) != %s(%d)\n]\n", \
__location__, \
#a, (int)a, #b, (int)b); \
+ close(fd); \
return false; \
} \
} while(0)
unlink(TESTFILE);
printf("success: utimes\n");
+ close(fd);
return true;
}