1 /******************************************************************************/
2 /* Copyright (c) Jens Axboe <axboe@kernel.dk>, 2009 */
3 /* */
4 /* LKML Reference: http://lkml.org/lkml/2009/4/2/55 */
5 /* */
6 /* This program is free software; you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation; either version 2 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* This program is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
14 /* the GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with this program; if not, write to the Free Software Foundation, */
18 /* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
19 /* */
20 /******************************************************************************/
21 /******************************************************************************/
22 /* Description: This tests the splice() syscall */
23 /******************************************************************************/
24 #define _GNU_SOURCE
25
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <fcntl.h>
30
31 #include "tst_test.h"
32 #include "lapi/splice.h"
33
34 #define SPLICE_SIZE (64*1024)
35
splice_test(void)36 static void splice_test(void)
37 {
38 int fd;
39
40 fd = SAFE_OPEN("splice02-temp", O_WRONLY | O_CREAT | O_TRUNC, 0644);
41
42 TEST(splice(STDIN_FILENO, NULL, fd, NULL, SPLICE_SIZE, 0));
43 if (TST_RET < 0) {
44 tst_res(TFAIL, "splice failed - errno = %d : %s",
45 TST_ERR, strerror(TST_ERR));
46 } else {
47 tst_res(TPASS, "splice() system call Passed");
48 }
49
50 SAFE_CLOSE(fd);
51 }
52
53 static struct tst_test test = {
54 .test_all = splice_test,
55 .needs_tmpdir = 1,
56 .min_kver = "2.6.17",
57 };
58