[LTP] [PATCH 2/2] tee01, vmsplice01, af_alg08: Use SAFE_SPLICE()
Andrea Cervesato
andrea.cervesato@suse.de
Thu Apr 30 19:25:30 CEST 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
Replace raw splice() calls with manual error checking by
SAFE_SPLICE() in tests where splice is not the subject of
testing but just utility plumbing.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/crypto/af_alg08.c | 10 ++--------
testcases/kernel/syscalls/tee/tee01.c | 9 ++-------
testcases/kernel/syscalls/vmsplice/vmsplice01.c | 6 +-----
3 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/testcases/kernel/crypto/af_alg08.c b/testcases/kernel/crypto/af_alg08.c
index 4f27f3c9da7cc277926c6fe3eee1a4649a483763..05f17eea4797b7575c97e194e34c0390c6d6be22 100644
--- a/testcases/kernel/crypto/af_alg08.c
+++ b/testcases/kernel/crypto/af_alg08.c
@@ -27,7 +27,6 @@
#include "tst_test.h"
#include "tst_af_alg.h"
#include "lapi/socket.h"
-#include "lapi/splice.h"
#define TESTFILE "copy_fail"
#define OVERWRITE_SIZE 4
@@ -92,13 +91,8 @@ static void try_corrupt(void)
SAFE_PIPE(pipefd);
- TEST(splice(file_fd, &off_in, pipefd[1], NULL, OVERWRITE_SIZE, 0));
- if (TST_RET < 0)
- tst_brk(TBROK | TTERRNO, "splice(file -> pipe)");
-
- TEST(splice(pipefd[0], NULL, reqfd, NULL, OVERWRITE_SIZE, 0));
- if (TST_RET < 0)
- tst_brk(TBROK | TTERRNO, "splice(pipe -> AF_ALG)");
+ SAFE_SPLICE(file_fd, &off_in, pipefd[1], NULL, OVERWRITE_SIZE, 0);
+ SAFE_SPLICE(pipefd[0], NULL, reqfd, NULL, OVERWRITE_SIZE, 0);
/* Expected to fail (invalid ciphertext); triggers the scratch write */
TST_EXP_FAIL_SILENT(recv(reqfd, recvbuf, sizeof(recvbuf), 0), EBADMSG);
diff --git a/testcases/kernel/syscalls/tee/tee01.c b/testcases/kernel/syscalls/tee/tee01.c
index d1489d0453f11faab41ab6e8e2dabbb372566f60..680793eb2b21cfd2609492d3be3bef10abb25acf 100644
--- a/testcases/kernel/syscalls/tee/tee01.c
+++ b/testcases/kernel/syscalls/tee/tee01.c
@@ -15,7 +15,6 @@
#include "tst_test.h"
#include "lapi/fcntl.h"
#include "lapi/tee.h"
-#include "lapi/splice.h"
#define TEST_BLOCK_SIZE 1024
@@ -58,17 +57,13 @@ static void tee_test(void)
SAFE_PIPE(pipe1);
SAFE_PIPE(pipe2);
- ret = splice(fd_in, NULL, pipe1[1], NULL, TEST_BLOCK_SIZE, 0);
- if (ret < 0)
- tst_brk(TBROK | TERRNO, "splice(fd_in, pipe1) failed");
+ SAFE_SPLICE(fd_in, NULL, pipe1[1], NULL, TEST_BLOCK_SIZE, 0);
ret = tee(pipe1[0], pipe2[1], TEST_BLOCK_SIZE, SPLICE_F_NONBLOCK);
if (ret < 0)
tst_brk(TBROK | TERRNO, "tee() failed");
- ret = splice(pipe2[0], NULL, fd_out, NULL, TEST_BLOCK_SIZE, 0);
- if (ret < 0)
- tst_brk(TBROK | TERRNO, "splice(pipe2, fd_out) failed");
+ SAFE_SPLICE(pipe2[0], NULL, fd_out, NULL, TEST_BLOCK_SIZE, 0);
SAFE_CLOSE(pipe2[0]);
SAFE_CLOSE(pipe2[1]);
diff --git a/testcases/kernel/syscalls/vmsplice/vmsplice01.c b/testcases/kernel/syscalls/vmsplice/vmsplice01.c
index 17486179baa2a897c2efbf0d2b4d39273788aadc..7b55e66a373d2d72824fbb9146b2af353a5ff1c9 100644
--- a/testcases/kernel/syscalls/vmsplice/vmsplice01.c
+++ b/testcases/kernel/syscalls/vmsplice/vmsplice01.c
@@ -15,7 +15,6 @@
#include "tst_test.h"
#include "lapi/fcntl.h"
-#include "lapi/splice.h"
#include "lapi/vmsplice.h"
#define TEST_BLOCK_SIZE (1<<17) /* 128K */
@@ -50,7 +49,6 @@ static void vmsplice_test(void)
{
int pipes[2];
long written;
- int ret;
int fd_out;
struct iovec v;
loff_t offset;
@@ -85,9 +83,7 @@ static void vmsplice_test(void)
}
}
- ret = splice(pipes[0], NULL, fd_out, &offset, written, 0);
- if (ret < 0)
- tst_brk(TBROK | TERRNO, "splice() failed");
+ SAFE_SPLICE(pipes[0], NULL, fd_out, &offset, written, 0);
//printf("offset = %lld\n", (long long)offset);
}
--
2.51.0
More information about the ltp
mailing list