mirror of
https://github.com/postgres/postgres.git
synced 2026-05-28 04:35:45 -04:00
Update test_fsync to honor -f.
Backpatch to 8.0.X.
This commit is contained in:
parent
c7d40ff35f
commit
4bc4ce01a7
1 changed files with 18 additions and 19 deletions
|
|
@ -58,11 +58,10 @@ main(int argc, char *argv[])
|
|||
for (i = 0; i < WAL_FILE_SIZE; i++)
|
||||
strout[i] = 'a';
|
||||
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
write(tmpfile, strout, WAL_FILE_SIZE);
|
||||
fsync(tmpfile); /* fsync so later fsync's don't have to do
|
||||
* it */
|
||||
fsync(tmpfile); /* fsync so later fsync's don't have to do it */
|
||||
close(tmpfile);
|
||||
|
||||
printf("Simple write timing:\n");
|
||||
|
|
@ -70,7 +69,7 @@ main(int argc, char *argv[])
|
|||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
{
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
write(tmpfile, strout, 8192);
|
||||
close(tmpfile);
|
||||
|
|
@ -87,12 +86,12 @@ main(int argc, char *argv[])
|
|||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
{
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
write(tmpfile, strout, 8192);
|
||||
fsync(tmpfile);
|
||||
close(tmpfile);
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
/* do nothing but the open/close the tests are consistent. */
|
||||
close(tmpfile);
|
||||
|
|
@ -106,12 +105,12 @@ main(int argc, char *argv[])
|
|||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
{
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
write(tmpfile, strout, 8192);
|
||||
close(tmpfile);
|
||||
/* reopen file */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
fsync(tmpfile);
|
||||
close(tmpfile);
|
||||
|
|
@ -124,7 +123,7 @@ main(int argc, char *argv[])
|
|||
printf("\nCompare one o_sync write to two:\n");
|
||||
|
||||
/* 16k o_sync write */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -136,7 +135,7 @@ main(int argc, char *argv[])
|
|||
printf("\n");
|
||||
|
||||
/* 2*8k o_sync writes */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -154,7 +153,7 @@ main(int argc, char *argv[])
|
|||
|
||||
#ifdef OPEN_DATASYNC_FLAG
|
||||
/* open_dsync, write */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | O_DSYNC)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR | O_DSYNC)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -169,7 +168,7 @@ main(int argc, char *argv[])
|
|||
printf("\n");
|
||||
|
||||
/* open_fsync, write */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -182,7 +181,7 @@ main(int argc, char *argv[])
|
|||
|
||||
#ifdef HAVE_FDATASYNC
|
||||
/* write, fdatasync */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -200,7 +199,7 @@ main(int argc, char *argv[])
|
|||
printf("\n");
|
||||
|
||||
/* write, fsync, close */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -218,7 +217,7 @@ main(int argc, char *argv[])
|
|||
|
||||
#ifdef OPEN_DATASYNC_FLAG
|
||||
/* open_dsync, write */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | O_DSYNC)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR | O_DSYNC)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -236,7 +235,7 @@ main(int argc, char *argv[])
|
|||
printf("\n");
|
||||
|
||||
/* open_fsync, write */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -252,7 +251,7 @@ main(int argc, char *argv[])
|
|||
|
||||
#ifdef HAVE_FDATASYNC
|
||||
/* write, fdatasync */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -271,7 +270,7 @@ main(int argc, char *argv[])
|
|||
printf("\n");
|
||||
|
||||
/* write, fsync, close */
|
||||
if ((tmpfile = open(FSYNC_FILENAME, O_RDWR)) == -1)
|
||||
if ((tmpfile = open(filename, O_RDWR)) == -1)
|
||||
die("can't open /var/tmp/test_fsync.out");
|
||||
gettimeofday(&start_t, NULL);
|
||||
for (i = 0; i < loops; i++)
|
||||
|
|
@ -286,7 +285,7 @@ main(int argc, char *argv[])
|
|||
print_elapse(start_t, elapse_t);
|
||||
printf("\n");
|
||||
|
||||
unlink(FSYNC_FILENAME);
|
||||
unlink(filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue