tests/kernel/pipe/pipe_api: Remove mem_pool-related test cases

Remove test cases that exercise the deprecated mem_pool features of
the pipe utility.

Note that this leaves comparatively few cases left, we should probably
audit coverage after this merges and rewrite tests that aren't
interdependent.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
diff --git a/tests/kernel/pipe/pipe_api/src/main.c b/tests/kernel/pipe/pipe_api/src/main.c
index fd305e2..9ba6eae 100644
--- a/tests/kernel/pipe/pipe_api/src/main.c
+++ b/tests/kernel/pipe/pipe_api/src/main.c
@@ -25,12 +25,6 @@
 extern void test_pipe_alloc(void);
 extern void test_pipe_reader_wait(void);
 extern void test_pipe_block_writer_wait(void);
-#ifdef CONFIG_USERSPACE
-extern void test_pipe_user_thread2thread(void);
-extern void test_pipe_user_put_fail(void);
-extern void test_pipe_user_get_fail(void);
-extern void test_resource_pool_auto_free(void);
-#endif
 
 extern void test_pipe_avail_r_lt_w(void);
 extern void test_pipe_avail_w_lt_r(void);
@@ -43,7 +37,6 @@
 extern struct k_sem end_sema;
 extern struct k_stack tstack;
 extern struct k_thread tdata;
-extern struct k_mem_pool test_pool;
 
 #ifndef CONFIG_USERSPACE
 #define dummy_test(_name) \
@@ -55,7 +48,6 @@
 dummy_test(test_pipe_user_thread2thread);
 dummy_test(test_pipe_user_put_fail);
 dummy_test(test_pipe_user_get_fail);
-dummy_test(test_resource_pool_auto_free);
 #endif /* !CONFIG_USERSPACE */
 
 /*test case main entry*/
@@ -65,25 +57,16 @@
 			      &kpipe, &end_sema, &tdata, &tstack,
 			      &khalfpipe, &put_get_pipe);
 
-	z_thread_resource_pool_assign(k_current_get(), &test_pool);
-
 	ztest_test_suite(pipe_api,
 			 ztest_1cpu_unit_test(test_pipe_thread2thread),
 			 ztest_1cpu_user_unit_test(test_pipe_user_thread2thread),
 			 ztest_1cpu_user_unit_test(test_pipe_user_put_fail),
 			 ztest_user_unit_test(test_pipe_user_get_fail),
-			 ztest_unit_test(test_resource_pool_auto_free),
 			 ztest_1cpu_unit_test(test_pipe_put_fail),
 			 ztest_unit_test(test_pipe_get_fail),
-			 ztest_unit_test(test_pipe_block_put),
-			 ztest_1cpu_unit_test(test_pipe_block_put_sema),
-			 ztest_1cpu_unit_test(test_pipe_get_put),
-			 ztest_unit_test(test_half_pipe_block_put_sema),
 			 ztest_unit_test(test_half_pipe_get_put),
-			 ztest_unit_test(test_half_pipe_saturating_block_put),
 			 ztest_1cpu_unit_test(test_pipe_alloc),
 			 ztest_unit_test(test_pipe_reader_wait),
-			 ztest_1cpu_unit_test(test_pipe_block_writer_wait),
 			 ztest_unit_test(test_pipe_avail_r_lt_w),
 			 ztest_unit_test(test_pipe_avail_w_lt_r),
 			 ztest_unit_test(test_pipe_avail_r_eq_w_full),
diff --git a/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c b/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c
index f783447..1b6004d 100644
--- a/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c
+++ b/tests/kernel/pipe/pipe_api/src/test_pipe_contexts.c
@@ -10,7 +10,6 @@
 #define PIPE_LEN	(4 * 16)
 #define BYTES_TO_WRITE	16
 #define BYTES_TO_READ BYTES_TO_WRITE
-Z_MEM_POOL_DEFINE(mpool, BYTES_TO_WRITE, PIPE_LEN, 1, 4);
 
 static ZTEST_DMEM unsigned char __aligned(4) data[] =
 "abcd1234$%^&PIPEefgh5678!/?*EPIPijkl9012[]<>PEPImnop3456{}()IPEP";
@@ -31,17 +30,6 @@
 struct k_thread tdata2;
 K_SEM_DEFINE(end_sema, 0, 1);
 
-/* By design, only two blocks. We should never need more than that, one
- * to allocate the pipe object, one for its buffer. Both should be auto-
- * released when the thread exits
- */
-#ifdef CONFIG_64BIT
-#define SZ	256
-#else
-#define SZ	128
-#endif
-Z_MEM_POOL_DEFINE(test_pool, SZ, SZ, 4, 4);
-
 static void tpipe_put(struct k_pipe *ppipe, k_timeout_t timeout)
 {
 	size_t to_wt, wt_byte = 0;
@@ -56,25 +44,6 @@
 	}
 }
 
