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