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