plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 3 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of version 2 of the GNU General Public License as |
| 6 | * published by the Free Software Foundation. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 7 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 8 | * This program is distributed in the hope that it would be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 11 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 12 | * Further, this software is distributed without any warranty that it is |
| 13 | * free of the rightful claim of any third person regarding infringement |
| 14 | * or the like. Any license provided herein, whether implied or |
| 15 | * otherwise, applies only to this software file. Patent licenses, if |
| 16 | * any, provided herein do not apply to combinations of this program with |
| 17 | * other software, or any other product whatsoever. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 18 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 19 | * You should have received a copy of the GNU General Public License along |
Wanlong Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame^] | 20 | * with this program; if not, write the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 22 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 24 | * Mountain View, CA 94043, or: |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 25 | * |
| 26 | * http://www.sgi.com |
| 27 | * |
| 28 | * For further information regarding this notice, see: |
| 29 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 30 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 31 | */ |
yaberauneya | db37adc | 2009-11-09 05:56:58 +0000 | [diff] [blame] | 32 | /* $Id: access01.c,v 1.8 2009/11/09 05:56:58 yaberauneya Exp $ */ |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 33 | /********************************************************** |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 34 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 35 | * OS Test - Silicon Graphics, Inc. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 36 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 37 | * TEST IDENTIFIER : access01 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 38 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 39 | * EXECUTED BY : anyone |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 40 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 41 | * TEST TITLE : Basic test for access(2) using F_OK, |
| 42 | * R_OK, W_OK and X_OK arguments. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 43 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 44 | * PARENT DOCUMENT : usctpl01 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 45 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 46 | * TEST CASE TOTAL : 6 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 47 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 48 | * WALL CLOCK TIME : 1 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 49 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 50 | * CPU TYPES : ALL |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 51 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 52 | * AUTHOR : William Roske |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 53 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 54 | * CO-PILOT : Dave Fenner |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 55 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 56 | * DATE STARTED : 03/30/92 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 57 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 58 | * INITIAL RELEASE : UNICOS 7.0 |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 59 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 60 | * TEST CASES |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 61 | * |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 62 | * 1.) access(2) returns 0 for F_OK...(See Description) |
| 63 | * 2.) access(2) returns 0 for R_OK...(See Description) |
| 64 | * 3.) access(2) returns 0 for W_OK...(See Description) |
| 65 | * 4.) access(2) returns 0 for X_OK...(See Description) |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 66 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 67 | * INPUT SPECIFICATIONS |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 68 | * The standard options for system call tests are accepted. |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 69 | * (See the parse_opts(3) man page). |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 70 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 71 | * OUTPUT SPECIFICATIONS |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 72 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 73 | * DURATION |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 74 | * Terminates - with frequency and infinite modes. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 75 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 76 | * SIGNALS |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 77 | * Uses SIGUSR1 to pause before test if option set. |
| 78 | * (See the parse_opts(3) man page). |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 79 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 80 | * RESOURCES |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 81 | * None |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 82 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 83 | * ENVIRONMENTAL NEEDS |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 84 | * The libcuts.a and libsys.a libraries must be included in |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 85 | * the compilation of this test. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 86 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 87 | * SPECIAL PROCEDURAL REQUIREMENTS |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 88 | * None |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 89 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 90 | * INTERCASE DEPENDENCIES |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 91 | * None |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 92 | * |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 93 | * DETAILED DESCRIPTION |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 94 | * This is a Phase I test for the access(2) system call. It is intended |
| 95 | * to provide a limited exposure of the system call, for now. It |
| 96 | * should/will be extended when full functional tests are written for |
| 97 | * access(2). |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 98 | * |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 99 | * Setup: |
| 100 | * Setup signal handling. |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 101 | * Pause for SIGUSR1 if option specified. |
| 102 | * Create a temp directory and cd to it. |
| 103 | * Creat a temp file wil read, write and execute permissions. |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 104 | * |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 105 | * Test: |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 106 | * Loop if the proper options are given. |
| 107 | * Execute system call with F_OK on tmp file |
| 108 | * Check return code, if system call failed (return=-1) |
| 109 | * Log the errno and Issue a FAIL message. |
| 110 | * Otherwise, Issue a PASS message. |
| 111 | * Execute system call with X_OK on tmp file... |
| 112 | * Execute system call with W_OK on tmp file... |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 113 | * Execute system call with R_OK on tmp file... |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 114 | * |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 115 | * Cleanup: |
| 116 | * Print errno log |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 117 | * |
| 118 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 119 | *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ |
| 120 | |
| 121 | #include <string.h> |
plars | 19d169e | 2002-09-04 13:34:31 +0000 | [diff] [blame] | 122 | #include <unistd.h> |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 123 | #include <sys/types.h> |
| 124 | #include <sys/fcntl.h> |
| 125 | #include <errno.h> |
| 126 | #include <signal.h> |
| 127 | #include <sys/stat.h> |
| 128 | #include "test.h" |
| 129 | #include "usctest.h" |
| 130 | void setup(); |
| 131 | void cleanup(); |
| 132 | |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 133 | char *TCID = "access01"; /* Test program identifier. */ |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 134 | int TST_TOTAL = 4; /* Total number of test cases. */ |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 135 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 136 | char Fname[255]; |
| 137 | |
| 138 | static struct test_case_t { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 139 | char *file; |
| 140 | int mode; |
| 141 | char *string; |
| 142 | int experrno; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 143 | } Test_cases[] = { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 144 | { Fname, F_OK, "F_OK", 0}, |
| 145 | { Fname, X_OK, "X_OK", 0}, |
| 146 | { Fname, W_OK, "W_OK", 0}, |
| 147 | { Fname, R_OK, "R_OK", 0}, |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | int Ntc = sizeof(Test_cases) / sizeof(struct test_case_t); |
| 151 | |
| 152 | /*********************************************************************** |
| 153 | * Main |
| 154 | ***********************************************************************/ |
| 155 | int main(int ac, char **av) |
| 156 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 157 | int lc; /* loop counter */ |
| 158 | char *msg; /* message returned from parse_opts */ |
| 159 | int tc; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 160 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 161 | TST_TOTAL = Ntc; |
| 162 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 163 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 164 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 165 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 166 | setup(); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 167 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 168 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 169 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 170 | Tst_count = 0; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 171 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 172 | for (tc = 0; tc < Ntc; tc++) { |
| 173 | /* |
| 174 | * Call access(2) |
| 175 | */ |
| 176 | TEST(access(Test_cases[tc].file, Test_cases[tc].mode)); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 177 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 178 | /* check return code */ |
| 179 | if (TEST_RETURN == -1 && Test_cases[tc].experrno == 0) { |
vapier | 6f55017 | 2009-08-28 10:46:41 +0000 | [diff] [blame] | 180 | tst_resm(TFAIL|TTERRNO, |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 181 | "access(%s, %s) failed", |
| 182 | Test_cases[tc].file, |
| 183 | Test_cases[tc].string); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 184 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 185 | } else if (TEST_RETURN != -1 |
| 186 | && Test_cases[tc].experrno != 0) { |
| 187 | tst_resm(TFAIL, |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 188 | "access(%s, %s) returned %ld, " |
| 189 | "exp -1, errno:%d", |
| 190 | Test_cases[tc].file, |
| 191 | Test_cases[tc].string, TEST_RETURN, |
| 192 | Test_cases[tc].experrno); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 193 | } else { |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 194 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 195 | if (STD_FUNCTIONAL_TEST) { |
| 196 | /* No Verification test, yet... */ |
| 197 | tst_resm(TPASS, |
vapier | 6f55017 | 2009-08-28 10:46:41 +0000 | [diff] [blame] | 198 | "access(%s, %s) returned %ld", |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 199 | Test_cases[tc].file, |
| 200 | Test_cases[tc].string, |
| 201 | TEST_RETURN); |
| 202 | } |
| 203 | } |
| 204 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 205 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 206 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 207 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 208 | cleanup(); |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 209 | tst_exit(); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 210 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 211 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 212 | void setup() |
subrata_modak | 4bb656a | 2009-02-26 12:02:09 +0000 | [diff] [blame] | 213 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 214 | int fd; |
| 215 | struct stat stbuf; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 216 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 217 | tst_sig(FORK, DEF_HANDLER, cleanup); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 218 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 219 | umask(0); /* reset umask avoid it affects on modes */ |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 220 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 221 | TEST_PAUSE; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 222 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 223 | tst_tmpdir(); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 224 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 225 | /* |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 226 | * Since files inherit group ids, make sure our dir has a valid grp |
| 227 | * to us. |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 228 | */ |
yaberauneya | db37adc | 2009-11-09 05:56:58 +0000 | [diff] [blame] | 229 | if (chown(".", -1, getegid()) < 0) { |
| 230 | tst_brkm(TBROK|TERRNO, cleanup, |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 231 | "chown(\".\", -1, %d) failed", getegid()); |
yaberauneya | db37adc | 2009-11-09 05:56:58 +0000 | [diff] [blame] | 232 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 233 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 234 | sprintf(Fname, "accessfile"); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 235 | |
vapier | 6f55017 | 2009-08-28 10:46:41 +0000 | [diff] [blame] | 236 | fd = open(Fname, O_RDWR | O_CREAT, 06777); |
| 237 | if (fd == -1) |
| 238 | tst_brkm(TBROK|TERRNO, cleanup, |
| 239 | "open(%s, O_RDWR|O_CREAT, 06777) failed", Fname); |
| 240 | else if (close(fd) == -1) |
| 241 | tst_resm(TINFO|TERRNO, "close(%s) failed", Fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 242 | |
| 243 | /* |
| 244 | * force the mode to be set to 6777 |
| 245 | */ |
vapier | 6f55017 | 2009-08-28 10:46:41 +0000 | [diff] [blame] | 246 | if (chmod(Fname, 06777) == -1) |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 247 | tst_brkm(TBROK|TERRNO, cleanup, "chmod(%s, 06777) failed", |
| 248 | Fname); |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 249 | |
| 250 | stat(Fname, &stbuf); |
| 251 | |
| 252 | if ((stbuf.st_mode & 06777) != 06777) { |
| 253 | /* |
| 254 | * file can not be properly setup |
| 255 | */ |
| 256 | } |
| 257 | |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 258 | } |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 259 | |
| 260 | /*************************************************************** |
| 261 | * cleanup() - performs all ONE TIME cleanup for this test at |
| 262 | * completion or premature exit. |
| 263 | ***************************************************************/ |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 264 | void cleanup() |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 265 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 266 | /* |
| 267 | * print timing stats if that option was specified. |
| 268 | */ |
| 269 | TEST_CLEANUP; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 270 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 271 | tst_rmdir(); |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 272 | } |