@@ -508,6 +508,38 @@ void test_ocre_context_get_containers_ok(void)
508508 TEST_ASSERT_EQUAL_INT (0 , ocre_context_get_containers (context , containers , 2 ));
509509}
510510
511+ void test_ocre_context_create_container_detached_mode (void )
512+ {
513+ /* Create a valid detached container*/
514+
515+ struct ocre_container * detached_container =
516+ ocre_context_create_container (context , "hello-world.wasm" , "wamr/wasip1" , NULL , true, NULL );
517+ TEST_ASSERT_NOT_NULL (detached_container );
518+
519+ /* Create a valid non-detached container*/
520+
521+ struct ocre_container * non_detached_container =
522+ ocre_context_create_container (context , "hello-world.wasm" , "wamr/wasip1" , NULL , false, NULL );
523+ TEST_ASSERT_NOT_NULL (non_detached_container );
524+
525+ /* Check detached status */
526+
527+ TEST_ASSERT_TRUE (ocre_container_is_detached (detached_container ));
528+
529+ /* Check non-detached status */
530+
531+ TEST_ASSERT_FALSE (ocre_container_is_detached (non_detached_container ));
532+
533+ /* Check detached status from NULL should be false */
534+
535+ TEST_ASSERT_FALSE (ocre_container_is_detached (NULL ));
536+
537+ /* Remove the containers */
538+
539+ TEST_ASSERT_EQUAL_INT (0 , ocre_context_remove_container (context , detached_container ));
540+ TEST_ASSERT_EQUAL_INT (0 , ocre_context_remove_container (context , non_detached_container ));
541+ }
542+
511543int main (void )
512544{
513545 UNITY_BEGIN ();
@@ -523,6 +555,7 @@ int main(void)
523555 RUN_TEST (test_ocre_context_create_container_ok );
524556 RUN_TEST (test_ocre_context_create_container_null_runtime_ok );
525557 RUN_TEST (test_ocre_context_create_container_with_id_ok );
558+ RUN_TEST (test_ocre_context_create_container_detached_mode );
526559 RUN_TEST (test_ocre_context_create_container_with_id_twice );
527560 RUN_TEST (test_ocre_context_create_container_and_forget );
528561 RUN_TEST (test_ocre_context_create_wait_remove );
0 commit comments