From ae8c51996a086998145617eba1f3ac6deebfb165 Mon Sep 17 00:00:00 2001 From: Kwang Son Date: Sun, 1 Aug 2021 21:28:41 -0400 Subject: [PATCH] test: Remove test while loop While loop keep previous test context which contains allocated resource. This resource check only increase code not usability. Change-Id: I1f2bfdd17fd6305d313d98362c4549b82f214d62 Signed-off-by: Kwang Son --- .../inference/inference_test_suite.c | 105 ++++++--------------- 1 file changed, 30 insertions(+), 75 deletions(-) diff --git a/test/testsuites/machine_learning/inference/inference_test_suite.c b/test/testsuites/machine_learning/inference/inference_test_suite.c index 50b19eb..5053cea 100644 --- a/test/testsuites/machine_learning/inference/inference_test_suite.c +++ b/test/testsuites/machine_learning/inference/inference_test_suite.c @@ -3568,79 +3568,34 @@ int perform_pose_landmark_detection() int main() { - int sel_opt = 0; - - const char *names[] = { - "Image Classification", "Object Detection", - "Face Detection", "Facial Landmark Detection", - "Pose Landmark Detection", "Exit" - }; - int err = MEDIA_VISION_ERROR_NONE; - while (sel_opt == 0) { - sel_opt = show_menu_linear("Select Action:", names, ARRAY_SIZE(names)); - switch (sel_opt) { - case 1: { - err = perform_image_classification(); - if (err != MEDIA_VISION_ERROR_NONE) { - printf("Fail to perform image classification. ERROR[0x%x]\n", - err); - } - } break; - case 2: { - err = perform_object_detection(); - if (err != MEDIA_VISION_ERROR_NONE) { - printf("Fail to perform object detection. ERROR[0x%x]\n", err); - } - } break; - case 3: { - err = perform_face_detection(); - if (err != MEDIA_VISION_ERROR_NONE) { - printf("Fail to perform face detection. ERROR[0x%x]\n", err); - } - } break; - case 4: { - err = perform_facial_landmark_detection(); - if (err != MEDIA_VISION_ERROR_NONE) { - printf("Fail to perform facial landmark detection. ERROR[0x%x]\n", - err); - } - } break; - case 5: { - err = perform_pose_landmark_detection(); - if (err != MEDIA_VISION_ERROR_NONE) { - printf("Fail to perform pose landmark detection"); - } - } break; - case 6: { - printf("Exit"); - } break; - default: - printf("Invalid option"); - sel_opt = 0; - continue; - } - - int do_another = 0; - - sel_opt = 0; - while (sel_opt == 0) { - sel_opt = show_menu_yes_or_no("Another action?: "); - switch (sel_opt) { - case 1: - do_another = 1; - break; - case 2: - do_another = 0; - break; - default: - printf("Invalid option.\n"); - sel_opt = 0; - } - } - - sel_opt = (do_another == 1) ? 0 : 1; - } - - return 0; -} + const char *names[] = { "Image Classification", "Object Detection", + "Face Detection", "Facial Landmark Detection", + "Pose Landmark Detection" }; + + int sel_opt = show_menu_linear("Select Action:", names, ARRAY_SIZE(names)); + if (sel_opt <= 0 || sel_opt > ARRAY_SIZE(names)) { + printf("Invalid option"); + return -1; + } + switch (sel_opt) { + case 1: { + err = perform_image_classification(); + } break; + case 2: { + err = perform_object_detection(); + } break; + case 3: { + err = perform_face_detection(); + } break; + case 4: { + err = perform_facial_landmark_detection(); + } break; + case 5: { + err = perform_pose_landmark_detection(); + } break; + } + if (err != MEDIA_VISION_ERROR_NONE) + printf("Fail to perform task. ERROR[0x%x]\n", err); + return err; +} \ No newline at end of file -- 2.7.4