From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1A06CA0540; Fri, 9 Sep 2022 11:36:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46ECD42B75; Fri, 9 Sep 2022 11:35:52 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id E499E4003F for ; Fri, 9 Sep 2022 11:35:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662716149; x=1694252149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=meo/0pHiYWPh3MuMPnK0dfOYgBnhXJTnsuJS8dOq1pk=; b=JEuvBVzIdncbULqlZvEZxeYqHkZs5nAM8uxwFTYmXQdJf+jaPCdjEgZh mAUwn0tTaAzfmLv89xDKa+WZXT+QsCteCFpdOp4Bdn4USj/fUTk598/jC ECFmRntWl9nOcxYc/6Qi8qTluQgaIJKjhYZr9ZUqS7nA/GVbvdMJ5tIzl yRacg0PqIZuvWyIelFHhPYUi0DW41Ns3aO5vCajPDTed3ZQBMPcDxfgsa 49Ss1JpptKtSG8WSjSGgiFq38AsxRQX1dWcBQ0zTUTdfEKRKFgzngwUTV 1Qu0A8ISsl8UcDhRIhd4IUFd+uXJdzSUTevuSOBeAMas+ax1wZX6Fz/6y g==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="298241089" X-IronPort-AV: E=Sophos;i="5.93,302,1654585200"; d="scan'208";a="298241089" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2022 02:35:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,302,1654585200"; d="scan'208";a="740996353" Received: from silpixa00401385.ir.intel.com ([10.237.214.161]) by orsmga004.jf.intel.com with ESMTP; 09 Sep 2022 02:35:40 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Ciara Power , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH v3 02/13] test/telemetry_json: print success or failure per subtest Date: Fri, 9 Sep 2022 10:35:12 +0100 Message-Id: <20220909093523.471727-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220909093523.471727-1-bruce.richardson@intel.com> References: <20220623164245.561371-1-bruce.richardson@intel.com> <20220909093523.471727-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org rather than just printing out success or failure at the end of the test only, print out "OK" or "ERROR" for each individual test case within the overall test. As part of this, ensure each case returns 0 on success and any other value on failure. Signed-off-by: Bruce Richardson Acked-by: Ciara Power Acked-by: Morten Brørup --- app/test/test_telemetry_json.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/app/test/test_telemetry_json.c b/app/test/test_telemetry_json.c index 790181d316..748b7cfe5a 100644 --- a/app/test/test_telemetry_json.c +++ b/app/test/test_telemetry_json.c @@ -102,8 +102,10 @@ test_large_array_element(void) used = rte_tel_json_add_array_string(buf, sizeof(buf), used, str); printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected); + if (used != 0) + return -1; - return strlen(buf) != 0; + return strncmp(expected, buf, sizeof(buf)); } static int @@ -117,20 +119,33 @@ test_large_obj_element(void) used = rte_tel_json_add_obj_u64(buf, sizeof(buf), used, str, 0); printf("%s: buf = '%s', expected = '%s'\n", __func__, buf, expected); + if (used != 0) + return -1; - return strlen(buf) != 0; + return strncmp(expected, buf, sizeof(buf)); } +typedef int (*test_fn)(void); + static int test_telemetry_json(void) { - if (test_basic_array() < 0 || - test_basic_obj() < 0 || - test_overflow_array() < 0 || - test_overflow_obj() < 0 || - test_large_array_element() < 0 || - test_large_obj_element() < 0) - return -1; + unsigned int i; + test_fn fns[] = { + test_basic_array, + test_basic_obj, + test_overflow_array, + test_overflow_obj, + test_large_array_element, + test_large_obj_element, + }; + for (i = 0; i < RTE_DIM(fns); i++) + if (fns[i]() == 0) + printf("OK\n"); + else { + printf("ERROR\n"); + return -1; + } return 0; } -- 2.34.1