-static void tpipe_block_put(struct k_pipe *ppipe, struct k_sem *sema,
-			    k_timeout_t timeout)
-{
-	struct k_mem_block block;
-
-	for (int i = 0; i < PIPE_LEN; i += BYTES_TO_WRITE) {
-		/**TESTPOINT: pipe block put*/
-		zassert_equal(z_mem_pool_alloc(&mpool, &block, BYTES_TO_WRITE,
-					       timeout), 0, NULL);
-		memcpy(block.data, &data[i], BYTES_TO_WRITE);
-		k_pipe_block_put(ppipe, &block, BYTES_TO_WRITE, sema);
-		if (sema) {
-			k_sem_take(sema, K_FOREVER);
-			zassert_not_equal(memcmp(block.data, &data[i], BYTES_TO_WRITE), 0,
-					"block should be freed after k_pipe_block_put.");
-		}
-	}
-}
-
 static void tpipe_get(struct k_pipe *ppipe, k_timeout_t timeout)
 {
 	unsigned char rx_data[PIPE_LEN];
@@ -103,12 +72,6 @@
 	k_sem_give(&end_sema);
 }
 
-static void tThread_block_put(void *p1, void *p2, void *p3)
-{
-	tpipe_block_put((struct k_pipe *)p1, (struct k_sem *)p2, K_NO_WAIT);
-	k_sem_give(&end_sema);
-}
-
 static void tpipe_thread_thread(struct k_pipe *ppipe)
 {
 	/**TESTPOINT: thread-thread data passing via pipe*/
@@ -164,11 +127,6 @@
 	k_sem_give(&end_sema);
 }
 
-static void thread_for_block_put(void *p1, void *p2, void *p3)
-{
-	tpipe_block_put((struct k_pipe *)p1, (struct k_sem *)p2, K_FOREVER);
-}
-
 /**
  * @addtogroup kernel_pipe_tests
  * @{
@@ -248,125 +206,11 @@
 }
 #endif
 
-/**
- * @brief Test pipe put of blocks
- * @details Check if kernel support sending a kernel
- * memory block into a pipe.
- * - Using a sub thread to put blcok data to pipe
- * - Get the pipe data and verify it
- * @see k_pipe_block_put()
- */
-void test_pipe_block_put(void)
-{
-
-	/**TESTPOINT: test k_pipe_block_put without semaphore*/
-	k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
-				      tThread_block_put, &kpipe, NULL, NULL,
-				      K_PRIO_PREEMPT(0), 0, K_NO_WAIT);
-
-	k_sleep(K_MSEC(10));
-	tpipe_get(&kpipe, K_FOREVER);
-	k_sem_take(&end_sema, K_FOREVER);
-
-	k_thread_abort(tid);
-}
-
-/**
- * @brief Test pipe block put with semaphore
- *
- * @ingroup kernel_pipe_tests
- *
- * @details
- * Test Objective:
- * - Check if kernel support sending a kernel
- * memory block into a pipe.
- *
- * Testing techniques:
- * - function and block box testing,Interface testing,
- * Dynamic analysis and testing.
- *
- * Prerequisite Conditions:
- * - CONFIG_TEST_USERSPACE.
- *
- * Input Specifications:
- * - N/A
- *
- * Test Procedure:
- * -# Create a sub thread to put blcok data to pipe.
- * and check the return of k_mem_pool_alloc.
- * -# Check if the block be freed after pip put.
- * -# Get the pipe data and check if the data equals the
- * put data.
- *
- * Expected Test Result:
- * - Pipe can send a memory block into a pipe.
- *
- * Pass/Fail Criteria:
- * - Successful if check points in test procedure are all passed, otherwise failure.
- *
- * Assumptions and Constraints:
- * - N/A
- *
- * @see k_pipe_block_put()
- */
-void test_pipe_block_put_sema(void)
-{
-	struct k_sem sync_sema;
-
-	k_sem_init(&sync_sema, 0, 1);
-	/**TESTPOINT: test k_pipe_block_put with semaphore*/
-	k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
-				      tThread_block_put, &pipe, &sync_sema,
-				      NULL, K_PRIO_PREEMPT(0), 0, K_NO_WAIT);
-	k_sleep(K_MSEC(10));
-	tpipe_get(&pipe, K_FOREVER);
-	k_sem_take(&end_sema, K_FOREVER);
-
-	k_thread_abort(tid);
-}
-
-/**
- * @brief Test pipe get and put
- * @see k_pipe_put(), k_pipe_get()
- */
-void test_pipe_get_put(void)
-{
-	/**TESTPOINT: test API sequence: [get, put]*/
-	k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
-				      tThread_block_put, &kpipe, NULL, NULL,
-				      K_PRIO_PREEMPT(0), 0, K_NO_WAIT);
-
-	/*get will be executed previous to put*/
-	tpipe_get(&kpipe, K_FOREVER);
-	k_sem_take(&end_sema, K_FOREVER);
-
-	k_thread_abort(tid);
-}
-/**
- * @brief Test resource pool free
- * @see z_mem_pool_malloc()
- */
-#ifdef CONFIG_USERSPACE
-void test_resource_pool_auto_free(void)
-{
-	/* Pool has 2 blocks, both should succeed if kernel object and pipe
-	 * buffer are auto-freed when the allocating threads exit
-	 */
-	zassert_true(z_mem_pool_malloc(&test_pool, 64) != NULL, NULL);
-	zassert_true(z_mem_pool_malloc(&test_pool, 64) != NULL, NULL);
-}
-#endif
-
 static void tThread_half_pipe_put(void *p1, void *p2, void *p3)
 {
 	tpipe_put((struct k_pipe *)p1, K_FOREVER);
 }
 
