From nobody Tue Jul 19 07:37:20 2022 X-Original-To: dev-commits-src-branches@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 4Ln9ds0TJJz4Wbgh; Tue, 19 Jul 2022 07:37:21 +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 4Ln9dr6ykrz3pm7; Tue, 19 Jul 2022 07:37:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658216241; 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=VOAx28xwUvPeCFsIJClkUX2iVgDsG0CmNCjv7qCsigE=; b=voOUasaEhoFIlD0748laL0CiucTBeZDwY217a84JouPPmbp41cOWy292cNeHIS7f4xfO1X uokaaTXweV4j16nViFZL6MWKX3CTg/A8WAOKDSbs7m9z1LWUZYaK5D2FjWq0x7t+nkOa8n NdIxZVqkMPvcDbg6ZKkH7AM6fIah/u7O2tQ9uR0R4D+YJ6NPJkBrxOZlP0TsSskCfdTMgX NpSrv/iHwyC6VJ0JVLIxjHfygG0oEqJpNwdRlIzoALTTk0cWAor30HoUYx8EJchBdnL3RJ /KF2i2nyoUdxO/+hn1JgV9jg1F8/tStVOQjIMelxXMxCVZDT+DJBjOH3WkPPQQ== 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 4Ln9dr62Tqz19Pd; Tue, 19 Jul 2022 07:37:20 +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 26J7bKf5021478; Tue, 19 Jul 2022 07:37:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26J7bKFs021477; Tue, 19 Jul 2022 07:37:20 GMT (envelope-from git) Date: Tue, 19 Jul 2022 07:37:20 GMT Message-Id: <202207190737.26J7bKFs021477@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 3a5e46a3bf53 - stable/13 - Remove PAGE_SIZE from the kcov tests List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3a5e46a3bf5308de0123655c5c4f7ab4cfaefdf2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658216241; 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=VOAx28xwUvPeCFsIJClkUX2iVgDsG0CmNCjv7qCsigE=; b=KhGTzdgpPvokWldbi9vjQzq7rKikxoUyfz9tQcTL++TYWsne11VXM+t2ypXXbYBgQ8pZWv ZwlzqNyj1/pQ7K/n162Znfi3ht0EEZ201+oeFajTlDqe55HkW2aHLwlK4TRvw2Y1dYpptq G13h83vb7Hp8X6r2obqAlvZqyjIk8VqszLe48+l9sf9m/ytiBMK8YBZmByG9YiDzZAX5fd 85MrA/1x7w70VDP0AFHhqOcAET/zFV08ZQA+s6PyeImVepNoIRA/8DApJKZiNe0buqWjup 85QInqW5bLoMvA0E6hvMk7mxfDg1/XdC8jbxf3yhwW4dHBBhSqkuvvQrVstuYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658216241; a=rsa-sha256; cv=none; b=yZQzsxsiRZJeqYocNGyJoESr8gK9e0DLale4HAfVvfSQ6JCYJj1Wf+lHyVND5h1TkREvkp QzkvESX0hp07377ojeSCQYyENmJONAxpSzZNbi5j6ZGiJKokSOb8l1TgiTVqvOOIB3LML9 TCW2hrlbBTbtnuQES24QxRFx/iVQcC2UEAjwgMPNgBOMq/q85yQ6q0UP65czeGvIrHu3Do /b0M/dcJ/V/OXI5kSy70oY0WYrrCnAM7Xkr9JiS7L/QgMIHFb3b8QJvlJEB+GtU/5pFcXH bAFevRafGHD2kieBfns2Sufow2OHbiHgYOjDT6LMCgjeVsBHf5B+ZBEzwqF5HQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=3a5e46a3bf5308de0123655c5c4f7ab4cfaefdf2 commit 3a5e46a3bf5308de0123655c5c4f7ab4cfaefdf2 Author: Andrew Turner AuthorDate: 2022-04-20 17:33:00 +0000 Commit: Andrew Turner CommitDate: 2022-07-19 07:03:30 +0000 Remove PAGE_SIZE from the kcov tests To allow for a dynamic page size on arm64 remove the static valud from the kcov tests Sponsored by: The FreeBSD Foundation (cherry picked from commit 2ff6e4ee9762526ed1e924da838a760423271978) --- tests/sys/kern/kcov.c | 139 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 106 insertions(+), 33 deletions(-) diff --git a/tests/sys/kern/kcov.c b/tests/sys/kern/kcov.c index 0a59ddbeff73..64f75b8902ef 100644 --- a/tests/sys/kern/kcov.c +++ b/tests/sys/kern/kcov.c @@ -50,6 +50,14 @@ static const char *modes[] = { "comparison tracing", }; +static size_t page_size; + +static void +init_page_size(void) +{ + page_size = getpagesize(); +} + static int open_kcov(void) { @@ -62,7 +70,12 @@ open_kcov(void) return (fd); } -ATF_TC_WITHOUT_HEAD(kcov_bufsize); +ATF_TC(kcov_bufsize); +ATF_TC_HEAD(kcov_bufsize, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_bufsize, tc) { int fd; @@ -77,7 +90,12 @@ ATF_TC_BODY(kcov_bufsize, tc) close(fd); } -ATF_TC_WITHOUT_HEAD(kcov_mmap); +ATF_TC(kcov_mmap); +ATF_TC_HEAD(kcov_mmap, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_mmap, tc) { void *data1, *data2; @@ -85,19 +103,19 @@ ATF_TC_BODY(kcov_mmap, tc) fd = open_kcov(); - ATF_CHECK(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + ATF_CHECK(mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0) == MAP_FAILED); ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, - 2 * PAGE_SIZE / KCOV_ENTRY_SIZE) == 0); + 2 * page_size / KCOV_ENTRY_SIZE) == 0); - ATF_CHECK(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + ATF_CHECK(mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0) == MAP_FAILED); - ATF_CHECK(mmap(NULL, 3 * PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + ATF_CHECK(mmap(NULL, 3 * page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0) == MAP_FAILED); - ATF_REQUIRE((data1 = mmap(NULL, 2 * PAGE_SIZE, PROT_READ | PROT_WRITE, + ATF_REQUIRE((data1 = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) != MAP_FAILED); - ATF_REQUIRE((data2 = mmap(NULL, 2 * PAGE_SIZE, PROT_READ | PROT_WRITE, + ATF_REQUIRE((data2 = mmap(NULL, 2 * page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) != MAP_FAILED); *(uint64_t *)data1 = 0x123456789abcdeful; @@ -105,38 +123,48 @@ ATF_TC_BODY(kcov_mmap, tc) *(uint64_t *)data2 = 0xfedcba9876543210ul; ATF_REQUIRE(*(uint64_t *)data1 == 0xfedcba9876543210ull); - munmap(data1, 2 * PAGE_SIZE); - munmap(data2, 2 * PAGE_SIZE); + munmap(data1, 2 * page_size); + munmap(data2, 2 * page_size); close(fd); } /* This shouldn't panic */ -ATF_TC_WITHOUT_HEAD(kcov_mmap_no_munmap); +ATF_TC(kcov_mmap_no_munmap); +ATF_TC_HEAD(kcov_mmap_no_munmap, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_mmap_no_munmap, tc) { int fd; fd = open_kcov(); - ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, PAGE_SIZE / KCOV_ENTRY_SIZE) == 0); + ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, page_size / KCOV_ENTRY_SIZE) == 0); - ATF_CHECK(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + ATF_CHECK(mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0) != MAP_FAILED); close(fd); } -ATF_TC_WITHOUT_HEAD(kcov_mmap_no_munmap_no_close); +ATF_TC(kcov_mmap_no_munmap_no_close); +ATF_TC_HEAD(kcov_mmap_no_munmap_no_close, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_mmap_no_munmap_no_close, tc) { int fd; fd = open_kcov(); - ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, PAGE_SIZE / KCOV_ENTRY_SIZE) == 0); + ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, page_size / KCOV_ENTRY_SIZE) == 0); - ATF_CHECK(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + ATF_CHECK(mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0) != MAP_FAILED); } @@ -150,8 +178,8 @@ kcov_mmap_enable_thread(void *data) fd = open_kcov(); *(int *)data = fd; - ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, PAGE_SIZE / KCOV_ENTRY_SIZE) == 0); - ATF_CHECK(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, page_size / KCOV_ENTRY_SIZE) == 0); + ATF_CHECK(mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0) != MAP_FAILED); ATF_CHECK(ioctl(fd, KIOENABLE, KCOV_MODE_TRACE_PC) == 0); @@ -161,7 +189,12 @@ kcov_mmap_enable_thread(void *data) return (NULL); } -ATF_TC_WITHOUT_HEAD(kcov_mmap_enable_thread_close); +ATF_TC(kcov_mmap_enable_thread_close); +ATF_TC_HEAD(kcov_mmap_enable_thread_close, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_mmap_enable_thread_close, tc) { pthread_t thread; @@ -177,7 +210,12 @@ ATF_TC_BODY(kcov_mmap_enable_thread_close, tc) pthread_join(thread, NULL); } -ATF_TC_WITHOUT_HEAD(kcov_enable); +ATF_TC(kcov_enable); +ATF_TC_HEAD(kcov_enable, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_enable, tc) { int fd; @@ -186,7 +224,7 @@ ATF_TC_BODY(kcov_enable, tc) ATF_CHECK(ioctl(fd, KIOENABLE, KCOV_MODE_TRACE_PC) == -1); - ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, PAGE_SIZE / KCOV_ENTRY_SIZE) == 0); + ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, page_size / KCOV_ENTRY_SIZE) == 0); /* We need to enable before disable */ ATF_CHECK(ioctl(fd, KIODISABLE, 0) == -1); @@ -208,24 +246,34 @@ ATF_TC_BODY(kcov_enable, tc) close(fd); } -ATF_TC_WITHOUT_HEAD(kcov_enable_no_disable); +ATF_TC(kcov_enable_no_disable); +ATF_TC_HEAD(kcov_enable_no_disable, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_enable_no_disable, tc) { int fd; fd = open_kcov(); - ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, PAGE_SIZE / KCOV_ENTRY_SIZE) == 0); + ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, page_size / KCOV_ENTRY_SIZE) == 0); ATF_CHECK(ioctl(fd, KIOENABLE, KCOV_MODE_TRACE_PC) == 0); close(fd); } -ATF_TC_WITHOUT_HEAD(kcov_enable_no_disable_no_close); +ATF_TC(kcov_enable_no_disable_no_close); +ATF_TC_HEAD(kcov_enable_no_disable_no_close, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_enable_no_disable_no_close, tc) { int fd; fd = open_kcov(); - ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, PAGE_SIZE / KCOV_ENTRY_SIZE) == 0); + ATF_REQUIRE(ioctl(fd, KIOSETBUFSIZE, page_size / KCOV_ENTRY_SIZE) == 0); ATF_CHECK(ioctl(fd, KIOENABLE, KCOV_MODE_TRACE_PC) == 0); } @@ -238,10 +286,10 @@ common_head(int *fdp) fd = open_kcov(); ATF_REQUIRE_MSG(ioctl(fd, KIOSETBUFSIZE, - PAGE_SIZE / KCOV_ENTRY_SIZE) == 0, + page_size / KCOV_ENTRY_SIZE) == 0, "Unable to set the kcov buffer size"); - data = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + data = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); ATF_REQUIRE_MSG(data != MAP_FAILED, "Unable to mmap the kcov buffer"); *fdp = fd; @@ -252,7 +300,7 @@ static void common_tail(int fd, void *data) { - ATF_REQUIRE_MSG(munmap(data, PAGE_SIZE) == 0, + ATF_REQUIRE_MSG(munmap(data, page_size) == 0, "Unable to unmap the kcov buffer"); close(fd); @@ -280,13 +328,23 @@ basic_test(u_int mode) common_tail(fd, buf); } -ATF_TC_WITHOUT_HEAD(kcov_basic_pc); +ATF_TC(kcov_basic_pc); +ATF_TC_HEAD(kcov_basic_pc, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_basic_pc, tc) { basic_test(KCOV_MODE_TRACE_PC); } -ATF_TC_WITHOUT_HEAD(kcov_basic_cmp); +ATF_TC(kcov_basic_cmp); +ATF_TC_HEAD(kcov_basic_cmp, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_basic_cmp, tc) { basic_test(KCOV_MODE_TRACE_CMP); @@ -327,13 +385,23 @@ thread_test(u_int mode) common_tail(fd, buf); } -ATF_TC_WITHOUT_HEAD(kcov_thread_pc); +ATF_TC(kcov_thread_pc); +ATF_TC_HEAD(kcov_thread_pc, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_thread_pc, tc) { thread_test(KCOV_MODE_TRACE_PC); } -ATF_TC_WITHOUT_HEAD(kcov_thread_cmp); +ATF_TC(kcov_thread_cmp); +ATF_TC_HEAD(kcov_thread_cmp, tc) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_thread_cmp, tc) { thread_test(KCOV_MODE_TRACE_CMP); @@ -364,7 +432,12 @@ multi_thread_test_helper(void *ptr) return (NULL); } -ATF_TC_WITHOUT_HEAD(kcov_enable_multi_thread); +ATF_TC(kcov_enable_multi_thread); +ATF_TC_HEAD(kcov_enable_multi_thread, t) +{ + init_page_size(); +} + ATF_TC_BODY(kcov_enable_multi_thread, t) { struct multi_thread_data data;