summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorBruce Momjian2012-06-10 19:20:04 +0000
committerBruce Momjian2012-06-10 19:20:04 +0000
commit927d61eeff78363ea3938c818d07e511ebaf75cf (patch)
tree2f0bcecf53327f76272a8ce690fa62505520fab9 /src/test
parent60801944fa105252b48ea5688d47dfc05c695042 (diff)
Run pgindent on 9.2 source tree in preparation for first 9.3
commit-fest.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/isolation/isolationtester.c87
-rw-r--r--src/test/regress/pg_regress.c2
-rw-r--r--src/test/thread/thread_test.c17
3 files changed, 56 insertions, 50 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c
index 0e681639ba..98f89da6bf 100644
--- a/src/test/isolation/isolationtester.c
+++ b/src/test/isolation/isolationtester.c
@@ -18,7 +18,6 @@
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
-
#else
int getopt(int argc, char *const argv[], const char *optstring);
#endif /* ! WIN32 */
@@ -47,16 +46,16 @@ static int nconns = 0;
/* In dry run only output permutations to be run by the tester. */
static int dry_run = false;
-static void run_testspec(TestSpec *testspec);
+static void run_testspec(TestSpec * testspec);
static void run_all_permutations(TestSpec * testspec);
static void run_all_permutations_recurse(TestSpec * testspec, int nsteps,
Step ** steps);
static void run_named_permutations(TestSpec * testspec);
static void run_permutation(TestSpec * testspec, int nsteps, Step ** steps);
-#define STEP_NONBLOCK 0x1 /* return 0 as soon as cmd waits for a lock */
-#define STEP_RETRY 0x2 /* this is a retry of a previously-waiting cmd */
-static bool try_complete_step(Step *step, int flags);
+#define STEP_NONBLOCK 0x1 /* return 0 as soon as cmd waits for a lock */
+#define STEP_RETRY 0x2 /* this is a retry of a previously-waiting cmd */
+static bool try_complete_step(Step * step, int flags);
static int step_qsort_cmp(const void *a, const void *b);
static int step_bsearch_cmp(const void *a, const void *b);
@@ -82,7 +81,7 @@ main(int argc, char **argv)
int i;
PGresult *res;
PQExpBufferData wait_query;
- int opt;
+ int opt;
while ((opt = getopt(argc, argv, "n")) != -1)
{
@@ -99,8 +98,8 @@ main(int argc, char **argv)
/*
* If the user supplies a non-option parameter on the command line, use it
- * as the conninfo string; otherwise default to setting dbname=postgres and
- * using environment variables or defaults for all other connection
+ * as the conninfo string; otherwise default to setting dbname=postgres
+ * and using environment variables or defaults for all other connection
* parameters.
*/
if (argc > optind)
@@ -125,8 +124,8 @@ main(int argc, char **argv)
printf("Parsed test spec with %d sessions\n", testspec->nsessions);
/*
- * Establish connections to the database, one for each session and an extra
- * for lock wait detection and global work.
+ * Establish connections to the database, one for each session and an
+ * extra for lock wait detection and global work.
*/
nconns = 1 + testspec->nsessions;
conns = calloc(nconns, sizeof(PGconn *));
@@ -187,7 +186,7 @@ main(int argc, char **argv)
/*
* Build the query we'll use to detect lock contention among sessions in
- * the test specification. Most of the time, we could get away with
+ * the test specification. Most of the time, we could get away with
* simply checking whether a session is waiting for *any* lock: we don't
* exactly expect concurrent use of test tables. However, autovacuum will
* occasionally take AccessExclusiveLock to truncate a table, and we must
@@ -254,16 +253,16 @@ main(int argc, char **argv)
"'ExclusiveLock',"
"'AccessExclusiveLock'] END) "
- "AND holder.locktype IS NOT DISTINCT FROM waiter.locktype "
- "AND holder.database IS NOT DISTINCT FROM waiter.database "
- "AND holder.relation IS NOT DISTINCT FROM waiter.relation "
+ "AND holder.locktype IS NOT DISTINCT FROM waiter.locktype "
+ "AND holder.database IS NOT DISTINCT FROM waiter.database "
+ "AND holder.relation IS NOT DISTINCT FROM waiter.relation "
"AND holder.page IS NOT DISTINCT FROM waiter.page "
"AND holder.tuple IS NOT DISTINCT FROM waiter.tuple "
- "AND holder.virtualxid IS NOT DISTINCT FROM waiter.virtualxid "
- "AND holder.transactionid IS NOT DISTINCT FROM waiter.transactionid "
- "AND holder.classid IS NOT DISTINCT FROM waiter.classid "
+ "AND holder.virtualxid IS NOT DISTINCT FROM waiter.virtualxid "
+ "AND holder.transactionid IS NOT DISTINCT FROM waiter.transactionid "
+ "AND holder.classid IS NOT DISTINCT FROM waiter.classid "
"AND holder.objid IS NOT DISTINCT FROM waiter.objid "
- "AND holder.objsubid IS NOT DISTINCT FROM waiter.objsubid ");
+ "AND holder.objsubid IS NOT DISTINCT FROM waiter.objsubid ");
res = PQprepare(conns[0], PREP_WAITING, wait_query.data, 0, NULL);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
@@ -294,7 +293,7 @@ static int *piles;
* explicitly specified.
*/
static void
-run_testspec(TestSpec *testspec)
+run_testspec(TestSpec * testspec)
{
if (testspec->permutations)
run_named_permutations(testspec);
@@ -400,9 +399,10 @@ run_named_permutations(TestSpec * testspec)
/* Find all the named steps using the lookup table */
for (j = 0; j < p->nsteps; j++)
{
- Step **this = (Step **) bsearch(p->stepnames[j], allsteps,
- nallsteps, sizeof(Step *),
- &step_bsearch_cmp);
+ Step **this = (Step **) bsearch(p->stepnames[j], allsteps,
+ nallsteps, sizeof(Step *),
+ &step_bsearch_cmp);
+
if (this == NULL)
{
fprintf(stderr, "undefined step \"%s\" specified in permutation\n",
@@ -441,7 +441,7 @@ step_bsearch_cmp(const void *a, const void *b)
* If a step caused an error to be reported, print it out and clear it.
*/
static void
-report_error_message(Step *step)
+report_error_message(Step * step)
{
if (step->errormsg)
{
@@ -458,9 +458,9 @@ report_error_message(Step *step)
* one fails due to a timeout such as deadlock timeout.
*/
static void
-report_two_error_messages(Step *step1, Step *step2)
+report_two_error_messages(Step * step1, Step * step2)
{
- char *prefix;
+ char *prefix;
prefix = malloc(strlen(step1->name) + strlen(step2->name) + 2);
sprintf(prefix, "%s %s", step1->name, step2->name);
@@ -494,8 +494,8 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
Step *waiting = NULL;
/*
- * In dry run mode, just display the permutation in the same format used by
- * spec files, and return.
+ * In dry run mode, just display the permutation in the same format used
+ * by spec files, and return.
*/
if (dry_run)
{
@@ -547,21 +547,22 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
/* Perform steps */
for (i = 0; i < nsteps; i++)
{
- Step *step = steps[i];
- PGconn *conn = conns[1 + step->session];
+ Step *step = steps[i];
+ PGconn *conn = conns[1 + step->session];
if (waiting != NULL && step->session == waiting->session)
{
- PGcancel *cancel;
- PGresult *res;
- int j;
+ PGcancel *cancel;
+ PGresult *res;
+ int j;
/*
* This permutation is invalid: it can never happen in real life.
*
- * A session is blocked on an earlier step (waiting) and no further
- * steps from this session can run until it is unblocked, but it
- * can only be unblocked by running steps from other sessions.
+ * A session is blocked on an earlier step (waiting) and no
+ * further steps from this session can run until it is unblocked,
+ * but it can only be unblocked by running steps from other
+ * sessions.
*/
fprintf(stderr, "invalid permutation detected\n");
@@ -569,7 +570,7 @@ run_permutation(TestSpec * testspec, int nsteps, Step ** steps)
cancel = PQgetCancel(conn);
if (cancel != NULL)
{
- char buf[256];
+ char buf[256];
PQcancel(cancel, buf, sizeof(buf));
@@ -673,11 +674,11 @@ teardown:
/*
* Our caller already sent the query associated with this step. Wait for it
* to either complete or (if given the STEP_NONBLOCK flag) to block while
- * waiting for a lock. We assume that any lock wait will persist until we
+ * waiting for a lock. We assume that any lock wait will persist until we
* have executed additional steps in the permutation.
*
* When calling this function on behalf of a given step for a second or later
- * time, pass the STEP_RETRY flag. This only affects the messages printed.
+ * time, pass the STEP_RETRY flag. This only affects the messages printed.
*
* If the connection returns an error, the message is saved in step->errormsg.
* Caller should call report_error_message shortly after this, to have it
@@ -687,7 +688,7 @@ teardown:
* a lock, returns true. Otherwise, returns false.
*/
static bool
-try_complete_step(Step *step, int flags)
+try_complete_step(Step * step, int flags)
{
PGconn *conn = conns[1 + step->session];
fd_set read_set;
@@ -705,12 +706,12 @@ try_complete_step(Step *step, int flags)
timeout.tv_usec = 10000; /* Check for lock waits every 10ms. */
ret = select(sock + 1, &read_set, NULL, NULL, &timeout);
- if (ret < 0) /* error in select() */
+ if (ret < 0) /* error in select() */
{
fprintf(stderr, "select failed: %s\n", strerror(errno));
exit_nicely();
}
- else if (ret == 0) /* select() timeout: check for lock wait */
+ else if (ret == 0) /* select() timeout: check for lock wait */
{
int ntuples;
@@ -765,9 +766,9 @@ try_complete_step(Step *step, int flags)
}
/* Detail may contain xid values, so just show primary. */
step->errormsg = malloc(5 +
- strlen(PQresultErrorField(res, PG_DIAG_SEVERITY)) +
+ strlen(PQresultErrorField(res, PG_DIAG_SEVERITY)) +
strlen(PQresultErrorField(res,
- PG_DIAG_MESSAGE_PRIMARY)));
+ PG_DIAG_MESSAGE_PRIMARY)));
sprintf(step->errormsg, "%s: %s",
PQresultErrorField(res, PG_DIAG_SEVERITY),
PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY));
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 2931a73fdb..7d89318b27 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -475,7 +475,7 @@ convert_sourcefiles_in(char *source_subdir, char *dest_dir, char *dest_subdir, c
/* build the full actual paths to open */
snprintf(prefix, strlen(*name) - 6, "%s", *name);
snprintf(srcfile, MAXPGPATH, "%s/%s", indir, *name);
- snprintf(destfile, MAXPGPATH, "%s/%s/%s.%s", dest_dir, dest_subdir,
+ snprintf(destfile, MAXPGPATH, "%s/%s/%s.%s", dest_dir, dest_subdir,
prefix, suffix);
infile = fopen(srcfile, "r");
diff --git a/src/test/thread/thread_test.c b/src/test/thread/thread_test.c
index bb5b92f142..9041928f08 100644
--- a/src/test/thread/thread_test.c
+++ b/src/test/thread/thread_test.c
@@ -114,8 +114,10 @@ static bool platform_is_threadsafe = true;
int
main(int argc, char *argv[])
{
- pthread_t thread1, thread2;
+ pthread_t thread1,
+ thread2;
int rc;
+
#ifdef WIN32
WSADATA wsaData;
int err;
@@ -199,7 +201,7 @@ main(int argc, char *argv[])
#endif
/* close down threads */
-
+
pthread_mutex_unlock(&init_mutex); /* let children exit */
pthread_join(thread1, NULL); /* clean up children */
@@ -277,7 +279,7 @@ func_call_1(void)
#ifdef WIN32
HANDLE h1;
#else
- int fd;
+ int fd;
#endif
unlink(TEMP_FILENAME_1);
@@ -285,10 +287,11 @@ func_call_1(void)
/* Set errno = EEXIST */
/* create, then try to fail on exclusive create open */
+
/*
* It would be great to check errno here but if errno is not thread-safe
- * we might get a value from the other thread and mis-report the cause
- * of the failure.
+ * we might get a value from the other thread and mis-report the cause of
+ * the failure.
*/
#ifdef WIN32
if ((h1 = CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL)) ==
@@ -301,7 +304,7 @@ func_call_1(void)
TEMP_FILENAME_1);
exit(1);
}
-
+
#ifdef WIN32
if (CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL)
!= INVALID_HANDLE_VALUE)
@@ -346,6 +349,7 @@ func_call_1(void)
unlink(TEMP_FILENAME_1);
#ifndef HAVE_STRERROR_R
+
/*
* If strerror() uses sys_errlist, the pointer might change for different
* errno values, so we don't check to see if it varies within the thread.
@@ -428,6 +432,7 @@ func_call_2(void)
}
#ifndef HAVE_STRERROR_R
+
/*
* If strerror() uses sys_errlist, the pointer might change for different
* errno values, so we don't check to see if it varies within the thread.