1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) International Business Machines Corp., 2001 4f08c3bdfSopenharmony_ci */ 5f08c3bdfSopenharmony_ci 6f08c3bdfSopenharmony_ci/* 7f08c3bdfSopenharmony_ci * DESCRIPTION 8f08c3bdfSopenharmony_ci * fchdir01 - create a directory and cd into it. 9f08c3bdfSopenharmony_ci */ 10f08c3bdfSopenharmony_ci 11f08c3bdfSopenharmony_ci#include "tst_test.h" 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_cistatic int fd; 14f08c3bdfSopenharmony_cistatic const char *TEST_DIR = "alpha"; 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci#define MODES S_IRWXU 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_cistatic void verify_fchdir(void) 19f08c3bdfSopenharmony_ci{ 20f08c3bdfSopenharmony_ci TST_EXP_PASS(fchdir(fd)); 21f08c3bdfSopenharmony_ci} 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_cistatic void setup(void) 24f08c3bdfSopenharmony_ci{ 25f08c3bdfSopenharmony_ci SAFE_MKDIR(TEST_DIR, MODES); 26f08c3bdfSopenharmony_ci fd = SAFE_OPEN(TEST_DIR, O_RDONLY); 27f08c3bdfSopenharmony_ci} 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_cistatic void cleanup(void) 30f08c3bdfSopenharmony_ci{ 31f08c3bdfSopenharmony_ci SAFE_CLOSE(fd); 32f08c3bdfSopenharmony_ci} 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_cistatic struct tst_test test = { 35f08c3bdfSopenharmony_ci .test_all = verify_fchdir, 36f08c3bdfSopenharmony_ci .setup = setup, 37f08c3bdfSopenharmony_ci .cleanup = cleanup, 38f08c3bdfSopenharmony_ci .needs_tmpdir = 1, 39f08c3bdfSopenharmony_ci}; 40