From patchwork Fri Oct 28 04:57:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13023073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 133A6C38A02 for ; Fri, 28 Oct 2022 05:06:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooHS0-0003o2-52; Fri, 28 Oct 2022 00:58:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooHRy-0003nf-5e for qemu-devel@nongnu.org; Fri, 28 Oct 2022 00:58:34 -0400 Received: from mx0a-0064b401.pphosted.com ([205.220.166.238]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooHRw-000295-BL for qemu-devel@nongnu.org; Fri, 28 Oct 2022 00:58:33 -0400 Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 29S4wVwv018028; Thu, 27 Oct 2022 21:58:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=PPS06212021; bh=pupwfqANM6SYjHJ+RxVx1vpyVHI+kjVmJpVUPBItn4I=; b=JXN8EqfMQzd5A3kX3TQi5hl4xkEudAWvMl1RHTZxde7K4xur6uzNCGwhQG79Kvi0yvKq b3+0P7cdhLZFXJR+GbVbrZXlErWWsO10U5Ln37tQ7RZHuujcpxbK28o5WyMNINpe+28H b35u0gx2ZemRCPKyDePN26qTXQkt2fp81q0dH9Cwj3DTndtX4140qQwadneHt+eIsXuB 0S3sMYr5xKirc9GNqDQ3zn4uWFrdeH5lOWvCHKkf6i57EqsvdNiWXWP7r/acWBv85t1b u0HUNo9e9YQ403CHRI2EjL9lS34J0/YbDT9pD4leWq/Wr8EVAUhHYQ2MvdBeasNMiIH6 Vg== Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3kfg3gs4ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Oct 2022 21:58:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iD/w7C+TUeYJM17UTzZhdNl6WNFXWw2jksO15Bprm7r8Q1WEVZmemPpvXEfzon+SDMWXifOfUeVk/OfcnEYeWNg+R00hwC2Y+uuN4WF7ytaV8iA1lM/Azj0Nba1xybGvxP0ABqBzMscukSrqc1QkaealLNnKIsNT8HLPNGMjGo/DR64axI+wxUpqgK5oGexUHA5QajJAHgGgtRKEsxZ9rbWUsF7mKiWNMFZswi1RyVtFdShlW2gzVLq5t+pm2boow/KfWELBbYQz2nqUCn+P2KKQQHiULbz8LqPBOjcCyepIkshQTQkXQMFrE8GZHI5kRmHsyVo+iNIgbH9A3qDS2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pupwfqANM6SYjHJ+RxVx1vpyVHI+kjVmJpVUPBItn4I=; b=SVASMpZ4oYX16qZKXczVTPtBIH1ZKWkzIjhbFLkLf7i4IAnhryhYXLfN4VJ1d8h+Q66MFb2dRGpY0jJFsptoUkxAlAsgzZDa6mM/57ib5aXmBsUYCxBiFdnuvp78taOXCN6CzqnjMoSfy6tPByWsKmgUf1aSPSWhIlWN24qgnjIxroVKgO+PjlBVIhKckjlVuscHuC1qUBoB/S03hudrJY69jshFUUW/zLbl94BS2OzHMNluGF3rDbniuFGpGnmGW6amiH7Hi45gtQNho/4trynK4hkk9jz1GW74LE0n+DRaasIt88F9krNGrzsfw8/jUtrNVSqQncTzu7FQc1qCDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from BL1PR11MB5351.namprd11.prod.outlook.com (2603:10b6:208:318::5) by MN2PR11MB4632.namprd11.prod.outlook.com (2603:10b6:208:24f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Fri, 28 Oct 2022 04:58:29 +0000 Received: from BL1PR11MB5351.namprd11.prod.outlook.com ([fe80::9a11:fa81:cdd8:b201]) by BL1PR11MB5351.namprd11.prod.outlook.com ([fe80::9a11:fa81:cdd8:b201%9]) with mapi id 15.20.5746.026; Fri, 28 Oct 2022 04:58:29 +0000 From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v6 09/11] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32 Date: Fri, 28 Oct 2022 12:57:34 +0800 Message-Id: <20221028045736.679903-10-bin.meng@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221028045736.679903-1-bin.meng@windriver.com> References: <20221028045736.679903-1-bin.meng@windriver.com> X-ClientProxiedBy: SL2PR04CA0009.apcprd04.prod.outlook.com (2603:1096:100:2d::21) To BL1PR11MB5351.namprd11.prod.outlook.com (2603:10b6:208:318::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL1PR11MB5351:EE_|MN2PR11MB4632:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bc926f4-1e5f-4b4c-1b67-08dab8a10df0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZzxpbHVuvG2baJRc1xwmGWYZY/749d1+4cuBQylEZYS3M5kp3jRUGGGaSN/agOMo7csF31SL0ohdNYWgZpCnu9fKDGh2iXyJ+YUnv5BAm2qrAzP/hxg2c8mjndHQ5qclXYT/4zfz7DD9FjCNoSLDQWFHljF0AnY9Y1nsjRKAU6TFo3P/y1EbbPXw2RRofcM07fR390TkJb3r4aObz3Ep0gNE5Qs/uWDYTsewKKlTirJXhIU1T5jMmI4czHt7+0CMvTVnq8fI+2XdbnojbJ4rPOPHEpdTmY1qcV64sI/AcjhjTXDu3zsuQi75TT9SEIcHQye2IDFtHsZLjcM1oDU0YF2ClGX/mjFKe1+dLfOFgcB5XAWHvTTGRkYIBOz9gclRE5hyy5qJlPPXiFxO6KA1ETLig+KxqdRxfGlLOsz2BWMX7yYoFhCq2dzwMvke9iWttMQ+JAamyfyEz3j+FzCV5J7DPXukxnuWikjGYFIuNRF1DK+7GROEWfZl7ShN+C6MyMCd50UJzaocyUIdQ1EWtcgx0KAtzthpplFTnhKM+sFu6EYty7VdcvCiWviYGvWq2Yr53FDnUJWTzkN4VGRBnlU3ziPfjc12vJsuvecDuqR6+x2rGjvcUcwhsDTAXEs4D+PgHEhHQ192SbXFLyKt6XXzmTu5UZ9LLLHjTwx1OlIynVvq3sV7FM+pSXcRC1he1zZCko4uvvRpc0ca86P1G+J1ICfQzOusNu238nXqS+9AhgglHoaIec+StBrheK5hw4KVzDiBKCbQN1FORnPTKA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL1PR11MB5351.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(376002)(39850400004)(346002)(366004)(396003)(451199015)(478600001)(26005)(6486002)(6506007)(36756003)(2906002)(83380400001)(52116002)(6666004)(86362001)(5660300002)(38100700002)(38350700002)(2616005)(316002)(186003)(1076003)(6512007)(66476007)(8676002)(54906003)(4326008)(6916009)(41300700001)(66946007)(66556008)(44832011)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?2IeMCefFr6tUdqrveSYArn7W0XCp?= =?utf-8?q?CM0O5iF1bGTOqBDz2OFjwGiWjVW0V64snzd0mLQ+WgtJhBBC8TI8sd7osNjuowWKQ?= =?utf-8?q?6DwN9+4JtkUJ/9lVdmHoQK+4xGtj1iN3sSC5Njs/R5S7F6MOcCRtBr9658WjVn5tO?= =?utf-8?q?I1g83qvgQKXWfICkoAvTgLyXKe9ns6rnX+ebC2tfqaSC1qp6ifRfLVw1jKv5z4kgV?= =?utf-8?q?o8AqWzPR72JUG3aPa4nY4PPeB0XXxZ6koBuwne7T1JlMmnOuhZUV8xlhuCdXZVnbZ?= =?utf-8?q?FoK1pTwoPkG4mN1QNbLylkiKBiJA40j0XslmvvK91b3+JOAv5tRN+Oa0YHbSJhw3a?= =?utf-8?q?kyZ/Ula9br2fhoD2bqVAoVVVQ7Rkl2YaynTgETA4KivsC34Qrccat2HUPw7eSWIu4?= =?utf-8?q?LE93NfbNydrrA10zkVU/Fz0tiPEWVyzlUPJRYJEtxzQa8FMmcI96okgR4P+FX+940?= =?utf-8?q?+Y5lLuAO9LsBV4DOC71nqbSeBuYoXu5hKzp9s+xAPuidOv5G24mTHbVjvW78X23r7?= =?utf-8?q?cz5RLsHJ/b/Fx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phxQDEtCsobSmDLCJNYBjRBBQXam5wh?= =?utf-8?q?MC2rvOnmrbthpsaYc95MCEfnPeGy7i/GgxgX8/jogLvA04Mpz8UmlxQGBe6myHlhL?= =?utf-8?q?/9PEuLZOBFjD?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bc926f4-1e5f-4b4c-1b67-08dab8a10df0 X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5351.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2022 04:58:29.1774 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nkfrn8S+5EY8dQqkh/ynNaOyM4PGW0hbAy91a50RpQrB3ZXHLy7KagL/B/z/9ZB0iZ8P7SfYmQdrsAjD5Ypq0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4632 X-Proofpoint-GUID: 23ABmq3cRudYVfdxBp8YTpqCif35qgsU X-Proofpoint-ORIG-GUID: 23ABmq3cRudYVfdxBp8YTpqCif35qgsU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-28_02,2022-10-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 spamscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2210280030 Received-SPF: pass client-ip=205.220.166.238; envelope-from=prvs=7300ee25fa=bin.meng@windriver.com; helo=mx0a-0064b401.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Some qtest cases don't get response from the QEMU executable under test in time on Windows. It turns out that the socket receive call got timeout before it receive the complete response. The timeout value is supposed to be set to 50 seconds via the setsockopt() call, but there is a difference among platforms. The timeout unit of blocking receive calls is measured in seconds on non-Windows platforms but milliseconds on Windows. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) tests/qtest/libqtest.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index e1e2d39a6e..2fbc3b88f3 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -36,13 +36,14 @@ #include "qapi/qmp/qstring.h" #define MAX_IRQ 256 -#define SOCKET_TIMEOUT 50 #ifndef _WIN32 +# define SOCKET_TIMEOUT 50 # define CMD_EXEC "exec " # define DEV_STDERR "/dev/fd/2" # define DEV_NULL "/dev/null" #else +# define SOCKET_TIMEOUT 50000 # define CMD_EXEC "" # define DEV_STDERR "2" # define DEV_NULL "nul" @@ -106,8 +107,16 @@ static int socket_accept(int sock) struct sockaddr_un addr; socklen_t addrlen; int ret; + /* + * timeout unit of blocking receive calls is different among platfoms. + * It's in seconds on non-Windows platforms but milliseconds on Windows. + */ +#ifndef _WIN32 struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT, .tv_usec = 0 }; +#else + DWORD timeout = SOCKET_TIMEOUT; +#endif if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout, sizeof(timeout))) {