Skip to content

Commit

Permalink
Add more metal CI and test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Oct 25, 2024
1 parent d15aa62 commit a592adb
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 24 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/metal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
testcase: [ hasher_256, hasher_512 ]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -37,17 +41,17 @@ jobs:
- name: build benchmark_single-stm32f429
run: |
mkdir -p bin
emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ -std=c++20 -Wall -Wextra -Wpedantic -Os -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -fno-inline-functions -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I../../include -DBOOST_CRYPT_NO_EXCEPTIONS -DBOOST_CRYPT_DISABLE_IOSTREAM -DAPP_BENCHMARK_STANDALONE_MAIN app_benchmark_hasher.cpp ./target/micros/stm32f429/make/single/crt.cpp ./target/micros/stm32f429/make/single/mcal_gcc_cxx_completion_with_stdlib.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_hasher.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -Wl,--print-memory-usage -o ./bin/app_benchmark_hasher.elf
emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/app_benchmark_hasher.elf -O ihex ./bin/app_benchmark_hasher.hex
ls -la ./bin/app_benchmark_hasher.elf ./bin/app_benchmark_hasher.hex ./bin/app_benchmark_hasher.map
emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-g++ -std=c++20 -Wall -Wextra -Wpedantic -Os -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -fno-inline-functions -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I../../include -DBOOST_CRYPT_NO_EXCEPTIONS -DBOOST_CRYPT_DISABLE_IOSTREAM -DAPP_BENCHMARK_STANDALONE_MAIN app_benchmark_${{ matrix.testcase }}.cpp ./target/micros/stm32f429/make/single/crt.cpp ./target/micros/stm32f429/make/single/mcal_gcc_cxx_completion_with_stdlib.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_${{ matrix.testcase }}.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -Wl,--print-memory-usage -o ./bin/app_benchmark_${{ matrix.testcase }}.elf
emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-objcopy ./bin/app_benchmark_${{ matrix.testcase }}.elf -O ihex ./bin/app_benchmark_${{ matrix.testcase }}.hex
ls -la ./bin/app_benchmark_${{ matrix.testcase }}.elf ./bin/app_benchmark_${{ matrix.testcase }}.hex ./bin/app_benchmark_${{ matrix.testcase }}.map
working-directory: ./test/metal/
- name: emulate-target stm32f429
run: |
./emu_env/xpack-qemu-arm-7.1.0-1/bin/qemu-system-gnuarmeclipse --verbose --mcu STM32F429ZI --nographic --gdb tcp::9999 -d unimp,guest_errors &
working-directory: ./test/metal/
- name: run-test-on-target
run: |
./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb-py ./bin/app_benchmark_hasher.elf -x ./target/build/test_app_benchmarks_emulator.py
./emu_env/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb-py ./bin/app_benchmark_${{ matrix.testcase }}.elf -x ./target/build/test_app_benchmarks_emulator.py
qemu_result=$?
echo "qemu_result" "$qemu_result"
echo "qemu_result" "$qemu_result" | grep 'qemu_result 0'
Expand Down
8 changes: 6 additions & 2 deletions include/boost/crypt/hash/sha512.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ auto sha512_file_impl(utility::file_reader<block_size>& reader) noexcept -> sha5

} // namespace detail

#ifndef BOOST_CRYPT_DISABLE_IOSTREAM

BOOST_CRYPT_EXPORT inline auto sha512_file(const std::string& filepath) noexcept -> sha512_hasher::return_type
{
try
Expand Down Expand Up @@ -253,7 +255,9 @@ BOOST_CRYPT_EXPORT inline auto sha512_file(const char* filepath) noexcept -> sha
}
}

#ifdef BOOST_CRYPT_HAS_STRING_VIEW
#endif // !BOOST_CRYPT_DISABLE_IOSTREAM

#if (defined(BOOST_CRYPT_HAS_STRING_VIEW) && !defined(BOOST_CRYPT_DISABLE_IOSTREAM))

BOOST_CRYPT_EXPORT inline auto sha512_file(std::string_view filepath) noexcept -> sha512_hasher::return_type
{
Expand All @@ -268,7 +272,7 @@ BOOST_CRYPT_EXPORT inline auto sha512_file(std::string_view filepath) noexcept -
}
}

#endif // BOOST_CRYPT_HAS_STRING_VIEW
#endif // BOOST_CRYPT_HAS_STRING_VIEW && !BOOST_CRYPT_DISABLE_IOSTREAM

#endif // BOOST_CRYPT_HAS_CUDA

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023.
// Copyright Christopher Kormanyos 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif

