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 92F4745648; Thu, 18 Jul 2024 21:11:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E2CBD42E52; Thu, 18 Jul 2024 21:11:02 +0200 (CEST) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mails.dpdk.org (Postfix) with ESMTP id 0F07F4029B for ; Thu, 18 Jul 2024 21:11:01 +0200 (CEST) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1fc65329979so7784715ad.0 for ; Thu, 18 Jul 2024 12:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1721329860; x=1721934660; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GpQkMWsnKGyoqaT6ChpakXYOG2TeGecvxGC5BtQIv5A=; b=tdJiNSWZ5p/vsTYacVAK4iLIpYL1vx1zGcy1Typr4gf/4YAuwv8PV6FKQ8ajicjS5X FK6TfFsdntrgtoZ364K8opsV2kd1yOwBVeoh14iR7Fti1KFZDMgnRCxGcxx6F1FbrtS8 b4caoa8vrfGz3jqGDwY4oOjbAdP7YeiGmTokwhF4F5i5616wKGp000eFBZ6loy1CAqmt QU55zaFU+l+r9NamkZVtzHTO85izEprrKq5mmJ4JONzhb5N/49UkBMp/4VmO8xGHq5Ba F/xeOg0PntGrAjGriCwEca9ckvC5S534SpjmkJlzzsM3Uq3oqxVsLmlj+JftST16A4G0 K1pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721329860; x=1721934660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GpQkMWsnKGyoqaT6ChpakXYOG2TeGecvxGC5BtQIv5A=; b=dyzzIEBHdS/40p86v1nXpuHeFCX2xUuPW82u2ywjiePTuFP2AtQFVL8X9dRRlLlCKm KepYm2IKqTIkrtAK0DoZPMpPtNoRTYXiEZ4bKniuMmYv9vfcfFfsG0t6GSnTH70skh3D mk7ZjXAHZ9n1RbxWCZf6o7uzxUsdv24jZ51nKUj/UoI5XSccJOhwdP3EB2xjnyJNc5FJ JOpkj/kKUj6Rk8yq5qQ6sg4l91Ne8b99QVPxtngL29m+XlsOd6NNnF5tzAI7nPaPJTVx 0Uh/OtL5Ld6WydF3VVQ+N17QKhywMbd+DwkuaJH2/tIP/t1wOSFFw+V+b6IzeEuAlsnt s3Fw== X-Gm-Message-State: AOJu0Yw/8IJFutM5BpwuEcv9E57ETZl+ReeXfB7eVXp8b4xiokPDGuPo /dY7qHcxFh5p9ao5quBA7U4Tg8ueLM6wJeOuVL1CQKry4J57evfhRzoGJA9VykgCheEAsgoyx24 /kvk= X-Google-Smtp-Source: AGHT+IFLxBI5/TQBi8EqXQZMio0Dlf9tlR9sncsv+y08WY0det/AUDtisYrIlhGYo+3wVwjBa6TmPA== X-Received: by 2002:a17:903:2451:b0:1fa:b7ea:9f0f with SMTP id d9443c01a7336-1fc4e154911mr62532515ad.7.1721329860112; Thu, 18 Jul 2024 12:11:00 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fc0bc384dfsm97244165ad.209.2024.07.18.12.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 12:10:59 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Tyler Retzlaff Subject: [PATCH 1/4] test: update alarm test Date: Thu, 18 Jul 2024 12:07:12 -0700 Message-ID: <20240718191049.84865-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718191049.84865-1-stephen@networkplumber.org> References: <20240718191049.84865-1-stephen@networkplumber.org> 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 This test should be using the TEST_ASSERT macros, and can be run as part of the fast test suite now. Signed-off-by: Stephen Hemminger --- app/test/test_alarm.c | 53 ++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/app/test/test_alarm.c b/app/test/test_alarm.c index 70e97a3109..4ba8aa1af2 100644 --- a/app/test/test_alarm.c +++ b/app/test/test_alarm.c @@ -10,7 +10,8 @@ #include "test.h" -#ifndef RTE_EXEC_ENV_WINDOWS +#define US_PER_SEC 1000000 + static volatile int flag; static void @@ -19,46 +20,32 @@ test_alarm_callback(void *cb_arg) flag = 1; printf("Callback setting flag - OK. [cb_arg = %p]\n", cb_arg); } -#endif static int test_alarm(void) { -#ifdef RTE_EXEC_ENV_FREEBSD - printf("The alarm API is not supported on FreeBSD\n"); - return 0; -#endif + int ret; + + ret = rte_eal_alarm_set(0, test_alarm_callback, NULL); + TEST_ASSERT_FAIL(ret, "should not be succeed with 0 us value"); + + ret = rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback, NULL); + TEST_ASSERT_FAIL(ret, "should not be succeed with (UINT64_MAX-1) us value"); + + ret = rte_eal_alarm_set(10, NULL, NULL); + TEST_ASSERT_FAIL(ret, "should not succeed with null callback parameter"); -#ifndef RTE_EXEC_ENV_WINDOWS - /* check if it will fail to set alarm with wrong us value */ - printf("check if it will fail to set alarm with wrong ms values\n"); - if (rte_eal_alarm_set(0, test_alarm_callback, - NULL) >= 0) { - printf("should not be successful with 0 us value\n"); - return -1; - } - if (rte_eal_alarm_set(UINT64_MAX - 1, test_alarm_callback, - NULL) >= 0) { - printf("should not be successful with (UINT64_MAX-1) us value\n"); - return -1; - } -#endif + ret = rte_eal_alarm_cancel(NULL, NULL); + TEST_ASSERT_FAIL(ret, "should not succeed to remove alarm with null callback parameter"); - /* check if it will fail to set alarm with null callback parameter */ - printf("check if it will fail to set alarm with null callback parameter\n"); - if (rte_eal_alarm_set(10 /* ms */, NULL, NULL) >= 0) { - printf("should not be successful to set alarm with null callback parameter\n"); - return -1; - } + ret = rte_eal_alarm_set(US_PER_SEC, test_alarm_callback, NULL); + TEST_ASSERT_SUCCESS(ret, "could not set an alarm"); - /* check if it will fail to remove alarm with null callback parameter */ - printf("check if it will fail to remove alarm with null callback parameter\n"); - if (rte_eal_alarm_cancel(NULL, NULL) == 0) { - printf("should not be successful to remove alarm with null callback parameter"); - return -1; - } + ret = rte_eal_alarm_cancel(test_alarm_callback, NULL); + /* return is the number of the alarm set (or 0 if none or -1 if error) */ + TEST_ASSERT(ret > 0, "could not cancel an alarm: %d", ret); return 0; } -REGISTER_TEST_COMMAND(alarm_autotest, test_alarm); +REGISTER_FAST_TEST(alarm_autotest, true, true, test_alarm); -- 2.43.0