Content-Length: 753568 | pFad | http://github.com/tonybelloni/postgres/commit/bc616703e8767d2a5d0312cdbf5dc3c6de2b86fe

42 Clean up pg_test_fsync commit. · tonybelloni/postgres@bc61670 · GitHub
Skip to content

Commit bc61670

Browse files
committed
Clean up pg_test_fsync commit.
Actually rename the program, rather than just claiming we did. Hook it into the build system. Get rid of useless dependency on libpq. Clean up #include list and messy whitespace.
1 parent 0cf3db2 commit bc61670

File tree

6 files changed

+45
-45
lines changed

6 files changed

+45
-45
lines changed

contrib/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SUBDIRS = \
3333
pg_freespacemap \
3434
pg_standby \
3535
pg_stat_statements \
36+
pg_test_fsync \
3637
pg_trgm \
3738
pg_upgrade \
3839
pg_upgrade_support \

contrib/README

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ adminpack -
3030

3131
auth_delay
3232
Add a short delay after a failed authentication attempt, to make
33-
brute-force attacks on database passwords a bit harder.
33+
brute-force attacks on database passwords a bit harder.
3434
by KaiGai Kohei <kaigai@ak.jp.nec.com>
3535

3636
auto_explain -
@@ -71,7 +71,7 @@ dict_xsyn -
7171

7272
earthdistance -
7373
Functions for computing distances between two points on Earth
74-
by Bruno Wolff III <bruno@wolff.to> and Hal Snyder <hal@vailsys.com>
74+
by Bruno Wolff III <bruno@wolff.to> and Hal Snyder <hal@vailsys.com>
7575

7676
fuzzystrmatch -
7777
Levenshtein, metaphone, and soundex fuzzy string matching
@@ -129,6 +129,10 @@ pg_stat_statements -
129129
Track statement execution times across a whole database cluster
130130
by Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>
131131

132+
pg_test_fsync -
133+
Test different wal_sync_method settings
134+
by Bruce Momjian <bruce@momjian.us>
135+
132136
pg_trgm -
133137
Functions for determining the similarity of text based on trigram
134138
matching.

contrib/pg_test_fsync/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/pg_test_fsync

contrib/pg_test_fsync/Makefile

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
#
2-
# Makefile for test_fsync
2+
# Makefile for pg_test_fsync
33
#
4-
# contrib/test_fsync/Makefile
4+
# contrib/pg_test_fsync/Makefile
55

6-
PGFILEDESC = "test_fsync - test various disk sync methods"
6+
PGFILEDESC = "pg_test_fsync - test various disk sync methods"
77
PGAPPICON = win32
88

9-
PROGRAM = test_fsync
10-
OBJS = test_fsync.o
11-
12-
PG_LIBS = $(libpq_pgport)
9+
PROGRAM = pg_test_fsync
10+
OBJS = pg_test_fsync.o
1311

1412
ifdef USE_PGXS
1513
PG_CONFIG = pg_config
1614
PGXS := $(shell $(PG_CONFIG) --pgxs)
1715
include $(PGXS)
1816
else
19-
subdir = contrib/test_fsync
17+
subdir = contrib/pg_test_fsync
2018
top_builddir = ../..
2119
include $(top_builddir)/src/Makefile.global
2220
include $(top_srcdir)/contrib/contrib-global.mk

contrib/pg_test_fsync/test_fsync.c contrib/pg_test_fsync/pg_test_fsync.c

+30-34
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
/*
2-
* test_fsync.c
2+
* pg_test_fsync.c
33
* tests all supported fsync() methods
44
*/
55

66
#include "postgres.h"
77

8+
#include <fcntl.h>
9+
#include <sys/stat.h>
10+
#include <sys/time.h>
11+
#include <time.h>
12+
#include <unistd.h>
13+
814
#include "getopt_long.h"
915
#include "access/xlog_internal.h"
1016
#include "access/xlog.h"
1117
#include "access/xlogdefs.h"
1218

13-
#include <sys/types.h>
14-
#include <sys/stat.h>
15-
#include <fcntl.h>
16-
#include <stdio.h>
17-
#include <stdlib.h>
18-
#include <time.h>
19-
#include <sys/time.h>
20-
#include <unistd.h>
21-
#include <string.h>
22-
2319

24-
/*
20+
/*
2521
* put the temp files in the local directory
26-
* unless the user specifies otherwise
22+
* unless the user specifies otherwise
2723
*/
28-
#define FSYNC_FILENAME "./test_fsync.out"
24+
#define FSYNC_FILENAME "./pg_test_fsync.out"
2925

3026
#define WRITE_SIZE (8 * 1024) /* 8k */
3127