// cd /mnt/c/ChrisGitRepos/cppalliance/crypt/test/metal
// mkdir -p bin
// arm-none-eabi-g++ -std=c++17 -Wall -Wextra -Wpedantic -O0 -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=128 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I../../include -DBOOST_DECIMAL_DISABLE_CLIB -DAPP_BENCHMARK_STANDALONE_MAIN app_benchmark_hasher.cpp ./target/micros/stm32f429/make/single/crt.cpp ./target/micros/stm32f429/make/single/mcal_gcc_cxx_completion_with_stdlib.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_hasher.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -Wl,--print-memory-usage -o ./bin/app_benchmark_hasher.elf
// arm-none-eabi-objcopy ./bin/app_benchmark_hasher.elf -O ihex ./bin/app_benchmark_hasher.hex
// ls -la ./bin/app_benchmark_hasher.elf ./bin/app_benchmark_hasher.hex ./bin/app_benchmark_hasher.map
// arm-none-eabi-g++ -std=c++20 -Wall -Wextra -Wpedantic -Os -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=128 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I../../include -DBOOST_CRYPT_DISABLE_IOSTREAM -DBOOST_CRYPT_NO_EXCEPTIONS -DAPP_BENCHMARK_STANDALONE_MAIN app_benchmark_hasher_256.cpp ./target/micros/stm32f429/make/single/crt.cpp ./target/micros/stm32f429/make/single/mcal_gcc_cxx_completion_with_stdlib.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_hasher_256.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -Wl,--print-memory-usage -o ./bin/app_benchmark_hasher_256.elf
// arm-none-eabi-objcopy ./bin/app_benchmark_hasher_256.elf -O ihex ./bin/app_benchmark_hasher_256.hex
// ls -la ./bin/app_benchmark_hasher_256.elf ./bin/app_benchmark_hasher_256.hex ./bin/app_benchmark_hasher_256.map

#if !defined(BOOST_CRYPT_STANDALONE)
#define BOOST_DECIMAL_STANDALONE
Expand All @@ -28,7 +23,7 @@ namespace detail {

} // namespace detail

auto run_hasher() -> bool;
auto run_hasher_256() -> bool;

} // namespace benchmark
} // namespace app
Expand All @@ -40,20 +35,20 @@ namespace local

} // namespace local

