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 3434345845; Thu, 22 Aug 2024 12:41:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1FD5B42EA2; Thu, 22 Aug 2024 12:41:35 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by mails.dpdk.org (Postfix) with ESMTP id 1862342E9D for ; Thu, 22 Aug 2024 12:41:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724323294; x=1755859294; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DDPSEFkMMn4v4OBytaX+sA1qZ9Uds52X5gXGOoJX6ec=; b=iF7xrICRZcg9ZF7fMzTNTtEm4TwrOOHSKXbN9mTweI9nR66ICyJ+ktWz O82jbFSD6XaZEUKPt52lhmts5SaLqYMemUk0SrbA5Hngh1UAXtVCmzIzP 0t6LJ9wjd2t7DLVmddmMwfI6VzvTCu4QX+uPn2jVj7l1EsIIYMik/CO02 XT5JaJJJz0rXJy/0Lt9ru+cvTmole320qVu/Kox4BexJgXpRvIIusMb7i /AnXXkB+wnzQKQgcc3RjidSPVDbMAqalSzIeEONCGi3dgE3zb3HGs97Pb r+iY3oT1TSWDwz6Sc6MDSDNAx9Ew6dWk0i8GxQmgatiNE47CB18UYW2Fp w==; X-CSE-ConnectionGUID: 05wHX8cvQYuHBabLgl+t+w== X-CSE-MsgGUID: XgpGocRRTUWbky2aiBLwrg== X-IronPort-AV: E=McAfee;i="6700,10204,11171"; a="33881938" X-IronPort-AV: E=Sophos;i="6.10,166,1719903600"; d="scan'208";a="33881938" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2024 03:41:32 -0700 X-CSE-ConnectionGUID: waa/nzXFTrKhEIuTUJ/6VQ== X-CSE-MsgGUID: tvFxNT7nRIK6S/mqN6VSSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,166,1719903600"; d="scan'208";a="65601349" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.39]) by fmviesa003.fm.intel.com with ESMTP; 22 Aug 2024 03:41:32 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Subject: [PATCH v2] app/testpmd: show output of commands read from file Date: Thu, 22 Aug 2024 11:41:10 +0100 Message-ID: <20240822104109.116208-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822103604.113246-1-bruce.richardson@intel.com> References: <20240822103604.113246-1-bruce.richardson@intel.com> MIME-Version: 1.0 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 Testpmd supports the "--cmdline-file" parameter to read a set of initial commands from a file. However, the only indication that this has been done successfully on startup is a single-line message, no output from the commands is seen. To improve usability here, we can use cmdline_new rather than cmdline_file_new and have the output from the various commands sent to stdout, allowing the user to see better what is happening. Signed-off-by: Bruce Richardson --- v2: use STDOUT_FILENO in place of hard-coded "1" --- app/test-pmd/cmdline.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b7759e38a8..52e64430d9 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -13431,7 +13432,18 @@ cmdline_read_from_file(const char *filename) { struct cmdline *cl; - cl = cmdline_file_new(main_ctx, "testpmd> ", filename); + /* cmdline_file_new does not produce any output which is not ideal here. + * Much better to show output of the commands, so we open filename directly + * and then pass that to cmdline_new with stdout as the output path. + */ + int fd = open(filename, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "Failed to open file %s: %s\n", + filename, strerror(errno)); + return; + } + + cl = cmdline_new(main_ctx, "testpmd> ", fd, STDOUT_FILENO); if (cl == NULL) { fprintf(stderr, "Failed to create file based cmdline context: %s\n", -- 2.43.0