1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. 4f08c3bdfSopenharmony_ci * 06/1994 AUTHOR: Richard Logan CO-PILOT: William Roske 5f08c3bdfSopenharmony_ci * Copyright (c) 2023 SUSE LLC 6f08c3bdfSopenharmony_ci */ 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ci/*\ 9f08c3bdfSopenharmony_ci * [Description] 10f08c3bdfSopenharmony_ci * 11f08c3bdfSopenharmony_ci * Basic test for dup(2) of a system pipe descriptor. 12f08c3bdfSopenharmony_ci */ 13f08c3bdfSopenharmony_ci 14f08c3bdfSopenharmony_ci#ifndef _GNU_SOURCE 15f08c3bdfSopenharmony_ci#define _GNU_SOURCE 16f08c3bdfSopenharmony_ci#endif 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_ci#include "tst_test.h" 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_cistatic int fd[2]; 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_cistatic void run(void) 23f08c3bdfSopenharmony_ci{ 24f08c3bdfSopenharmony_ci TST_EXP_FD(dup(fd[0]), "dup(%d) read end of the pipe", fd[0]); 25f08c3bdfSopenharmony_ci SAFE_CLOSE(TST_RET); 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci TST_EXP_FD(dup(fd[1]), "dup(%d) write end of the pipe", fd[1]); 28f08c3bdfSopenharmony_ci SAFE_CLOSE(TST_RET); 29f08c3bdfSopenharmony_ci} 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_cistatic void setup(void) 32f08c3bdfSopenharmony_ci{ 33f08c3bdfSopenharmony_ci fd[0] = -1; 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ci SAFE_PIPE(fd); 36f08c3bdfSopenharmony_ci} 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_cistatic struct tst_test test = { 39f08c3bdfSopenharmony_ci .test_all = run, 40f08c3bdfSopenharmony_ci .setup = setup, 41f08c3bdfSopenharmony_ci .needs_tmpdir = 1, 42f08c3bdfSopenharmony_ci}; 43