summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/perl/PostgresNode.pm29
-rw-r--r--src/test/perl/TestLib.pm14
-rw-r--r--src/test/regress/pg_regress.c35
3 files changed, 70 insertions, 8 deletions
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index fede1e601b9..afbdb6332bd 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -243,7 +243,13 @@ sub connstr
{
return "port=$pgport host=$pghost";
}
- return "port=$pgport host=$pghost dbname=$dbname";
+
+ # Escape properly the database string before using it, only
+ # single quotes and backslashes need to be treated this way.
+ $dbname =~ s#\\#\\\\#g;
+ $dbname =~ s#\'#\\\'#g;
+
+ return "port=$pgport host=$pghost dbname='$dbname'";
}
=pod
@@ -396,7 +402,8 @@ sub init
mkdir $self->backup_dir;
mkdir $self->archive_dir;
- TestLib::system_or_bail('initdb', '-D', $pgdata, '-A', 'trust', '-N');
+ TestLib::system_or_bail('initdb', '-D', $pgdata, '-A', 'trust', '-N',
+ @{ $params{extra} });
TestLib::system_or_bail($ENV{PG_REGRESS}, '--config-auth', $pgdata);
open my $conf, ">>$pgdata/postgresql.conf";
@@ -1300,6 +1307,24 @@ sub issues_sql_like
=pod
+=item $node->run_log(...)
+
+Runs a shell command like TestLib::run_log, but with PGPORT set so
+that the command will default to connecting to this PostgresNode.
+
+=cut
+
+sub run_log
+{
+ my $self = shift;
+
+ local $ENV{PGPORT} = $self->port;
+
+ TestLib::run_log(@_);
+}
+
+=pod
+
=back
=cut
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 51b533e08cd..31e7acd4dae 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -20,6 +20,7 @@ use SimpleTee;
use Test::More;
our @EXPORT = qw(
+ generate_ascii_string
slurp_dir
slurp_file
append_to_file
@@ -166,6 +167,19 @@ sub run_log
return IPC::Run::run(@_);
}
+# Generate a string made of the given range of ASCII characters
+sub generate_ascii_string
+{
+ my ($from_char, $to_char) = @_;
+ my $res;
+
+ for my $i ($from_char .. $to_char)
+ {
+ $res .= sprintf("%c", $i);
+ }
+ return $res;
+}
+
sub slurp_dir
{
my ($dir) = @_;
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 14c87c91abd..1154d4c300e 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -876,6 +876,29 @@ initialize_environment(void)
load_resultmap();
}
+pg_attribute_unused()
+static const char *
+fmtHba(const char *raw)
+{
+ static char *ret;
+ const char *rp;
+ char *wp;
+
+ wp = ret = realloc(ret, 3 + strlen(raw) * 2);
+
+ *wp++ = '"';
+ for (rp = raw; *rp; rp++)
+ {
+ if (*rp == '"')
+ *wp++ = '"';
+ *wp++ = *rp;
+ }
+ *wp++ = '"';
+ *wp++ = '\0';
+
+ return ret;
+}
+
#ifdef ENABLE_SSPI
/*
* Get account and domain/realm names for the current user. This is based on
@@ -1037,11 +1060,11 @@ config_sspi_auth(const char *pgdata)
* '#'. Windows forbids the double-quote character itself, so don't
* bother escaping embedded double-quote characters.
*/
- CW(fprintf(ident, "regress \"%s@%s\" \"%s\"\n",
- accountname, domainname, username) >= 0);
+ CW(fprintf(ident, "regress \"%s@%s\" %s\n",
+ accountname, domainname, fmtHba(username)) >= 0);
for (sl = extraroles; sl; sl = sl->next)
- CW(fprintf(ident, "regress \"%s@%s\" \"%s\"\n",
- accountname, domainname, sl->str) >= 0);
+ CW(fprintf(ident, "regress \"%s@%s\" %s\n",
+ accountname, domainname, fmtHba(sl->str)) >= 0);
CW(fclose(ident) == 0);
}
#endif
@@ -2064,7 +2087,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
* before we add the specified one.
*/
free_stringlist(&dblist);
- split_to_stringlist(optarg, ", ", &dblist);
+ split_to_stringlist(optarg, ",", &dblist);
break;
case 2:
debug = true;
@@ -2114,7 +2137,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
dlpath = pg_strdup(optarg);
break;
case 18:
- split_to_stringlist(optarg, ", ", &extraroles);
+ split_to_stringlist(optarg, ",", &extraroles);
break;
case 19:
add_stringlist_item(&temp_configs, optarg);