diff --git a/Makefile.am b/Makefile.am
index e9b126a3e9a4335f9aff62d6807089e28f79ed1b..6ed02a6c3bac2a2869e5bc2acee2dd19743f99d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -156,6 +156,7 @@ CLEANFILES = \
 	stamp-srclinks \
 	$(nodist_pkgpython_PYTHON) \
 	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
+	$(HS_BUILT_TEST_HELPERS) \
 	.hpc/*.mix htools/*.tix \
 	doc/hs-lint.html
 
@@ -358,6 +359,8 @@ HS_BIN_ROLES = hbal hscan hspace hinfo
 
 HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools
 HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
+HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail
+
 # we don't add -Werror by default
 HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
 # extra flags that can be overriden on the command line
@@ -840,7 +843,7 @@ check_SCRIPTS =
 if WANT_HTOOLSTESTS
 nodist_TESTS += $(haskell_tests)
 dist_TESTS += htools/offline-test.sh
-check_SCRIPTS += htools/hpc-htools
+check_SCRIPTS += htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
 endif
 
 TESTS = $(dist_TESTS) $(nodist_TESTS)
@@ -1150,6 +1153,7 @@ daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
 daemons/ganeti-watcher: MODULE = ganeti.watcher
 scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
 tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
+$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/%,%,$@)
 
 $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
 	test -n "$(MODULE)" || { echo Missing module; exit 1; }
@@ -1178,6 +1182,17 @@ $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
 	} > $@
 	chmod u+x $@
 
+$(HS_BUILT_TEST_HELPERS): Makefile
+	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
+	set -e; \
+	{ echo '#!/bin/sh'; \
+	  echo '# This file is automatically generated, do not edit!'; \
+	  echo "# Edit Makefile.am instead."; \
+	  echo; \
+	  echo "HTOOLS=$(TESTROLE) exec ./htools/hpc-htools \"\$$@\""; \
+	} > $@
+	chmod u+x $@
+
 # We need to create symlinks because "make distcheck" will not install Python
 # files when building.
 stamp-srclinks: Makefile | $(all_dirfiles)
@@ -1237,7 +1252,7 @@ check-local: check-dirs $(BUILT_SOURCES)
 	done
 
 .PHONY: hs-check
-hs-check: htools/test htools/hpc-htools
+hs-check: htools/test htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
 	@rm -f test.tix
 	./htools/test
 	HBINARY="./htools/hpc-htools" ./htools/offline-test.sh