diff --git a/src/testsuite/testsuite-binary.c b/src/testsuite/testsuite-binary.c
index 484716070ed491f01de192a47a77cc7d61941a44..450ff96f211108c8db23f0bdeda59a8f579eb094 100644
--- a/src/testsuite/testsuite-binary.c
+++ b/src/testsuite/testsuite-binary.c
@@ -43,9 +43,11 @@ void testsuite_binary_init(void)
 
 void testsuite_binary_deinit(void)
 {
-	if ( unlink_directory(testsuite_binary_tmp, TRUE) < 0 ) {
-		i_warning("failed to remove temporary directory '%s': %m.",
-			testsuite_binary_tmp);
+	const char *error;
+
+	if ( unlink_directory(testsuite_binary_tmp, UNLINK_DIRECTORY_FLAG_RMDIR, &error) < 0 ) {
+		i_warning("failed to remove temporary directory '%s': %s.",
+			testsuite_binary_tmp, error);
 	}
 
 	i_free(testsuite_binary_tmp);
diff --git a/src/testsuite/testsuite-common.c b/src/testsuite/testsuite-common.c
index 54be303b1a488e76c2a6a296470200f43f780dee..486c1703031649968ae09de521169a780121d1f4 100644
--- a/src/testsuite/testsuite-common.c
+++ b/src/testsuite/testsuite-common.c
@@ -261,9 +261,11 @@ static void testsuite_tmp_dir_init(void)
 
 static void testsuite_tmp_dir_deinit(void)
 {
-	if ( unlink_directory(testsuite_tmp_dir, TRUE) < 0 )
-		i_warning("failed to remove temporary directory '%s': %m.",
-			testsuite_tmp_dir);
+	const char *error;
+
+	if ( unlink_directory(testsuite_tmp_dir, UNLINK_DIRECTORY_FLAG_RMDIR, &error) < 0 )
+		i_warning("failed to remove temporary directory '%s': %s.",
+			testsuite_tmp_dir, error);
 
 	i_free(testsuite_tmp_dir);
 }
diff --git a/src/testsuite/testsuite-mailstore.c b/src/testsuite/testsuite-mailstore.c
index 91c16f14b47e19802f4cd4f44bc3127fa2ad5ba4..11e56102bb82eabb61706f58af6ed0dec26be67f 100644
--- a/src/testsuite/testsuite-mailstore.c
+++ b/src/testsuite/testsuite-mailstore.c
@@ -105,11 +105,13 @@ void testsuite_mailstore_init(void)
 
 void testsuite_mailstore_deinit(void)
 {
+	const char *error;
+
 	testsuite_mailstore_close();
 
-	if ( unlink_directory(testsuite_mailstore_location, TRUE) < 0 ) {
-		i_warning("failed to remove temporary directory '%s': %m.",
-			testsuite_mailstore_location);
+	if ( unlink_directory(testsuite_mailstore_location, UNLINK_DIRECTORY_FLAG_RMDIR, &error) < 0 ) {
+		i_warning("failed to remove temporary directory '%s': %s.",
+			testsuite_mailstore_location, error);
 	}
 
 	i_free(testsuite_mailstore_location);
diff --git a/src/testsuite/testsuite-smtp.c b/src/testsuite/testsuite-smtp.c
index b273135c5db5a321bd4d79b442945f110c2fd0de..ec61dd91d70df4ae75431b17f2be7927589d7fee 100644
--- a/src/testsuite/testsuite-smtp.c
+++ b/src/testsuite/testsuite-smtp.c
@@ -52,9 +52,11 @@ void testsuite_smtp_init(void)
 
 void testsuite_smtp_deinit(void)
 {
-	if ( unlink_directory(testsuite_smtp_tmp, TRUE) < 0 )
-		i_warning("failed to remove temporary directory '%s': %m.",
-			testsuite_smtp_tmp);
+	const char *error;
+
+	if ( unlink_directory(testsuite_smtp_tmp, UNLINK_DIRECTORY_FLAG_RMDIR, &error) < 0 )
+		i_warning("failed to remove temporary directory '%s': %s.",
+			testsuite_smtp_tmp, error);
 
 	pool_unref(&testsuite_smtp_pool);
 }