• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) International Business Machines  Corp., 2001
3  *
4  * This program is free software;  you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
12  * the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /* DESCRIPTION
19  *   This test will verify that rmdir(2) syscall basic functionality.
20  *   verify rmdir(2) returns a value of 0 and the directory being removed.
21  */
22 #include <errno.h>
23 #include <sys/stat.h>
24 #include <sys/types.h>
25 #include <unistd.h>
26 #include "tst_test.h"
27 
28 #define TESTDIR "testdir"
29 
verify_rmdir(void)30 static void verify_rmdir(void)
31 {
32 	struct stat buf;
33 
34 	SAFE_MKDIR(TESTDIR, 0777);
35 
36 	TEST(rmdir(TESTDIR));
37 	if (TST_RET == -1) {
38 		tst_res(TFAIL | TTERRNO, "rmdir(%s) failed", TESTDIR);
39 		return;
40 	}
41 
42 	if (!stat(TESTDIR, &buf))
43 		tst_res(TFAIL, "rmdir(%s) failed", TESTDIR);
44 	else
45 		tst_res(TPASS, "rmdir(%s) success", TESTDIR);
46 }
47 
48 static struct tst_test test = {
49 	.test_all = verify_rmdir,
50 	.needs_tmpdir = 1,
51 };
52 
53