From nobody Wed Jan 26 23:12:04 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E62B8196CA98; Wed, 26 Jan 2022 23:12:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jkfch68qLz3hNX; Wed, 26 Jan 2022 23:12:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643238724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/IP0zHtWGkoSkpPRsx+Y198saNCeCoscPhi0GRg2eak=; b=wvM9mSBKv/9FT1qp+EmVqLTq2gsE92kmqRpIVcXw7uCoy00bkmad0so1u+JL9pSu2rlcXN 9m9AYG0oqJrITtF7iDpPeHoK2eeJpBzULqBKgEseAMsb6FDGo2k0Jy6FhDtgRYohPRdwfR Fqidn2HIEsWBhihEzCs9ac69O+LoEv4LCZBRUR4bh+pyHNk4T8H19uFyUcP039Qlr12KJ/ XJJ27pdrrT+Wt23ZDi9bu4LmtkTNnXaf+Xlynhjf48ulOVZPYe3ddJi9Gm5RHU6v7pAUfs dpF2zHUAmhbGJQsKgdlKGATxUg8AYyfkZ2l6JxQkZpbzrBFbArGmzBPyCwqlCg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B442132D8; Wed, 26 Jan 2022 23:12:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20QNC4IU017854; Wed, 26 Jan 2022 23:12:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20QNC4t9017851; Wed, 26 Jan 2022 23:12:04 GMT (envelope-from git) Date: Wed, 26 Jan 2022 23:12:04 GMT Message-Id: <202201262312.20QNC4t9017851@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Li-Wen Hsu Subject: git: 2c449a4c5a33 - main - Fix test of ses(4) when there is no SES device exists List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: lwhsu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2c449a4c5a338d2dd39a1949524e57c06ce7eff6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643238724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/IP0zHtWGkoSkpPRsx+Y198saNCeCoscPhi0GRg2eak=; b=Qrq6G/9teDAG+Ud8XyMHJiN/XL9+eNlAHdsnJEemcc/HzxRKJgWresC/0Yn64uYQjb+G4s huQqycpFKAUCHNDlboSFE0v/dPGx8cPqVeDfggAvzw9vlkv7eUt82UjcG8gnxnlXIaKRzp N1Q2ot4VaZzQkIRGEootlFmBjX28bkbS+iC90nO1i7AT0PoLp7O3eABdS+5O7eGMHSGwlz Ht6KDEfzBIZVRU/2w/Cmtn/kCDRxedqvGhRyUef+h8qDmoZTt9bwPybi5lIaZ8BKZpEV0x /LjhLw0pEhvmsif0Iq9BeDNB4n+CwyKW0ltmmGFTug6gnEuF8xSJgl0gYlireg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643238724; a=rsa-sha256; cv=none; b=L/HsnawJB8CaG4LZCQl0Nam22qRr/852sasFc6HJn6T4ycyQ4zBKjPzFcs0sulm0d547Ok kYq0f5S6Tsx6Qv5UzcLFnxroCjUgIueXEYk/UMBQVwd1R/9K5JQgohlP/Uj1o3CihvzU3K mnNAsF3YAGXAZOPHL7F174rFl2ogHCuWSbOwbf0knbn/ANQ8GiwuVm6lUi4eZU+qxibNFX 8oJxA4LLnfAv9YD+GUrPTT186VNrz9AP668174kBKjqS0Ll7WC6z4aKkCSXsc4ktWHDd56 gB2HWGxIxUSPbbGBPhKC5nxgtQB4WSRlVJledZ502XkhYYxOitWexsesxj4qnw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by lwhsu: URL: https://cgit.FreeBSD.org/src/commit/?id=2c449a4c5a338d2dd39a1949524e57c06ce7eff6 commit 2c449a4c5a338d2dd39a1949524e57c06ce7eff6 Author: Li-Wen Hsu AuthorDate: 2022-01-26 23:11:17 +0000 Commit: Li-Wen Hsu CommitDate: 2022-01-26 23:11:17 +0000 Fix test of ses(4) when there is no SES device exists glob(3) returns GLOB_NOMATCH if GLOB_NOCHECK or GLOB_NOMAGIC flag is not passed so ATF_REQUIRE_EQ(r, 0) will cause a precondition check failure if no /dev/ses* exists. Remove calling of atf_tc_skip() in ATF_TC_CLEANUP() because it would let the clean up procedure unfinish. While here, fix a set-but-not-used warning. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D34056 --- tests/sys/ses/common.h | 24 +++++++++++++++++------- tests/sys/ses/destructive.c | 17 ++++++++++++----- tests/sys/ses/nondestructive.c | 18 ++++++++++++++++++ 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/tests/sys/ses/common.h b/tests/sys/ses/common.h index c4a74bd8505f..0c6b139a6ab4 100644 --- a/tests/sys/ses/common.h +++ b/tests/sys/ses/common.h @@ -34,26 +34,36 @@ for_each_ses_dev(ses_cb cb, int oflags) glob_t g; int r; unsigned i; - bool tested = false; g.gl_pathc = 0; g.gl_pathv = NULL; g.gl_offs = 0; - r = glob("/dev/ses*", GLOB_NOSORT, NULL, &g); + r = glob("/dev/ses*", GLOB_NOCHECK | GLOB_NOSORT, NULL, &g); ATF_REQUIRE_EQ(r, 0); + if (g.gl_matchc == 0) + return; - for(i = 0; i < g.gl_pathc; i++) { + for(i = 0; i < g.gl_matchc; i++) { int fd; fd = open(g.gl_pathv[i], oflags); ATF_REQUIRE(fd >= 0); - tested |= cb(g.gl_pathv[i], fd); + cb(g.gl_pathv[i], fd); close(fd); } - if (!tested) - atf_tc_skip("No supported devices found"); - globfree(&g); } + +static bool +has_ses() +{ + glob_t g; + int r; + + r = glob("/dev/ses*", GLOB_NOCHECK | GLOB_NOSORT, NULL, &g); + ATF_REQUIRE_EQ(r, 0); + + return (g.gl_matchc != 0); +} diff --git a/tests/sys/ses/destructive.c b/tests/sys/ses/destructive.c index 307b272c447f..9b83009280cf 100644 --- a/tests/sys/ses/destructive.c +++ b/tests/sys/ses/destructive.c @@ -53,10 +53,10 @@ for_one_ses_dev(ses_cb cb) g.gl_pathv = NULL; g.gl_offs = 0; - r = glob("/dev/ses*", GLOB_NOSORT, NULL, &g); + r = glob("/dev/ses*", GLOB_NOCHECK | GLOB_NOSORT, NULL, &g); ATF_REQUIRE_EQ(r, 0); - if (g.gl_pathc == 0) - atf_tc_skip("No ses devices found"); + if (g.gl_matchc == 0) + return; fd = open(g.gl_pathv[0], O_RDWR); ATF_REQUIRE(fd >= 0); @@ -84,7 +84,6 @@ static bool do_setelmstat(const char *devname __unused, int fd) { for (elm_idx = 0; elm_idx < nobj; elm_idx++) { encioc_elm_status_t elmstat; struct ses_ctrl_dev_slot *cslot; - struct ses_status_dev_slot *sslot; if (last_elm_type != map[elm_idx].elm_type) { /* skip overall elements */ @@ -99,7 +98,6 @@ static bool do_setelmstat(const char *devname __unused, int fd) { ATF_REQUIRE_EQ(r, 0); cslot = (struct ses_ctrl_dev_slot*)&elmstat.cstat[0]; - sslot = (struct ses_status_dev_slot*)&elmstat.cstat[0]; ses_ctrl_common_set_select(&cslot->common, 1); ses_ctrl_dev_slot_set_rqst_ident(cslot, 1); @@ -203,10 +201,16 @@ ATF_TC_HEAD(setelmstat, tc) } ATF_TC_BODY(setelmstat, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); + for_one_ses_dev(do_setelmstat); } ATF_TC_CLEANUP(setelmstat, tc) { + if (!has_ses()) + return; + for_one_ses_dev(do_setelmstat_cleanup); } @@ -262,6 +266,9 @@ ATF_TC_HEAD(setencstat, tc) } ATF_TC_BODY(setencstat, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); + for_each_ses_dev(do_setencstat, O_RDWR); } ATF_TC_CLEANUP(setencstat, tc) diff --git a/tests/sys/ses/nondestructive.c b/tests/sys/ses/nondestructive.c index e52a38a97862..47c7e5067239 100644 --- a/tests/sys/ses/nondestructive.c +++ b/tests/sys/ses/nondestructive.c @@ -120,6 +120,8 @@ ATF_TC_HEAD(getelmdesc, tc) } ATF_TC_BODY(getelmdesc, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getelmdesc, O_RDONLY); } @@ -221,6 +223,8 @@ ATF_TC_HEAD(getelmdevnames, tc) } ATF_TC_BODY(getelmdevnames, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getelmdevnames, O_RDONLY); } @@ -311,6 +315,8 @@ ATF_TC_HEAD(getelmmap, tc) } ATF_TC_BODY(getelmmap, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getelmmap, O_RDONLY); } @@ -380,6 +386,8 @@ ATF_TC_HEAD(getelmstat, tc) } ATF_TC_BODY(getelmstat, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getelmstat, O_RDONLY); } @@ -428,6 +436,8 @@ ATF_TC_HEAD(getencid, tc) } ATF_TC_BODY(getencid, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getencid, O_RDONLY); } @@ -472,6 +482,8 @@ ATF_TC_HEAD(getencname, tc) } ATF_TC_BODY(getencname, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getencname, O_RDONLY); } @@ -513,6 +525,8 @@ ATF_TC_HEAD(getencstat, tc) } ATF_TC_BODY(getencstat, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getencstat, O_RDONLY); } @@ -559,6 +573,8 @@ ATF_TC_HEAD(getnelm, tc) } ATF_TC_BODY(getnelm, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); for_each_ses_dev(do_getnelm, O_RDONLY); } @@ -609,6 +625,8 @@ ATF_TC_HEAD(getstring, tc) } ATF_TC_BODY(getstring, tc) { + if (!has_ses()) + atf_tc_skip("No ses devices found"); atf_tc_expect_fail("Bug 258188 ENCIO_GETSTRING does not set the string's returned size"); for_each_ses_dev(do_getstring, O_RDWR); }