Skip to content

Commit

Permalink
dev-libs/blake3: wire up tests
Browse files Browse the repository at this point in the history
See: BLAKE3-team/BLAKE3#405
Bug: https://bugs.gentoo.org/935370
Signed-off-by: Matoro Mahri <matoro_gentoo@matoro.tk>
  • Loading branch information
matoro committed Aug 9, 2024
1 parent 7598cb6 commit 608d97f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dev-libs/blake3/blake3-1.5.3.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ 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" )

src_configure() {
local mycmakeargs=(
-DBLAKE3_BUILD_TESTING="$(usex test)"
)
cmake_src_configure
}
57 changes: 57 additions & 0 deletions dev-libs/blake3/files/blake3-1.5.3-backport-pr405.patch
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 608d97f

Please sign in to comment.