summaryrefslogtreecommitdiffstats
path: root/tools/regression/sockets
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-12-11 16:06:52 +0000
committerpjd <pjd@FreeBSD.org>2010-12-11 16:06:52 +0000
commit4bcdb20a604f3f16ea8b45accd7679739119339f (patch)
treee78b3ead1617d8cc95cd33e15638bc23ed6321b3 /tools/regression/sockets
parent2d568ee741cbb447c81442279eacbb4875f4e732 (diff)
downloadFreeBSD-src-4bcdb20a604f3f16ea8b45accd7679739119339f.zip
FreeBSD-src-4bcdb20a604f3f16ea8b45accd7679739119339f.tar.gz
Allow to specify path to a file we want to test with sendfile(2).
This allows to specify selected file system and not only /tmp/.
Diffstat (limited to 'tools/regression/sockets')
-rw-r--r--tools/regression/sockets/sendfile/sendfile.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/regression/sockets/sendfile/sendfile.c b/tools/regression/sockets/sendfile/sendfile.c
index c815824..bd8c0c5 100644
--- a/tools/regression/sockets/sendfile/sendfile.c
+++ b/tools/regression/sockets/sendfile/sendfile.c
@@ -35,6 +35,7 @@
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <limits.h>
#include <md5.h>
#include <signal.h>
@@ -408,7 +409,7 @@ cleanup(void)
}
int
-main(void)
+main(int argc, char *argv[])
{
char *page_buffer;
int pagesize;
@@ -422,8 +423,20 @@ main(void)
FAIL_ERR("malloc")
bzero(page_buffer, TEST_PAGES * pagesize);
- snprintf(path, PATH_MAX, "/tmp/sendfile.XXXXXXXXXXXX");
- file_fd = mkstemp(path);
+ if (argc == 1) {
+ snprintf(path, PATH_MAX, "/tmp/sendfile.XXXXXXXXXXXX");
+ file_fd = mkstemp(path);
+ if (file_fd == -1)
+ FAIL_ERR("mkstemp");
+ } else if (argc == 2) {
+ (void)strlcpy(path, argv[1], sizeof(path));
+ file_fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0600);
+ if (file_fd == -1)
+ FAIL_ERR("open");
+ } else {
+ FAIL("usage: sendfile [path]");
+ }
+
atexit(cleanup);
len = write(file_fd, page_buffer, TEST_PAGES * pagesize);
OpenPOWER on IntegriCloud