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 44663A0C46; Wed, 18 Aug 2021 08:19:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F742411F7; Wed, 18 Aug 2021 08:18:16 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8DEFF410E7 for ; Wed, 18 Aug 2021 08:18:03 +0200 (CEST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 97D2E20C32C0; Tue, 17 Aug 2021 23:18:02 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 97D2E20C32C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1629267482; bh=o6V7/Jh84gGwBGvk7zCKaIERt7ErQj0hXmFcp6DqWeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnuITtWggYX34KbtrtQa9Z5/eLlFAscIdQ+KO8dhhIqoCsL8FTu3fhY0NzTt2jwZ4 wzAbH2JPRtw9vI+AvWLMaQTwV8gVZSWlaTehyyVRMgLBu+5X4yWXjw554yvvMKEZ94 5TzKPDpIs1VlCT7H6nS/BC35vqiW+jNHDkWiSBLA= From: Jie Zhou To: dev@dpdk.org Cc: dmitry.kozliuk@gmail.com, roretzla@microsoft.com, navasile@linux.microsoft.com, dmitrym@microsoft.com, pallavi.kadam@intel.com, talshn@nvidia.com, thomas@monjalon.net, aconole@redhat.com Date: Tue, 17 Aug 2021 23:17:53 -0700 Message-Id: <1629267476-901-11-git-send-email-jizh@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1629267476-901-1-git-send-email-jizh@linux.microsoft.com> References: <1629267476-901-1-git-send-email-jizh@linux.microsoft.com> Subject: [dpdk-dev] [PATCH v1 10/13] app/test: differentiate a strerror on different OS 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 Sender: "dev" From: Jie Zhou On Windows, strerror returns just "Unknown error" for errnum greater than MAX_ERRNO, while linux and freebsd returns "Unknown error ", which is the current expectation for errno_autotest. Differentiate the error string on Windows. Otherwise, currently errno_autotest has a "duplicate error code" failure. Signed-off-by: Jie Zhou --- app/test/test_errno.c | 12 +++++++++++- lib/eal/common/eal_common_errno.c | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/test/test_errno.c b/app/test/test_errno.c index 3ff0456a58..cca0518b37 100644 --- a/app/test/test_errno.c +++ b/app/test/test_errno.c @@ -18,13 +18,19 @@ test_errno(void) { const char *rte_retval; const char *libc_retval; + +#ifndef RTE_EXEC_ENV_WINDOWS #ifdef RTE_EXEC_ENV_FREEBSD /* BSD has a colon in the string, unlike linux */ const char unknown_code_result[] = "Unknown error: %d"; #else const char unknown_code_result[] = "Unknown error %d"; + char expected_libc_retval[sizeof(unknown_code_result) + 3]; +#endif +#else + /* Windows doesn't return error number for error greater than MAX_errno*/ + const char expected_libc_retval[] = "Unknown error"; #endif - char expected_libc_retval[sizeof(unknown_code_result)+3]; /* use a small selection of standard errors for testing */ int std_errs[] = {EAGAIN, EBADF, EACCES, EINTR, EINVAL}; @@ -54,11 +60,13 @@ test_errno(void) rte_retval, libc_retval); if (strcmp(rte_retval, libc_retval) == 0) return -1; +#ifndef RTE_EXEC_ENV_WINDOWS /* generate appropriate error string for unknown error number * and then check that this is what we got back. If not, we have * a duplicate error number that conflicts with errno.h */ snprintf(expected_libc_retval, sizeof(expected_libc_retval), unknown_code_result, rte_errs[i]); +#endif if ((strcmp(expected_libc_retval, libc_retval) != 0) && (strcmp("", libc_retval) != 0)){ printf("Error, duplicate error code %d\n", rte_errs[i]); @@ -69,8 +77,10 @@ test_errno(void) /* ensure that beyond RTE_MAX_ERRNO, we always get an unknown code */ rte_retval = rte_strerror(RTE_MAX_ERRNO + 1); libc_retval = strerror(RTE_MAX_ERRNO + 1); +#ifndef RTE_EXEC_ENV_WINDOWS snprintf(expected_libc_retval, sizeof(expected_libc_retval), unknown_code_result, RTE_MAX_ERRNO + 1); +#endif printf("rte_strerror: '%s', strerror: '%s'\n", rte_retval, libc_retval); if ((strcmp(rte_retval, libc_retval) != 0) || diff --git a/lib/eal/common/eal_common_errno.c b/lib/eal/common/eal_common_errno.c index f86802705a..4c4abb802e 100644 --- a/lib/eal/common/eal_common_errno.c +++ b/lib/eal/common/eal_common_errno.c @@ -37,7 +37,11 @@ rte_strerror(int errnum) /* since some implementations of strerror_r throw an error * themselves if errnum is too big, we handle that case here */ if (errnum >= RTE_MAX_ERRNO) +#ifdef RTE_EXEC_ENV_WINDOWS + snprintf(ret, RETVAL_SZ, "Unknown error%s", sep); +#else snprintf(ret, RETVAL_SZ, "Unknown error%s %d", sep, errnum); +#endif else switch (errnum){ case E_RTE_SECONDARY: -- 2.32.0.windows.2