diff --git a/src/bin/initdb/t/002_walsegsize.pl b/src/bin/initdb/t/002_walsegsize.pl
new file mode 100644
index 0000000..91cf3eb
--- /dev/null
+++ b/src/bin/initdb/t/002_walsegsize.pl
@@ -0,0 +1,94 @@
+# To test successful data directory creation with differnt wal-segsize values
+
+use strict;
+use warnings;
+use PostgresNode;
+use TestLib;
+use Test::More tests => 21;
+
+my $tempdir = TestLib::tempdir;
+my $xlogdir = "$tempdir/pgxlog";
+my $datadir = "$tempdir/data";
+
+program_help_ok('initdb');
+program_version_ok('initdb');
+program_options_handling_ok('initdb');
+
+command_fails([ 'initdb', '--wal-segsize', "1GB" ],
+	'--wal-segsize only accepts power 2 integer values between 1 and 1024');
+
+#wal-segsize=1GB
+my $node = get_new_node('main');
+$node->init(extra => [ '--wal-segsize=1024' ]);
+$node->start;
+
+my $result =
+ $node->safe_psql('postgres',"SHOW wal_segment_size");
+is($result,qq(1GB), 'wal_segment_size(1GB)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW min_wal_size");
+is($result,qq(5GB), 'min_wal_size(1GB)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW max_wal_size");
+is($result,qq(64GB), 'min_wal_size(1GB)');
+
+$node->stop;
+
+#wal-segsize=256MB
+$node = get_new_node('main');
+$node->init(extra => [ '--wal-segsize=256' ]);
+$node->start;
+
+$result =
+ $node->safe_psql('postgres',"SHOW wal_segment_size");
+is($result,qq(256MB), 'wal_segment_size(256MB)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW min_wal_size");
+is($result,qq(1280MB), 'min_wal_size(256MB)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW max_wal_size");
+is($result,qq(16GB), 'min_wal_size(256MB)');
+
+$node->stop;
+
+#wal-segsize=default
+$node = get_new_node('main');
+$node->init;
+$node->start;
+
+$result =
+ $node->safe_psql('postgres',"SHOW wal_segment_size");
+is($result,qq(16MB), 'wal_segment_size(DEF)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW min_wal_size");
+is($result,qq(80MB), 'min_wal_size(DEF)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW max_wal_size");
+is($result,qq(1GB), 'min_wal_size(DEF)');
+
+$node->stop;
+
+#wal-segsize=default
+$node = get_new_node('main');
+$node->init(extra => [ '--wal-segsize=4' ]);
+$node->start;
+
+$result =
+ $node->safe_psql('postgres',"SHOW wal_segment_size");
+is($result,qq(4MB), 'wal_segment_size(4MB)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW min_wal_size");
+is($result,qq(20MB), 'min_wal_size(4MB)');
+
+$result =
+ $node->safe_psql('postgres',"SHOW max_wal_size");
+is($result,qq(256MB), 'min_wal_size(4MB)');
+
+$node->stop;
