1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) Ulrich Drepper <drepper@redhat.com> 4f08c3bdfSopenharmony_ci * Copyright (c) International Business Machines Corp., 2009 5f08c3bdfSopenharmony_ci * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com> 6f08c3bdfSopenharmony_ci */ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci/*\ 9f08c3bdfSopenharmony_ci * [Description] 10f08c3bdfSopenharmony_ci * 11f08c3bdfSopenharmony_ci * This test verifies that eventfd2 correctly set O_NONBLOCK flag on file when 12f08c3bdfSopenharmony_ci * EFD_NONBLOCK flag is used. 13f08c3bdfSopenharmony_ci */ 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_ci#include <fcntl.h> 16f08c3bdfSopenharmony_ci#include <sys/eventfd.h> 17f08c3bdfSopenharmony_ci#include "tst_test.h" 18f08c3bdfSopenharmony_ci#include "eventfd2.h" 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_cistatic void run(void) 21f08c3bdfSopenharmony_ci{ 22f08c3bdfSopenharmony_ci int fd, flags; 23f08c3bdfSopenharmony_ci 24f08c3bdfSopenharmony_ci fd = eventfd2(1, 0); 25f08c3bdfSopenharmony_ci flags = SAFE_FCNTL(fd, F_GETFL); 26f08c3bdfSopenharmony_ci TST_EXP_EXPR(!(flags & O_NONBLOCK), "O_NONBLOCK is not set"); 27f08c3bdfSopenharmony_ci SAFE_CLOSE(fd); 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci fd = eventfd2(1, EFD_NONBLOCK); 30f08c3bdfSopenharmony_ci flags = SAFE_FCNTL(fd, F_GETFL); 31f08c3bdfSopenharmony_ci TST_EXP_EXPR((flags & O_NONBLOCK), "O_NONBLOCK is set"); 32f08c3bdfSopenharmony_ci SAFE_CLOSE(fd); 33f08c3bdfSopenharmony_ci} 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_cistatic struct tst_test test = { 36f08c3bdfSopenharmony_ci .test_all = run, 37f08c3bdfSopenharmony_ci}; 38