dev-libs/blake3: wire up tests

See: https://github.com/BLAKE3-team/BLAKE3/pull/405
Bug: https://bugs.gentoo.org/935370
Signed-off-by: Matoro Mahri <matoro_gentoo@matoro.tk>
Closes: https://github.com/gentoo/gentoo/pull/38021
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Matoro Mahri
2024-08-08 22:06:36 -04:00
committed by Michał Górny
parent d039b1148c
commit cbe461a76a
2 changed files with 74 additions and 1 deletions

View File

@@ -3,7 +3,8 @@
EAPI=8
inherit cmake
PYTHON_COMPAT=( python3_{11..13} )
inherit cmake python-any-r1
DESCRIPTION="a fast cryptographic hash function"
HOMEPAGE="https://github.com/BLAKE3-team/BLAKE3"
@@ -13,3 +14,18 @@ S="${WORKDIR}/BLAKE3-${PV}/c"
LICENSE="|| ( CC0-1.0 Apache-2.0 )"
SLOT="0/0"
KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~loong ~m68k ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
IUSE="test"
RESTRICT="!test? ( test )"
PATCHES=( "${FILESDIR}/${PN}-1.5.3-backport-pr405.patch" )
BDEPEND="test? ( ${PYTHON_DEPS} )"
pkg_setup() {
use test && python-any-r1_pkg_setup
}
src_configure() {
local mycmakeargs=(
-DBLAKE3_BUILD_TESTING="$(usex test)"
)
cmake_src_configure
}

View File

@@ -0,0 +1,57 @@
https://bugs.gentoo.org/935370
https://github.com/BLAKE3-team/BLAKE3/pull/405
From aad68f7f009b7e0607b3eee3b8b8e3021fa38bd7 Mon Sep 17 00:00:00 2001
From: matoro <matoro@users.noreply.github.com>
Date: Tue, 2 Jul 2024 19:36:45 -0400
Subject: [PATCH] build(CMake): support running tests with ctest
---
CMakeLists.txt | 11 +++++++++++
test.py | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a3b232d..e778e3d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -168,6 +168,17 @@ else()
BLAKE3_DISABLE_SIMD()
endif()
+# cmake test support
+if (BLAKE3_BUILD_TESTING)
+ find_package(Python3 REQUIRED)
+ get_target_property(BLAKE3_SOURCES blake3 SOURCES)
+ add_executable(blake3-testing ${BLAKE3_SOURCES} main.c)
+ set_property(TARGET blake3-testing PROPERTY OUTPUT_NAME blake3)
+ target_compile_definitions(blake3-testing PRIVATE BLAKE3_TESTING=1)
+ enable_testing()
+ add_test(test_vectors "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/test.py" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+endif()
+
# cmake install support
install(FILES blake3.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(TARGETS blake3 EXPORT blake3-targets)
diff --git a/test.py b/test.py
index 98b1c3df..2eb1f07e 100755
--- a/test.py
+++ b/test.py
@@ -2,7 +2,7 @@
from binascii import hexlify
import json
-from os import path
+from os import getcwd, path
import subprocess
HERE = path.dirname(__file__)
@@ -11,7 +11,7 @@
def run_blake3(args, input):
- output = subprocess.run([path.join(HERE, "blake3")] + args,
+ output = subprocess.run([path.join(getcwd(), "blake3")] + args,
input=input,
stdout=subprocess.PIPE,
check=True)