• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) International Business Machines Corp., 2001
4  */
5 
6 /* DESCRIPTION
7  *   This test will verify that rmdir(2) syscall basic functionality.
8  *   verify rmdir(2) returns a value of 0 and the directory being removed.
9  */
10 #include <errno.h>
11 #include <sys/stat.h>
12 #include <sys/types.h>
13 #include <unistd.h>
14 #include "tst_test.h"
15 
16 #define TESTDIR "testdir"
17 
verify_rmdir(void)18 static void verify_rmdir(void)
19 {
20 	struct stat buf;
21 
22 	SAFE_MKDIR(TESTDIR, 0777);
23 
24 	TEST(rmdir(TESTDIR));
25 	if (TST_RET == -1) {
26 		tst_res(TFAIL | TTERRNO, "rmdir(%s) failed", TESTDIR);
27 		return;
28 	}
29 
30 	if (!stat(TESTDIR, &buf))
31 		tst_res(TFAIL, "rmdir(%s) failed", TESTDIR);
32 	else
33 		tst_res(TPASS, "rmdir(%s) success", TESTDIR);
34 }
35 
36 static struct tst_test test = {
37 	.test_all = verify_rmdir,
38 	.needs_tmpdir = 1,
39 };
40 
41