test_astlpc: Add test initialising the device before the bus owner

This is an invalid initialisation sequence, so ensure the device
start-up routine bails out if it detects that data in the control area
is invalid.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I9575bf6d34439212fe27cd56271c16f38d7b2faa
diff --git a/tests/test_astlpc.c b/tests/test_astlpc.c
index 65286d5..772ba26 100644
--- a/tests/test_astlpc.c
+++ b/tests/test_astlpc.c
@@ -350,6 +350,34 @@
 	network_destroy(&ctx);
 }
 
+static void astlpc_test_host_before_bmc(void)
+{
+	struct mctp_binding_astlpc_mmio mmio = { 0 };
+	struct mctp_binding_astlpc *astlpc;
+	uint8_t kcs[2] = { 0 };
+	struct mctp *mctp;
+	int rc;
+
+	mctp = mctp_init();
+	assert(mctp);
+
+	/* Inject KCS registers */
+	mmio.kcs = &kcs;
+
+	/* Initialise the binding */
+	astlpc = mctp_astlpc_init(MCTP_BINDING_ASTLPC_MODE_HOST, MCTP_BTU, NULL,
+				  &mctp_binding_astlpc_mmio_ops, &mmio);
+
+	/* Register the binding to trigger the start-up sequence */
+	rc = mctp_register_bus(mctp, &astlpc->binding, 8);
+
+	/* Start-up should fail as we haven't initialised the BMC */
+	assert(rc < 0);
+
+	mctp_astlpc_destroy(astlpc);
+	mctp_destroy(mctp);
+}
+
 static void astlpc_test_simple_init(void)
 {
 	struct astlpc_endpoint bmc, host;
@@ -400,6 +428,7 @@
 	void (*test)(void);
 } astlpc_tests[] = {
 	TEST_CASE(astlpc_test_simple_init),
+	TEST_CASE(astlpc_test_host_before_bmc),
 	TEST_CASE(astlpc_test_simple_message_bmc_to_host),
 	TEST_CASE(astlpc_test_simple_message_host_to_bmc),
 	TEST_CASE(astlpc_test_packetised_message_bmc_to_host),