Changeset 223 for branches/samba-3.3.x/source/torture
- Timestamp:
- May 24, 2009, 7:51:24 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/torture/torture.c
r206 r223 4155 4155 return correct; 4156 4156 } 4157 4158 /* 4159 Test POSIX open /mkdir calls. 4160 */ 4161 static bool run_simple_posix_open_test(int dummy) 4162 { 4163 static struct cli_state *cli1; 4164 const char *fname = "\\posix.file"; 4165 const char *dname = "\\posix.dir"; 4166 uint16 major, minor; 4167 uint32 caplow, caphigh; 4168 int fnum1 = -1; 4169 bool correct = false; 4170 4171 printf("Starting simple POSIX open test\n"); 4172 4173 if (!torture_open_connection(&cli1, 0)) { 4174 return false; 4175 } 4176 4177 cli_sockopt(cli1, sockops); 4178 4179 if (!SERVER_HAS_UNIX_CIFS(cli1)) { 4180 printf("Server doesn't support UNIX CIFS extensions.\n"); 4181 return false; 4182 } 4183 4184 if (!cli_unix_extensions_version(cli1, &major, 4185 &minor, &caplow, &caphigh)) { 4186 printf("Server didn't return UNIX CIFS extensions.\n"); 4187 return false; 4188 } 4189 4190 if (!cli_set_unix_extensions_capabilities(cli1, 4191 major, minor, caplow, caphigh)) { 4192 printf("Server doesn't support setting UNIX CIFS extensions.\n"); 4193 return false; 4194 } 4195 4196 cli_setatr(cli1, fname, 0, 0); 4197 cli_posix_unlink(cli1, fname); 4198 cli_setatr(cli1, dname, 0, 0); 4199 cli_posix_rmdir(cli1, dname); 4200 4201 /* Create a directory. */ 4202 if (cli_posix_mkdir(cli1, dname, 0777) == -1) { 4203 printf("Server doesn't support setting UNIX CIFS extensions.\n"); 4204 goto out; 4205 } 4206 4207 fnum1 = cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600); 4208 if (fnum1 == -1) { 4209 printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1)); 4210 goto out; 4211 } 4212 4213 if (!cli_close(cli1, fnum1)) { 4214 printf("close failed (%s)\n", cli_errstr(cli1)); 4215 goto out; 4216 } 4217 4218 /* Now open the file again for read only. */ 4219 fnum1 = cli_posix_open(cli1, fname, O_RDONLY, 0); 4220 if (fnum1 == -1) { 4221 printf("POSIX open of %s failed (%s)\n", fname, cli_errstr(cli1)); 4222 goto out; 4223 } 4224 4225 /* Now unlink while open. */ 4226 if (!cli_posix_unlink(cli1, fname)) { 4227 printf("POSIX unlink of %s failed (%s)\n", fname, cli_errstr(cli1)); 4228 goto out; 4229 } 4230 4231 if (!cli_close(cli1, fnum1)) { 4232 printf("close(2) failed (%s)\n", cli_errstr(cli1)); 4233 goto out; 4234 } 4235 4236 /* Ensure the file has gone. */ 4237 fnum1 = cli_posix_open(cli1, fname, O_RDONLY, 0); 4238 if (fnum1 != -1) { 4239 printf("POSIX open of %s succeeded, should have been deleted.\n", fname); 4240 goto out; 4241 } 4242 4243 if (!cli_posix_rmdir(cli1, dname)) { 4244 printf("POSIX rmdir failed (%s)\n", cli_errstr(cli1)); 4245 goto out; 4246 } 4247 4248 printf("Simple POSIX open test passed\n"); 4249 correct = true; 4250 4251 out: 4252 4253 if (fnum1 != -1) { 4254 cli_close(cli1, fnum1); 4255 fnum1 = -1; 4256 } 4257 4258 cli_setatr(cli1, fname, 0, 0); 4259 cli_posix_unlink(cli1, fname); 4260 cli_setatr(cli1, dname, 0, 0); 4261 cli_posix_rmdir(cli1, dname); 4262 4263 if (!torture_close_connection(cli1)) { 4264 correct = false; 4265 } 4266 4267 return correct; 4268 } 4269 4157 4270 4158 4271 static uint32 open_attrs_table[] = { … … 5419 5532 {"RW3", run_readwritelarge, 0}, 5420 5533 {"OPEN", run_opentest, 0}, 5534 {"POSIX", run_simple_posix_open_test, 0}, 5421 5535 #if 1 5422 5536 {"OPENATTR", run_openattrtest, 0},
Note:
See TracChangeset
for help on using the changeset viewer.