Remove unused test service and add test using other.

Bug: 132420445
Change-Id: Icbf1905befede4cd6078df1a11b394526b4135ee
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index daf5227..7e88fdc 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -330,6 +330,43 @@
 }
 
 /**
+ * Check that memory that is donated can't be relinquished.
+ */
+TEST(memory_sharing, donate_relinquish)
+{
+	struct spci_value run_res;
+	struct mailbox_buffers mb = set_up_mailbox();
+	uint8_t *ptr = pages;
+	uint32_t msg_size;
+
+	SERVICE_SELECT(SERVICE_VM1, "spci_memory_donate_relinquish", mb.send);
+
+	/* Initialise the memory before giving it. */
+	memset_s(ptr, sizeof(pages), 'b', PAGE_SIZE);
+
+	struct spci_memory_region_constituent constituents[] = {
+		{.address = (uint64_t)pages, .page_count = 1},
+		{.address = (uint64_t)pages + PAGE_SIZE, .page_count = 2},
+	};
+
+	msg_size = spci_memory_donate_init(
+		mb.send, SERVICE_VM1, constituents, ARRAY_SIZE(constituents), 0,
+		SPCI_MEMORY_RW_X, SPCI_MEMORY_NORMAL_MEM,
+		SPCI_MEMORY_CACHE_WRITE_BACK, SPCI_MEMORY_OUTER_SHAREABLE);
+
+	EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM1, msg_size,
+				SPCI_MSG_SEND_LEGACY_MEMORY)
+			  .func,
+		  SPCI_SUCCESS_32);
+
+	/*
+	 * Let the service access the memory, and try and fail to relinquish it.
+	 */
+	run_res = spci_run(SERVICE_VM1, 0);
+	EXPECT_EQ(run_res.func, SPCI_YIELD_32);
+}
+
+/**
  * Memory given away can be given back.
  */
 TEST(memory_sharing, give_and_get_back)
diff --git a/test/vmapi/primary_with_secondaries/services/memory.c b/test/vmapi/primary_with_secondaries/services/memory.c
index 9015e8e..24d3cdd 100644
--- a/test/vmapi/primary_with_secondaries/services/memory.c
+++ b/test/vmapi/primary_with_secondaries/services/memory.c
@@ -64,50 +64,6 @@
 	}
 }
 
-TEST_SERVICE(memory_lend_relinquish_spci)
-{
-	/* Loop, giving memory back to the sender. */
-	for (;;) {
-		struct spci_value ret = spci_msg_wait();
-		uint8_t *ptr;
-		uint32_t msg_size;
-		size_t i;
-
-		EXPECT_EQ(ret.func, SPCI_MSG_SEND_32);
-		EXPECT_EQ(spci_msg_send_attributes(ret),
-			  SPCI_MSG_SEND_LEGACY_MEMORY);
-
-		void *recv_buf = SERVICE_RECV_BUFFER();
-		void *send_buf = SERVICE_SEND_BUFFER();
-		struct spci_memory_region *memory_region =
-			spci_get_memory_region(recv_buf);
-		struct spci_memory_region_constituent *constituents =
-			spci_memory_region_get_constituents(memory_region);
-
-		ptr = (uint8_t *)constituents[0].address;
-
-		/* Check that one has access to the shared region. */
-		for (i = 0; i < PAGE_SIZE; ++i) {
-			ptr[i]++;
-		}
-
-		/* Give the memory back and notify the sender. */
-		msg_size = spci_memory_relinquish_init(
-			send_buf, HF_PRIMARY_VM_ID, constituents,
-			memory_region->constituent_count, 0);
-		/* Relevant information read, RX mailbox can be cleared. */
-		spci_rx_release();
-		spci_msg_send(spci_msg_send_receiver(ret), HF_PRIMARY_VM_ID,
-			      msg_size, SPCI_MSG_SEND_LEGACY_MEMORY);
-
-		/*
-		 * Try and access the memory which will cause a fault unless the
-		 * memory has been shared back again.
-		 */
-		ptr[0] = 123;
-	}
-}
-
 TEST_SERVICE(give_memory_and_fault)
 {
 	void *send_buf = SERVICE_SEND_BUFFER();