From nobody Fri Jun 17 09:43:56 2022 X-Original-To: dev-commits-src-main@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 CBF7D85DE40; Fri, 17 Jun 2022 09:43:57 +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 4LPYyj2zKkz4dbC; Fri, 17 Jun 2022 09:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655459037; 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=rBANyv7cLKdW3VJ0Xuhi+YdC78wUF0VMyrPEo1P1gQY=; b=Dmh0wyQHcXbYsC5SwrEvRLqRJwfxFDve7U7Yf4lSdFVLOsH/krTiN0FwzueB2LZUWa/Wko KdQ0IMZ8kuV5tjpHRSZb7JTB5/rIW/HlpVFzGpwliyLWnkJa2lHoIIJjVvlvmmj81+HSvh Aere2K1nR8hf1N39JgysYWyj6zDPzIpsoKdXAhQ0S62uzeK8ehANoJUyzcWzYu+g3kvagS IJB6EVd4Rs76e0WSe8SMc8saoegc88/4LcNLQzhEyuBYA5oLw3gM2wkgkb2t8b2yXya98m 3Yj0f4jPxnAyix9c9+tsS5o7JcgPUyqWYV/yHrGvSUWJbpkqWSNOEcbbdmWWUw== 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 CC4BF1D6F9; Fri, 17 Jun 2022 09:43:56 +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 25H9huAB012940; Fri, 17 Jun 2022 09:43:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25H9huAw012939; Fri, 17 Jun 2022 09:43:56 GMT (envelope-from git) Date: Fri, 17 Jun 2022 09:43:56 GMT Message-Id: <202206170943.25H9huAw012939@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 2ff6e4ee9762 - main - Remove PAGE_SIZE from the kcov tests List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 2ff6e4ee9762526ed1e924da838a760423271978 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655459037; 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=rBANyv7cLKdW3VJ0Xuhi+YdC78wUF0VMyrPEo1P1gQY=; b=Wn1H8er7JCMKUSZ17tz+q6MBCo75gjlQLWU3vNOIkaruYFfoy3bdwiXo2PvS88mOD4IDm/ qEtm7tpUlykXzFCU0meFNBE5GLNDCTIGra5wk8apLxCTTiHldHwpZ/EWuVwW0w/pPaPRao p3lyqaI2WR3voCSldFsKMoj+iktdXhBgld/F2Tp04+nYEQGk3oTwmYewPEU4TN8CVyYziA 7RKJkGEDJvWZTbtxvUMnoerledMVS3AUVDMWf+eUSEc4GtPzQK2KUQ8VCOKtwaWveB+Yuh aLuaiH21nPwvvwCPATICNIgxh7qqzdPHUwIiJIcWLr2l9hurM/G1TpGB7NiMWQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655459037; a=rsa-sha256; cv=none; b=hWSIWSjdVfi/nrc8ouR1QVeoQ6N7df3E3sFv09TxlddrVq866mLduej8BTgBbFNBCJD/Y5 /T3RBVibBgzw6dB4pNGizezSUciyfLYmMB1nGdh5H7e0i0MQoi6uNFCyvwwDmAyXmFNSCx 9rMVPmwuO+ageZRIW5D73qjty/5WCA0QaHgEsPgKUQHPbN25GSJEY/sYDnKjku6sMXQi2n gBnpO9RBiqCp04wtGpqtGOEIPm6+JA/ymbetC2q9PNf6jbSyLH9SH8V8ft6+d9UpzsVrqO 0k5Vfu7/Cs8542brlr3H25xNol0Z9gYicynlMsu1tpkHRNqHe9oyB8hDbCstoA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=2ff6e4ee9762526ed1e924da838a760423271978 commit 2ff6e4ee9762526ed1e924da838a760423271978 Author: Andrew Turner AuthorDate: 2022-04-20 17:33:00 +0000 Commit: Andrew Turner CommitDate: 2022-06-17 09:43: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 --- 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 a8a43faf2d15..d7d22109cc49 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;