Skip to content

Commit

Permalink
Test x86_64-pc-cygwin target with basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackhex committed Apr 15, 2024
1 parent f500b98 commit 2f89bc6
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 28 deletions.
27 changes: 23 additions & 4 deletions .github/scripts/tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,29 @@

source `dirname ${BASH_SOURCE[0]}`/../config.sh

echo "::group::Build Aarch64 tests"
cd tests
cmake -S . -B build
cd tests

if [ "$RUN_CONFIG" = 1 ] || [ ! -f build/CMakeCache.txt ] ; then
echo "::group::Configure tests"
rm -rf build/*
TARGET=$TARGET \
TOOLCHAIN_NAME=$TOOLCHAIN_NAME \
TOOLCHAIN_PATH=$TOOLCHAIN_PATH \
cmake -S . -B build
echo "::endgroup::"
fi

echo "::group::Build tests"
cmake --build build

cp $TOOLCHAIN_PATH/$TARGET/bin/*.dll build/bin
case "$PLATFORM" in
w64-mingw32)
cp $TOOLCHAIN_PATH/$TARGET/bin/libwinpthread-1.dll build/bin
;;
pc-cygwin)
cp $TOOLCHAIN_PATH/bin/cygwin1.dll build/bin
cp $TOOLCHAIN_PATH/lib/gcc/$TARGET/cyggcc_s-seh-1.dll build/bin
cp $TOOLCHAIN_PATH/lib/gcc/$TARGET/14/cyggomp-1.dll build/bin
;;
esac
echo "::endgroup::"
2 changes: 1 addition & 1 deletion .github/scripts/tests/execute-tests.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
. $PSScriptRoot\..\config.ps1

Write-Output '::group::Test toolchain'
& $env:ARTIFACT_PATH\aarch64-mingw-tests.exe
& $env:ARTIFACT_PATH\$env:TARGET-tests.exe
Write-Output "::endgroup::"
24 changes: 13 additions & 11 deletions .github/workflows/advanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ env:
SOURCE_PATH: ${{ github.workspace }}/code
ARTIFACT_PATH: ${{ github.workspace }}/artifact

TEST_TOOLCHAIN: ${{ inputs.arch == 'aarch64' && inputs.platform == 'w64-mingw32' && inputs.crt == 'msvcrt' }}
TEST_TOOLCHAIN: ${{ (inputs.arch == 'aarch64' && inputs.platform == 'w64-mingw32' && inputs.crt == 'msvcrt') || (inputs.arch == 'x86_64' && inputs.platform == 'pc-cygwin') }}
TEST_PACKAGES: ${{ inputs.arch == 'aarch64' && inputs.platform == 'w64-mingw32' && inputs.crt == 'msvcrt' }}

jobs:
build-toolchain:
Expand Down Expand Up @@ -300,6 +301,7 @@ jobs:
outputs:
toolchain-cache-key: ${{ env.TEST_TOOLCHAIN == 'true' && format('{0}-{1}-{2}-{3}-{4}-{5}-{6}', env.TOOLCHAIN_NAME, steps.workflow-sha.outputs.sha, steps.binutils-sha.outputs.sha, steps.gcc-sha.outputs.sha, steps.mingw-sha.outputs.sha, steps.binutils-scripts-sha.outputs.sha, steps.toolchain-scripts-sha.outputs.sha) || '' }}
test-toolchain: ${{ env.TEST_TOOLCHAIN == 'true' }}
test-packages: ${{ env.TEST_PACKAGES == 'true' }}

build-tests:
needs: [build-toolchain]
Expand Down Expand Up @@ -365,7 +367,7 @@ jobs:

build-openblas:
needs: [build-toolchain]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -409,7 +411,7 @@ jobs:

execute-openblas-tests:
needs: [build-toolchain, build-openblas]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: [Windows, GCC, ARM64]

steps:
Expand All @@ -435,7 +437,7 @@ jobs:
build-zlib:
needs: [build-toolchain]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -479,7 +481,7 @@ jobs:

build-libxml2:
needs: [build-toolchain, build-zlib]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -533,7 +535,7 @@ jobs:

build-openssl:
needs: [build-toolchain, build-zlib]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -602,7 +604,7 @@ jobs:

execute-openssl-tests:
needs: [build-toolchain, build-openssl]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: [Windows, GCC, ARM64]

steps:
Expand Down Expand Up @@ -644,7 +646,7 @@ jobs:
build-libjpeg-turbo:
needs: [build-toolchain]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -703,7 +705,7 @@ jobs:

execute-libpeg-turbo-tests:
needs: [build-toolchain, build-libjpeg-turbo]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: [Windows, GCC, ARM64]

steps:
Expand All @@ -728,7 +730,7 @@ jobs:
build-ffmpeg:
needs: [build-toolchain]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -777,7 +779,7 @@ jobs:

execute-ffmpeg-tests:
needs: [build-toolchain, build-ffmpeg]
if: ${{ needs.build-toolchain.outputs.test-toolchain == 'true' }}
if: ${{ needs.build-toolchain.outputs.test-packages == 'true' }}
runs-on: [Windows, GCC, ARM64]

steps:
Expand Down
8 changes: 4 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp")
set(CMAKE_RANLIB "$ENV{TOOLCHAIN_PATH}/bin/$ENV{TARGET}-ranlib")

cmake_minimum_required(VERSION 3.14)
project(aarch64_mingw_tests)
project("$ENV{TARGET}-tests")

enable_testing()

add_library(simple-dll SHARED dll.c)

add_executable(
aarch64-mingw-tests.exe
"$ENV{TARGET}-tests.exe"
bigdata-test.c
chkstk-test.c
dll-test.c
Expand All @@ -40,10 +40,10 @@ add_executable(
)

target_link_libraries(
aarch64-mingw-tests.exe
"$ENV{TARGET}-tests.exe"
simple-dll
)

set_target_properties(simple-dll PROPERTIES SUFFIX ".dll")
set_target_properties(simple-dll PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set_target_properties(aarch64-mingw-tests.exe PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set_target_properties("$ENV{TARGET}-tests.exe" PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
14 changes: 9 additions & 5 deletions tests/bigdata-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static uint32_t fnv1a(uint32_t hash, const char *data)

// Test if large text is stored and addressed correctly.
// Basically hash a lot of strings and check the result.
static uint32_t hash_big_text()
static int hash_big_text()
{
uint32_t hash = OFFSET_BASIS_32;

Expand Down Expand Up @@ -84,7 +84,7 @@ static uint32_t hash_big_text()
hash = fnv1a(hash, "it was taken off the market, research showed that brand");
hash = fnv1a(hash, "recognition for the model was still at 87%.");

return hash;
return hash = 2659567138;
}

#define MAX_SAMPLES 0x1000000
Expand Down Expand Up @@ -114,8 +114,12 @@ static int check_bss()
return 1;
}

TEST(Aarch64MinGW, BigDataTest)
TEST(BigDataTest, HashBigText)
{
ASSERT_TRUE(hash_big_text());
}

TEST(BigDataTest, CheckBss)
{
ASSERT_EQ(hash_big_text(), 2659567138);
ASSERT_TRUE(check_bss());
}
}
8 changes: 8 additions & 0 deletions tests/dll-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
__declspec(dllimport) int __cdecl add_c_export(int a, int b);
__declspec(dllimport) int __stdcall add_std_export(int a, int b);

#if !defined(__CYGWIN__)

// These functions were exported via a def file.
int __cdecl add_c_def(int a, int b);
int __stdcall add_std_def(int a, int b);

#endif

// call a pointer to a function
int test_func_pointer(int __cdecl (*f)(int, int))
{
Expand All @@ -32,14 +36,18 @@ int check_dll()
return 1;
if (add_std_export(7, 3) != 10)
return 2;
#if !defined(__CYGWIN__)
if (add_c_def(7, 3) != 10)
return 3;
if (add_std_def(7, 3) != 10)
return 4;
#endif
if (test_func_pointer(add_c_export) != 29)
return 5;
#if !defined(__CYGWIN__)
if (test_func_pointer(add_c_def) != 29)
return 6;
#endif
return 0;
}

Expand Down
6 changes: 4 additions & 2 deletions tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include <getopt.h>

TEST(Aarch64MinGW, BigDataTest);
TEST(BigDataTest, HashBigText);
TEST(BigDataTest, CheckBss);
TEST(Aarch64MinGW, CHKSTKTest);
TEST(Aarch64MinGW, DllTest);
TEST(Aarch64MinGW, MathTest);
Expand Down Expand Up @@ -40,7 +41,8 @@ int main(int argc, char **argv) {
}

struct Test tests[] = {
DECLARE_TEST(Aarch64MinGW, BigDataTest),
DECLARE_TEST(BigDataTest, HashBigText),
DECLARE_TEST(BigDataTest, CheckBss),
DECLARE_TEST(Aarch64MinGW, CHKSTKTest),
DECLARE_TEST(Aarch64MinGW, DllTest),
DECLARE_TEST(Aarch64MinGW, MathTest),
Expand Down
2 changes: 1 addition & 1 deletion tests/varargs-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static void va_list_print(char *buf, size_t length, const char *fmt, ...)
{
va_list argv;
va_start(argv, fmt);
register int retval = _vsnprintf(buf, length, fmt, argv);
register int retval = vsnprintf(buf, length, fmt, argv);
va_end(argv);
}

Expand Down

0 comments on commit 2f89bc6

Please sign in to comment.