-static void tThread_half_pipe_block_put(void *p1, void *p2, void *p3)
-{
-	tpipe_block_put((struct k_pipe *)p1, (struct k_sem *)p2, K_FOREVER);
-}
-
 /**
  * @brief Test get/put with smaller pipe buffer
  * @see k_pipe_put(), k_pipe_get()
@@ -386,66 +230,6 @@
 }
 
 /**
- * @brief Test get/put with saturating smaller pipe buffer
- * @see k_pipe_put(), k_pipe_get()
- */
-void test_half_pipe_saturating_block_put(void)
-{
-	int nb;
-	struct k_mem_block blocks[16];
-
-	/**TESTPOINT: thread-thread data passing via pipe*/
-	k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
-				      tThread_half_pipe_block_put, &khalfpipe,
-				      NULL, NULL, K_PRIO_PREEMPT(0), 0,
-				      K_NO_WAIT);
-
-	k_msleep(10);
-
-	/* Ensure half the mempool is still queued in the pipe */
-	for (nb = 0; nb < ARRAY_SIZE(blocks); nb++) {
-		if (z_mem_pool_alloc(&mpool, &blocks[nb],
-				     BYTES_TO_WRITE, K_NO_WAIT) != 0) {
-			break;
-		}
-	}
-
-	/* Must have allocated two blocks, and pool must be full */
-	zassert_true(nb >= 2 && nb < ARRAY_SIZE(blocks), NULL);
-
-	for (int i = 0; i < nb; i++) {
-		z_mem_pool_free(&blocks[i]);
-	}
-
-	tpipe_get(&khalfpipe, K_FOREVER);
-
-	/* clear the spawned thread avoid side effect */
-	k_thread_abort(tid);
-}
-
-/**
- * @brief Test pipe block put with semaphore and smaller pipe buffer
- * @see k_pipe_block_put()
- */
-void test_half_pipe_block_put_sema(void)
-{
-	struct k_sem sync_sema;
-
-	k_sem_init(&sync_sema, 0, 1);
-
-	/**TESTPOINT: test k_pipe_block_put with semaphore*/
-	k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
-				      tThread_half_pipe_block_put,
-				      &khalfpipe, &sync_sema, NULL,
-				      K_PRIO_PREEMPT(0), 0, K_NO_WAIT);
-
-	k_sleep(K_MSEC(10));
-	tpipe_get(&khalfpipe, K_FOREVER);
-
-	k_thread_abort(tid);
-}
-
-/**
  * @brief Test Initialization and buffer allocation of pipe,
  * with various parameters
  * @see k_pipe_alloc_init(), k_pipe_cleanup()
@@ -484,40 +268,5 @@
 }
 
 /**
- * @brief Test pending writer in pipe
- * @see k_pipe_block_put(), k_pipe_get()
- */
-void test_pipe_block_writer_wait(void)
-{
-	struct k_sem s_sema;
-	struct k_sem s_sema1;
-
-	const int main_low_prio = 10;
-
-	k_sem_init(&s_sema, 0, 1);
-	k_sem_init(&s_sema1, 0, 1);
-
-	int old_prio = k_thread_priority_get(k_current_get());
-
-	k_thread_priority_set(k_current_get(), main_low_prio);
-	/**TESTPOINT: test k_pipe_block_put with semaphore*/
-
-	k_tid_t tid = k_thread_create(&tdata, tstack, STACK_SIZE,
-					thread_for_block_put, &kpipe1, &s_sema,
-					NULL, K_PRIO_PREEMPT(main_low_prio - 1),
-					0, K_NO_WAIT);
-
-	k_tid_t tid1 = k_thread_create(&tdata1, tstack1, STACK_SIZE,
-					thread_for_block_put, &kpipe1, &s_sema1,
-					NULL, K_PRIO_PREEMPT(main_low_prio - 1),
-					0, K_NO_WAIT);
-
-	tpipe_get(&kpipe1, K_FOREVER);
-	k_thread_priority_set(k_current_get(), old_prio);
-	k_thread_abort(tid);
-	k_thread_abort(tid1);
-}
-
-/**
  * @}
  */