auto app::benchmark::run_hasher() -> bool
auto app::benchmark::run_hasher_256() -> bool
{
auto app_benchmark_result_is_ok = true;

// "abc"
const std::array<std::uint8_t, 3U> message =
const std::array<std::uint8_t, 3U> message =
{{
0x61U, 0x62U, 0x63U
}};

using local_hasher_type = local::hasher_type;
using local_result_type = typename local_hasher_type::return_type;

const local_result_type control =
constexpr local_result_type control =
{{
0xBAU, 0x78U, 0x16U, 0xBFU, 0x8FU, 0x01U, 0xCFU, 0xEAU,
0x41U, 0x41U, 0x40U, 0xDEU, 0x5DU, 0xAEU, 0x22U, 0x23U,
Expand All @@ -67,7 +62,7 @@ auto app::benchmark::run_hasher() -> bool

my_hasher.process_bytes(message.data(), message.size());

const local_result_type result = my_hasher.get_digest();
const local_result_type result { my_hasher.get_digest() };

const bool result_hash_is_ok { result == control };

Expand All @@ -92,7 +87,7 @@ extern "C"

for(unsigned i = 0U; i < 64U; ++i)
{
result_is_ok &= app::benchmark::run_hasher();
result_is_ok &= app::benchmark::run_hasher_256();
}

app_benchmark_standalone_result =
Expand Down Expand Up @@ -128,6 +123,3 @@ extern "C"
}
#endif // APP_BENCHMARK_STANDALONE_MAIN

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
129 changes: 129 additions & 0 deletions test/metal/app_benchmark_hasher_512.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

// cd /mnt/c/ChrisGitRepos/cppalliance/crypt/test/metal
// mkdir -p bin
// arm-none-eabi-g++ -std=c++20 -Wall -Wextra -Wpedantic -Os -g -gdwarf-2 -ffunction-sections -fdata-sections -x c++ -fno-rtti -fno-use-cxa-atexit -fno-exceptions -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs -ftemplate-depth=128 -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -mfloat-abi=soft -mno-unaligned-access -mno-long-calls -I../../include -DBOOST_CRYPT_DISABLE_IOSTREAM -DBOOST_CRYPT_NO_EXCEPTIONS -DAPP_BENCHMARK_STANDALONE_MAIN app_benchmark_hasher_512.cpp ./target/micros/stm32f429/make/single/crt.cpp ./target/micros/stm32f429/make/single/mcal_gcc_cxx_completion_with_stdlib.cpp -nostartfiles -Wl,--gc-sections -Wl,-Map,./bin/app_benchmark_hasher_512.map -T ./target/micros/stm32f429/make/stm32f429.ld --specs=nano.specs --specs=nosys.specs -Wl,--print-memory-usage -o ./bin/app_benchmark_hasher_512.elf
// arm-none-eabi-objcopy ./bin/app_benchmark_hasher_512.elf -O ihex ./bin/app_benchmark_hasher_512.hex
// ls -la ./bin/app_benchmark_hasher_512.elf ./bin/app_benchmark_hasher_512.hex ./bin/app_benchmark_hasher_512.map

#if !defined(BOOST_CRYPT_STANDALONE)
#define BOOST_DECIMAL_STANDALONE
#endif

#include <boost/crypt/hash/sha512.hpp>

namespace app { namespace benchmark {

namespace detail {

} // namespace detail

auto run_hasher_512() -> bool;

} // namespace benchmark
} // namespace app

namespace local
{

using hasher_type = boost::crypt::sha512_hasher;

} // namespace local

auto app::benchmark::run_hasher_512() -> bool
{
auto app_benchmark_result_is_ok = true;

// "abc"
const std::array<std::uint8_t, 3U> message =
{{
0x61U, 0x62U, 0x63U
}};

using local_hasher_type = local::hasher_type;
using local_result_type = typename local_hasher_type::return_type;

constexpr local_result_type control =
{{
0xDDU, 0xAFU, 0x35U, 0xA1U, 0x93U, 0x61U, 0x7AU, 0xBAU,
0xCCU, 0x41U, 0x73U, 0x49U, 0xAEU, 0x20U, 0x41U, 0x31U,
0x12U, 0xE6U, 0xFAU, 0x4EU, 0x89U, 0xA9U, 0x7EU, 0xA2U,
0x0AU, 0x9EU, 0xEEU, 0xE6U, 0x4BU, 0x55U, 0xD3U, 0x9AU,
0x21U, 0x92U, 0x99U, 0x2AU, 0x27U, 0x4FU, 0xC1U, 0xA8U,
0x36U, 0xBAU, 0x3CU, 0x23U, 0xA3U, 0xFEU, 0xEBU, 0xBDU,
0x45U, 0x4DU, 0x44U, 0x23U, 0x64U, 0x3CU, 0xE8U, 0x0EU,
0x2AU, 0x9AU, 0xC9U, 0x4FU, 0xA5U, 0x4CU, 0xA4U, 0x9FU,
}};

local_hasher_type my_hasher { };

my_hasher.init();

my_hasher.process_bytes(message.data(), message.size());

const local_result_type result { my_hasher.get_digest() };

const bool result_hash_is_ok { result == control };

app_benchmark_result_is_ok = (result_hash_is_ok && app_benchmark_result_is_ok);

return app_benchmark_result_is_ok;
}

#if defined(APP_BENCHMARK_STANDALONE_MAIN)
constexpr auto app_benchmark_standalone_foodcafe = static_cast<std::uint32_t>(UINT32_C(0xF00DCAFE));

extern "C"
{
extern volatile std::uint32_t app_benchmark_standalone_result;

auto app_benchmark_run_standalone (void) -> bool;
auto app_benchmark_get_standalone_result(void) -> bool;

auto app_benchmark_run_standalone(void) -> bool
{
auto result_is_ok = true;

for(unsigned i = 0U; i < 64U; ++i)
{
result_is_ok &= app::benchmark::run_hasher_512();
}

app_benchmark_standalone_result =
static_cast<std::uint32_t>
(
result_is_ok ? app_benchmark_standalone_foodcafe : static_cast<std::uint32_t>(UINT32_C(0xFFFFFFFF))
);

return result_is_ok;
}

auto app_benchmark_get_standalone_result(void) -> bool
{
volatile auto result_is_ok = (app_benchmark_standalone_result == static_cast<std::uint32_t>(UINT32_C(0xF00DCAFE)));

return result_is_ok;
}
}

auto main() -> int
{
auto result_is_ok = true;

result_is_ok = (::app_benchmark_run_standalone () && result_is_ok);
result_is_ok = (::app_benchmark_get_standalone_result() && result_is_ok);

return (result_is_ok ? 0 : -1);
}

extern "C"
{
volatile std::uint32_t app_benchmark_standalone_result;
}
#endif // APP_BENCHMARK_STANDALONE_MAIN

0 comments on commit a592adb

Please sign in to comment.