@@ -54,23 +50,23 @@ int
5450
main(int argc, char *argv[])
5551
{
5652
handle_args(argc, argv);
57-
53+
5854
prepare_buf();
5955

6056
test_open();
61-
57+
6258
/* Test using 1 8k write */
6359
test_sync(1);
6460

6561
/* Test using 2 8k writes */
6662
test_sync(2);
67-
63+
6864
test_open_syncs();
6965

7066
test_file_descriptor_sync();
71-
67+
7268
test_non_sync();
73-
69+
7470
unlink(filename);
7571

7672
return 0;
@@ -92,12 +88,12 @@ handle_args(int argc, char *argv[])
9288
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ||
9389
strcmp(argv[1], "-?") == 0)
9490
{
95-
fprintf(stderr, "test_fsync [-f filename] [ops-per-test]\n");
91+
fprintf(stderr, "pg_test_fsync [-f filename] [ops-per-test]\n");
9692
exit(0);
9793
}
9894
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
9995
{
100-
fprintf(stderr,"test_fsync " PG_VERSION "\n");
96+
fprintf(stderr,"pg_test_fsync " PG_VERSION "\n");
10197
exit(0);
10298
}
10399
}
@@ -114,11 +110,11 @@ handle_args(int argc, char *argv[])
114110
case 'o':
115111
ops_per_test = atoi(optarg);
116112
break;
117-
113+
118114
default:
119115
fprintf(stderr,
120116
"Try \"%s --help\" for more information.\n",
121-
"test_fsync");
117+
"pg_test_fsync");
122118
exit(1);
123119
break;
124120
}
@@ -144,8 +140,8 @@ test_open(void)
144140
{
145141
int tmpfile;
146142

147-
/*
148-
* test if we can open the target file
143+
/*
144+
* test if we can open the target file
149145
*/
150146
if ((tmpfile = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) == -1)
151147
die("Cannot open output file.");
@@ -164,7 +160,7 @@ test_sync(int writes_per_op)
164160
{
165161
int tmpfile, ops, writes;
166162
bool fs_warning = false;
167-
163+
168164
if (writes_per_op == 1)
169165
printf("\nCompare file sync methods using one 8k write:\n");
170166
else
@@ -279,10 +275,10 @@ test_sync(int writes_per_op)
279275
gettimeofday(&stop_t, NULL);
280276
close(tmpfile);
281277
print_elapse(start_t, stop_t);
282-
278+
283279
/*
284280
* If fsync_writethrough is available, test as well
285-
*/
281+
*/
286282
#ifdef HAVE_FSYNC_WRITETHROUGH
287283
printf(LABEL_FORMAT, "fsync_writethrough");
288284
fflush(stdout);
@@ -422,7 +418,7 @@ test_open_sync(const char *msg, int writes_size)
422418
close(tmpfile);
423419
print_elapse(start_t, stop_t);
424420
}
425-
421+
426422
#else
427423
printf(NA_FORMAT, "open_sync", "n/a\n");
428424
#endif
@@ -444,8 +440,8 @@ test_file_descriptor_sync(void)
444440
printf("(If the times are similar, fsync() can sync data written\n");
445441
printf("on a different descriptor.)\n");
446442

447-
/*
448-
* first write, fsync and close, which is the
443+
/*
444+
* first write, fsync and close, which is the
449445
* normal behavior without multiple descriptors
450446
*/
451447
printf(LABEL_FORMAT, "write, fsync, close");
@@ -477,8 +473,8 @@ test_file_descriptor_sync(void)
477473
* This simulates processes fsyncing each other's
478474
* writes.
479475
*/
480-
printf(LABEL_FORMAT, "write, close, fsync");
481-
fflush(stdout);
476+
printf(LABEL_FORMAT, "write, close, fsync");
477+
fflush(stdout);
482478

483479
gettimeofday(&start_t, NULL);
484480
for (ops = 0; ops < ops_per_test; ops++)
@@ -525,7 +521,7 @@ test_non_sync(void)
525521
print_elapse(start_t, stop_t);
526522
}
527523

528-
/*
524+
/*
529525
* print out the writes per second for tests
530526
*/
531527
void

doc/src/sgml/pgtestfsync.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pg_test_fsync [options]
4040
This file should be in the same file system that the
4141
<filename>pg_xlog</> directory is or will be placed in.
4242
(<filename>pg_xlog</> contains the <acronym>WAL</> files.)
43-
The default is <filename>test_fsync.out</> in the current
43+
The default is <filename>pg_test_fsync.out</> in the current
4444
directory.
4545
</para>
4646
</listitem>

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/bc616703e8767d2a5d0312cdbf5dc3c6de2b86fe

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy