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/* DESCRIPTION 7f08c3bdfSopenharmony_ci * This test will verify that rmdir(2) syscall basic functionality. 8f08c3bdfSopenharmony_ci * verify rmdir(2) returns a value of 0 and the directory being removed. 9f08c3bdfSopenharmony_ci */ 10f08c3bdfSopenharmony_ci#include <errno.h> 11f08c3bdfSopenharmony_ci#include <sys/stat.h> 12f08c3bdfSopenharmony_ci#include <sys/types.h> 13f08c3bdfSopenharmony_ci#include <unistd.h> 14f08c3bdfSopenharmony_ci#include "tst_test.h" 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci#define TESTDIR "testdir" 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_cistatic void verify_rmdir(void) 19f08c3bdfSopenharmony_ci{ 20f08c3bdfSopenharmony_ci struct stat buf; 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci SAFE_MKDIR(TESTDIR, 0777); 23f08c3bdfSopenharmony_ci 24f08c3bdfSopenharmony_ci TEST(rmdir(TESTDIR)); 25f08c3bdfSopenharmony_ci if (TST_RET == -1) { 26f08c3bdfSopenharmony_ci tst_res(TFAIL | TTERRNO, "rmdir(%s) failed", TESTDIR); 27f08c3bdfSopenharmony_ci return; 28f08c3bdfSopenharmony_ci } 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ci if (!stat(TESTDIR, &buf)) 31f08c3bdfSopenharmony_ci tst_res(TFAIL, "rmdir(%s) failed", TESTDIR); 32f08c3bdfSopenharmony_ci else 33f08c3bdfSopenharmony_ci tst_res(TPASS, "rmdir(%s) success", TESTDIR); 34f08c3bdfSopenharmony_ci} 35f08c3bdfSopenharmony_ci 36f08c3bdfSopenharmony_cistatic struct tst_test test = { 37f08c3bdfSopenharmony_ci .test_all = verify_rmdir, 38f08c3bdfSopenharmony_ci .needs_tmpdir = 1, 39f08c3bdfSopenharmony_ci}; 40f08c3bdfSopenharmony_ci 41