diff --git a/contrib/pg_freespacemap/Makefile b/contrib/pg_freespacemap/Makefile
index da40b80c7c..2d525a1284 100644
--- a/contrib/pg_freespacemap/Makefile
+++ b/contrib/pg_freespacemap/Makefile
@@ -10,6 +10,8 @@ DATA = pg_freespacemap--1.1.sql pg_freespacemap--1.1--1.2.sql \
 	pg_freespacemap--1.0--1.1.sql
 PGFILEDESC = "pg_freespacemap - monitoring of free space map"
 
+REGRESS = pg_freespacemap
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/pg_freespacemap/expected/pg_freespacemap.out b/contrib/pg_freespacemap/expected/pg_freespacemap.out
new file mode 100644
index 0000000000..fc975b9050
--- /dev/null
+++ b/contrib/pg_freespacemap/expected/pg_freespacemap.out
@@ -0,0 +1,36 @@
+CREATE EXTENSION pg_freespacemap;
+CREATE TABLE t1(c1 int);
+INSERT INTO t1 VALUES (generate_series(1, 1000));
+VACUUM t1;
+SELECT * FROM pg_freespace('t1');
+ blkno | avail 
+-------+-------
+     0 |     0
+     1 |     0
+     2 |     0
+     3 |     0
+     4 |  4704
+(5 rows)
+
+DELETE FROM t1 WHERE c1 <= 10;
+VACUUM t1;
+SELECT * FROM pg_freespace('t1');
+ blkno | avail 
+-------+-------
+     0 |   320
+     1 |     0
+     2 |     0
+     3 |     0
+     4 |  4704
+(5 rows)
+
+SELECT * FROM pg_freespace('t1', 0);
+ pg_freespace 
+--------------
+          320
+(1 row)
+
+SELECT * FROM pg_freespace('t1', -1);
+ERROR:  invalid block number
+SELECT * FROM pg_freespace('t1', 4294967295);
+ERROR:  invalid block number
diff --git a/contrib/pg_freespacemap/sql/pg_freespacemap.sql b/contrib/pg_freespacemap/sql/pg_freespacemap.sql
new file mode 100644
index 0000000000..cc175322cd
--- /dev/null
+++ b/contrib/pg_freespacemap/sql/pg_freespacemap.sql
@@ -0,0 +1,17 @@
+CREATE EXTENSION pg_freespacemap;
+
+CREATE TABLE t1(c1 int);
+
+INSERT INTO t1 VALUES (generate_series(1, 1000));
+VACUUM t1;
+
+SELECT * FROM pg_freespace('t1');
+
+DELETE FROM t1 WHERE c1 <= 10;
+VACUUM t1;
+
+SELECT * FROM pg_freespace('t1');
+SELECT * FROM pg_freespace('t1', 0);
+
+SELECT * FROM pg_freespace('t1', -1);
+SELECT * FROM pg_freespace('t1', 4294967295);
