From 8058e5df1755e279448676c4ad1ad83d54fb49b4 Mon Sep 17 00:00:00 2001 From: Yongjie Sheng Date: Sat, 11 Oct 2025 20:50:26 +0800 Subject: [PATCH] Add project test for cryptography-primitives Signed-off-by: H. Peter Anvin (Intel) --- test/Makefile.in | 7 +++++-- test/get_build_cryptography-primitivestest.sh | 19 +++++++++++++++++++ test/projtest.sh | 10 ++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100755 test/get_build_cryptography-primitivestest.sh diff --git a/test/Makefile.in b/test/Makefile.in index b9c2a970b..bfbd5ca96 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -19,7 +19,7 @@ TESTS = $(wildcard *.asm) RM_F = rm -f RM_RF = rm -rf -.PHONY: tools nasm ndisasm ffmpegtest x264test dav1dtest intel-ipsec-mbtest isa-ltest isa-l_cryptotest +.PHONY: tools nasm ndisasm ffmpegtest x264test dav1dtest intel-ipsec-mbtest isa-ltest isa-l_cryptotest cryptography-primitivestest tools: $(MAKE) -C .. all @@ -47,6 +47,9 @@ isa-ltest: isa-l_cryptotest: bash projtest.sh '$(NASM)' $@ +cryptography-primitivestest: + bash projtest.sh '$(NASM)' $@ + %.bin: %.asm $(NASM) $(NASM) $(NASMOPT) -f bin -o $@ -MD $@.dep -l $@.lst $< @@ -132,7 +135,7 @@ clean: $(RM_RF) testresults $(RM_F) elftest elftest64 $(RM_RF) ffmpegtest x264test dav1dtest - $(RM_RF) intel-ipsec-mbtest isa-ltest isa-l_cryptotest + $(RM_RF) intel-ipsec-mbtest isa-ltest isa-l_cryptotest cryptography-primitivestest spotless: clean $(RM_RF) golden diff --git a/test/get_build_cryptography-primitivestest.sh b/test/get_build_cryptography-primitivestest.sh new file mode 100755 index 000000000..c917f53ed --- /dev/null +++ b/test/get_build_cryptography-primitivestest.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +: >> "$filelist" + +if [ -d cryptography-primitives/.git ]; then + cd cryptography-primitives + git reset --hard + xargs -r rm -f < "$filelist" + CC=gcc CXX=g++ cmake CMakeLists.txt -B_build -DARCH=intel64 -DCMAKE_ASM_NASM_COMPILER=nasm + cd _build + make clean +else + git clone https://github.com/intel/cryptography-primitives.git cryptography-primitives + cd cryptography-primitives + CC=gcc CXX=g++ cmake CMakeLists.txt -B_build -DARCH=intel64 -DCMAKE_ASM_NASM_COMPILER=nasm + cd _build +fi +: > "$filelist" +make all -j4 diff --git a/test/projtest.sh b/test/projtest.sh index ca763867f..78e3afdef 100755 --- a/test/projtest.sh +++ b/test/projtest.sh @@ -11,7 +11,9 @@ fi NASM2="$1" [ -z "$NASM2" ] && NASM2=../nasm -NASM2=$(which "$NASM2" 2>/dev/null) +# which does not work for Ubuntu on a relative path executable +# NASM2=$(which "$NASM2" 2>/dev/null) +NASM2=${PWD}/${NASM2} if [ -z "$NASM2" ]; then echo 'Test nasm not found' 1>&2 exit 1 @@ -79,11 +81,11 @@ do echo file ${f}.2 does not exist fi - objdump -d ${f}.1 | tail -n +4 >/tmp/1.dump - objdump -d ${f}.2 | tail -n +4 >/tmp/2.dump + objdump -d --no-show-raw-insn --no-addresses ${f}.1 | tail -n +4 >/tmp/1.dump + objdump -d --no-show-raw-insn --no-addresses ${f}.2 | tail -n +4 >/tmp/2.dump if ! diff /tmp/1.dump /tmp/2.dump >/dev/null; then echo [differs] $f - #diff -u /tmp/1.dump /tmp/2.dump + diff -u /tmp/1.dump /tmp/2.dump else echo [matches] $f fi