1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2017 Carlo Marcelo Arenas Belon <carlo@gmail.com>
4 * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz>
5 */
6
7 /*\
8 * [Description]
9 *
10 * Tests for a special case NULL buffer with size 0 is expected to return 0.
11 */
12
13 #include <errno.h>
14 #include "tst_test.h"
15
16 static int fd;
17
verify_pwrite(void)18 static void verify_pwrite(void)
19 {
20 TST_EXP_PASS(pwrite(fd, NULL, 0, 0), "pwrite(%d, NULL, 0) == 0", fd);
21 }
22
setup(void)23 static void setup(void)
24 {
25 fd = SAFE_OPEN("test_file", O_RDWR | O_CREAT, 0700);
26 }
27
cleanup(void)28 static void cleanup(void)
29 {
30 if (fd > 0)
31 SAFE_CLOSE(fd);
32 }
33
34 static struct tst_test test = {
35 .setup = setup,
36 .cleanup = cleanup,
37 .test_all = verify_pwrite,
38 .needs_tmpdir = 1,
39 };
40