Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consistent testing #74

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: PR Testing

on:
pull_request:
push:
branches:
- master

concurrency:
# In master we want to run for every commit, in other branches — only for the last one
group: ${{
( github.ref == 'refs/heads/master' && format('{0}/{1}/{2}', github.workflow, github.ref, github.sha) )
||
format('{0}/{1}', github.workflow, github.ref) }}
cancel-in-progress: true

jobs:
handle-syncwith:
name: Call Reusable SyncWith Handler
uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1.2.0
with:
ci-cd-ref: 'v1.2.0'
secrets: inherit

test-linux:
name: Linux Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing-linux.yml@crypto-nix

secrets: inherit
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
check-names: |
block-clang 2
# Temporarily disable mac tests, they fail.
# test-mac:
# name: Mac Reusable Crypto3 Testing
# needs:
# - handle-syncwith
# uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing-mac.yml@crypto-nix

# secrets: inherit
# with:
# submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
# check-names: |
# block-clang

publish-results:
name: Publish JUnit results
needs:
- test-linux
# - test-mac
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-publish-result.yml@crypto-nix
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,5 @@ cm_deploy(TARGETS ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
INCLUDE include
NAMESPACE ${CMAKE_WORKSPACE_NAME}::)

if(BUILD_TESTS)
add_subdirectory(test)
endif()
include(CMTest)
cm_add_test_subdirectory(test)
14 changes: 7 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# http://www.boost.org/LICENSE_1_0.txt
#---------------------------------------------------------------------------#

include(CMTest)

if(NOT Boost_UNIT_TEST_FRAMEWORK_FOUND)
cm_find_package(Boost REQUIRED COMPONENTS unit_test_framework)
endif()
Expand All @@ -16,27 +14,29 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
${Boost_LIBRARIES})

macro(define_block_cipher_test name)
cm_test(NAME block_${name}_test SOURCES ${name}.cpp)
set(test_name "block_${name}_test")

cm_test(NAME ${test_name} SOURCES ${name}.cpp)

target_include_directories(block_${name}_test PRIVATE
target_include_directories(${test_name} PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"

${Boost_INCLUDE_DIRS})

if(NOT CMAKE_CXX_STANDARD)
set_target_properties(block_${name}_test PROPERTIES CXX_STANDARD 14)
set_target_properties(${test_name} PROPERTIES CXX_STANDARD 14)
endif()

get_target_property(target_type Boost::unit_test_framework TYPE)
if(target_type STREQUAL "SHARED_LIB")
target_compile_definitions(block_${name}_test PRIVATE BOOST_TEST_DYN_LINK)
target_compile_definitions(${test_name} PRIVATE BOOST_TEST_DYN_LINK)
elseif(target_type STREQUAL "STATIC_LIB")

endif()

string(CONCAT TEST_DATA ${CMAKE_CURRENT_SOURCE_DIR} "/data/" "${name}" ".json")
target_compile_definitions(block_${name}_test PRIVATE TEST_DATA="${TEST_DATA}")
target_compile_definitions(${test_name} PRIVATE TEST_DATA_DIR="${TEST_DATA}")
endmacro()

set(TESTS_NAMES
Expand Down
23 changes: 11 additions & 12 deletions test/pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@

#define BOOST_TEST_MODULE block_pack_test

#include <boost/array.hpp>
#include <boost/cstdint.hpp>

#include <nil/crypto3/detail/pack.hpp>
#include <array>
#include <cstdint>
#include <cstdio>

#include <boost/test/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>

#include <cstdio>
#include <nil/crypto3/detail/pack.hpp>

using namespace nil::crypto3;
using namespace nil::crypto3::detail;
Expand Down Expand Up @@ -66,7 +65,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_bubb_2) {
BOOST_AUTO_TEST_CASE(bubb_to_bulb_1) {
std::array<uint8_t, 4> in = {{0x12, 0x34, 0x56, 0x78}};
std::array<uint32_t, 1> out {};
std::array<uint32_t, 1> res = {{0x482c6a1e}};
std::array<uint32_t, 1> res = {{0x482c6a1e}};

pack<big_octet_big_bit, big_octet_little_bit, 8, 32>(in.begin(), in.end(), out.begin());

Expand All @@ -90,7 +89,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_lubb_1) {

pack<big_octet_big_bit, little_octet_big_bit, 8, 64>(in.begin(), in.end(), out.begin());

BOOST_CHECK(out == res);
BOOST_CHECK(out == res);
}

BOOST_AUTO_TEST_CASE(bubb_to_lubb_2) {
Expand Down Expand Up @@ -204,7 +203,7 @@ BOOST_AUTO_TEST_CASE(lubb_to_lulb_2) {
}

BOOST_AUTO_TEST_CASE(bulb_to_bubb_1) {
std::array<uint8_t, 16> in = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
std::array<uint8_t, 16> in = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
0x48, 0x2c, 0x6a, 0x1e, 0x09, 0xd5, 0xb3, 0xf7}};
std::array<uint64_t, 2> out {};
std::array<uint64_t, 2> res = {{0x482c6a1e09d5b3f7, 0x1234567890abcdef}};
Expand Down Expand Up @@ -392,7 +391,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_bubb_2) {
BOOST_AUTO_TEST_CASE(bubb_to_bulb_1) {
std::array<uint32_t, 1> in = {{0x482c6a1e}};
std::array<uint8_t, 4> out {};
std::array<uint8_t, 4> res = {{0x12, 0x34, 0x56, 0x78}};
std::array<uint8_t, 4> res = {{0x12, 0x34, 0x56, 0x78}};

pack<big_octet_big_bit, big_octet_little_bit, 32, 8>(in.begin(), in.end(), out.begin());

Expand All @@ -416,7 +415,7 @@ BOOST_AUTO_TEST_CASE(bubb_to_lubb_1) {

pack<big_octet_big_bit, little_octet_big_bit, 64, 8>(in.begin(), in.end(), out.begin());

BOOST_CHECK(out == res);
BOOST_CHECK(out == res);
}

BOOST_AUTO_TEST_CASE(bubb_to_lubb_2) {
Expand Down Expand Up @@ -530,9 +529,9 @@ BOOST_AUTO_TEST_CASE(lubb_to_lulb_2) {
}

BOOST_AUTO_TEST_CASE(bulb_to_bubb_1) {
std::array<uint64_t, 2> in = {{0x482c6a1e09d5b3f7, 0x1234567890abcdef}};
std::array<uint64_t, 2> in = {{0x482c6a1e09d5b3f7, 0x1234567890abcdef}};
std::array<uint8_t, 16> out {};
std::array<uint8_t, 16> res = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
std::array<uint8_t, 16> res = {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
0x48, 0x2c, 0x6a, 0x1e, 0x09, 0xd5, 0xb3, 0xf7}};

pack<big_octet_little_bit, big_octet_big_bit, 64, 8>(in.begin(), in.end(), out.begin());
Expand Down
Loading