Add hftest macros to fail with a message.

Fail if secondary gets unexpected message.

Change-Id: I410e48b67e0dbe33daaf744c7408a99a031a78ac
diff --git a/test/hftest/inc/hftest.h b/test/hftest/inc/hftest.h
index 894d7f0..a1179fa 100644
--- a/test/hftest/inc/hftest.h
+++ b/test/hftest/inc/hftest.h
@@ -50,8 +50,8 @@
 #define ASSERT_GE(x, y) HFTEST_ASSERT_OP(x, y, >=, true)
 #define ASSERT_GT(x, y) HFTEST_ASSERT_OP(x, y, >, true)
 
-#define ASSERT_TRUE(x) ASSERT_EQ(x, true);
-#define ASSERT_FALSE(x) ASSERT_EQ(x, false);
+#define ASSERT_TRUE(x) ASSERT_EQ(x, true)
+#define ASSERT_FALSE(x) ASSERT_EQ(x, false)
 
 #define EXPECT_EQ(x, y) HFTEST_ASSERT_OP(x, y, ==, false)
 #define EXPECT_NE(x, y) HFTEST_ASSERT_OP(x, y, !=, false)
@@ -60,8 +60,11 @@
 #define EXPECT_GE(x, y) HFTEST_ASSERT_OP(x, y, >=, false)
 #define EXPECT_GT(x, y) HFTEST_ASSERT_OP(x, y, >, false)
 
-#define EXPECT_TRUE(x) EXPECT_EQ(x, true);
-#define EXPECT_FALSE(x) EXPECT_EQ(x, false);
+#define EXPECT_TRUE(x) EXPECT_EQ(x, true)
+#define EXPECT_FALSE(x) EXPECT_EQ(x, false)
+
+#define FAIL(message) HFTEST_FAIL(message, true)
+#define ADD_FAILURE(message) HFTEST_FAIL(message, false)
 
 /* Service utilities. */
 #define SERVICE_SELECT(vm_id, service, send_buffer) \
diff --git a/test/hftest/inc/hftest_impl.h b/test/hftest/inc/hftest_impl.h
index 7a7be34..3d4a44a 100644
--- a/test/hftest/inc/hftest_impl.h
+++ b/test/hftest/inc/hftest_impl.h
@@ -228,6 +228,17 @@
 		}                                                          \
 	} while (0)
 
+#define HFTEST_FAIL(message, fatal)                                        \
+	do {                                                               \
+		struct hftest_context *ctx = hftest_get_context();         \
+		++ctx->failures;                                           \
+		HFTEST_LOG_FAILURE();                                      \
+		dlog(HFTEST_LOG_PREFIX HFTEST_LOG_INDENT "%s\n", message); \
+		if (fatal) {                                               \
+			ctx->abort();                                      \
+		}                                                          \
+	} while (0)
+
 /**
  * Select the service to run in a service VM.
  */
diff --git a/test/vmapi/primary_with_secondaries/services/interruptible.c b/test/vmapi/primary_with_secondaries/services/interruptible.c
index e37689a..1eaa521 100644
--- a/test/vmapi/primary_with_secondaries/services/interruptible.c
+++ b/test/vmapi/primary_with_secondaries/services/interruptible.c
@@ -88,6 +88,7 @@
 		} else {
 			dlog("Got unexpected message from VM %d, size %d.\n",
 			     received_message.vm_id, received_message.size);
+			FAIL("Unexpected message");
 		}
 		hf_mailbox_clear();
 	}