summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNithya Balachandran <nbalacha@redhat.com>2015-05-05 23:47:58 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-05-07 01:54:08 -0700
commita661f7f54cef34aa39894818568a2c1b462e8cbc (patch)
tree2243944fc8fc34f52895cce49909d2c679b4f833
parent2bd2ccf0fdd5390c1c07cb228048f93e5e516512 (diff)
tests: Spurious failure in fop-sanity.t
Modified the calls to open in fops-sanity.c to pass in the mode as well if flags includes O_CREAT (as per man page). The missing mode randomly caused T files to be created causing DHT to treat them as linkto files and fail the fop. Modified 2 other files where the mode was not being provided. Change-Id: I047573d43655b4957d0703f7df36238f7e729c1f BUG: 1218951 Signed-off-by: Nithya Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/10590 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
-rw-r--r--tests/basic/fops-sanity.c35
-rw-r--r--tests/bugs/fuse/bug-1126048.c2
-rw-r--r--tests/bugs/nfs/bug-1210338.c2
3 files changed, 21 insertions, 18 deletions
diff --git a/tests/basic/fops-sanity.c b/tests/basic/fops-sanity.c
index 4f35a46e219..1e2ccde6bd8 100644
--- a/tests/basic/fops-sanity.c
+++ b/tests/basic/fops-sanity.c
@@ -48,7 +48,9 @@ int link_based_fops (char *filename);
/* to test open syscall with open modes available. */
int test_open_modes (char *filename);
/* generic function which does open write and read. */
-int generic_open_read_write (char *filename, int flag);
+int generic_open_read_write (char *filename, int flag, mode_t mode);
+
+#define OPEN_MODE 0666
int
main (int argc, char *argv[])
@@ -131,7 +133,7 @@ fd_based_fops_1 (char *filename)
char wstr[50] = {0,};
char rstr[50] = {0,};
- fd = open (filename, O_RDWR|O_CREAT);
+ fd = open (filename, O_RDWR|O_CREAT, OPEN_MODE);
if (fd < 0) {
fprintf (stderr, "open failed : %s\n", strerror (errno));
return ret;
@@ -250,7 +252,7 @@ fd_based_fops_2 (char *filename)
char wstr[50] = {0,};
char rstr[50] = {0,};
- fd = open (filename, O_RDWR|O_CREAT);
+ fd = open (filename, O_RDWR|O_CREAT, OPEN_MODE);
if (fd < 0) {
fprintf (stderr, "open failed : %s\n", strerror (errno));
return ret;
@@ -524,7 +526,7 @@ dup_fd_based_fops (char *filename)
char wstr[50] = {0,};
char rstr[50] = {0,};
- fd = open (filename, O_RDWR|O_CREAT);
+ fd = open (filename, O_RDWR|O_CREAT, OPEN_MODE);
if (fd < 0) {
fprintf (stderr, "open failed : %s\n", strerror (errno));
return ret;
@@ -835,19 +837,19 @@ test_open_modes (char *filename)
int ret = -1;
int result = 0;
- ret = generic_open_read_write (filename, O_CREAT|O_WRONLY);
+ ret = generic_open_read_write (filename, O_CREAT|O_WRONLY, OPEN_MODE);
if (ret != 0) {
fprintf (stderr, "flag O_CREAT|O_WRONLY failed: \n");
result |= ret;
}
- ret = generic_open_read_write (filename, O_CREAT|O_RDWR);
+ ret = generic_open_read_write (filename, O_CREAT|O_RDWR, OPEN_MODE);
if (ret != 0) {
fprintf (stderr, "flag O_CREAT|O_RDWR failed\n");
result |= ret;
}
- ret = generic_open_read_write (filename, O_CREAT|O_RDONLY);
+ ret = generic_open_read_write (filename, O_CREAT|O_RDONLY, OPEN_MODE);
if (ret != 0) {
fprintf (stderr, "flag O_CREAT|O_RDONLY failed\n");
result |= ret;
@@ -855,7 +857,7 @@ test_open_modes (char *filename)
ret = creat (filename, 0644);
close (ret);
- ret = generic_open_read_write (filename, O_WRONLY);
+ ret = generic_open_read_write (filename, O_WRONLY, 0);
if (ret != 0) {
fprintf (stderr, "flag O_WRONLY failed\n");
result |= ret;
@@ -863,7 +865,7 @@ test_open_modes (char *filename)
ret = creat (filename, 0644);
close (ret);
- ret = generic_open_read_write (filename, O_RDWR);
+ ret = generic_open_read_write (filename, O_RDWR, 0);
if (0 != ret) {
fprintf (stderr, "flag O_RDWR failed\n");
result |= ret;
@@ -871,7 +873,7 @@ test_open_modes (char *filename)
ret = creat (filename, 0644);
close (ret);
- ret = generic_open_read_write (filename, O_RDONLY);
+ ret = generic_open_read_write (filename, O_RDONLY, 0);
if (0 != ret) {
fprintf (stderr, "flag O_RDONLY failed\n");
result |= ret;
@@ -879,7 +881,7 @@ test_open_modes (char *filename)
ret = creat (filename, 0644);
close (ret);
- ret = generic_open_read_write (filename, O_TRUNC|O_WRONLY);
+ ret = generic_open_read_write (filename, O_TRUNC|O_WRONLY, 0);
if (0 != ret) {
fprintf (stderr, "flag O_TRUNC|O_WRONLY failed\n");
result |= ret;
@@ -888,14 +890,15 @@ test_open_modes (char *filename)
#if 0 /* undefined behaviour, unable to reliably test */
ret = creat (filename, 0644);
close (ret);
- ret = generic_open_read_write (filename, O_TRUNC|O_RDONLY);
+ ret = generic_open_read_write (filename, O_TRUNC|O_RDONLY, 0);
if (0 != ret) {
fprintf (stderr, "flag O_TRUNC|O_RDONLY failed\n");
result |= ret;
}
#endif
- ret = generic_open_read_write (filename, O_CREAT|O_RDWR|O_SYNC);
+ ret = generic_open_read_write (filename, O_CREAT|O_RDWR|O_SYNC,
+ OPEN_MODE);
if (0 != ret) {
fprintf (stderr, "flag O_CREAT|O_RDWR|O_SYNC failed\n");
result |= ret;
@@ -903,7 +906,7 @@ test_open_modes (char *filename)
ret = creat (filename, 0644);
close (ret);
- ret = generic_open_read_write (filename, O_CREAT|O_EXCL);
+ ret = generic_open_read_write (filename, O_CREAT|O_EXCL, OPEN_MODE);
if (0 != ret) {
fprintf (stderr, "flag O_CREAT|O_EXCL failed\n");
result |= ret;
@@ -913,14 +916,14 @@ test_open_modes (char *filename)
}
int
-generic_open_read_write (char *filename, int flag)
+generic_open_read_write (char *filename, int flag, mode_t mode)
{
int fd = 0;
int ret = -1;
char wstring[50] = {0,};
char rstring[50] = {0,};
- fd = open (filename, flag);
+ fd = open (filename, flag, mode);
if (fd < 0) {
if (flag == (O_CREAT|O_EXCL) && errno == EEXIST) {
unlink (filename);
diff --git a/tests/bugs/fuse/bug-1126048.c b/tests/bugs/fuse/bug-1126048.c
index 5b9afafef0f..60329955258 100644
--- a/tests/bugs/fuse/bug-1126048.c
+++ b/tests/bugs/fuse/bug-1126048.c
@@ -19,7 +19,7 @@ main (int argc, char **argv)
char *cmd = argv[1];
printf ("cmd is: %s\n", cmd);
- fd = open("a.txt", O_CREAT|O_RDWR);
+ fd = open("a.txt", O_CREAT|O_RDWR, 0644);
if (fd < 0)
printf ("open failed: %s\n", strerror(errno));
diff --git a/tests/bugs/nfs/bug-1210338.c b/tests/bugs/nfs/bug-1210338.c
index 77f56eb9d0b..7a17b9d68ce 100644
--- a/tests/bugs/nfs/bug-1210338.c
+++ b/tests/bugs/nfs/bug-1210338.c
@@ -14,7 +14,7 @@ main (int argc, char *argv[])
int ret = -1;
int fd = -1;
- fd = open (argv[1], O_CREAT|O_EXCL);
+ fd = open (argv[1], O_CREAT|O_EXCL, 0644);
if (fd == -1) {
fprintf (stderr, "creation of the file %s failed (%s)\n", argv[1],