From dc37f41e96562c27ee222d6e151bd402854d0a98 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 7 Feb 2024 21:19:07 -0800 Subject: [PATCH 01/16] Work on GHA --- .github/workflows/test.yml | 27 +++++++++ .travis.yml | 119 ------------------------------------- 2 files changed, 27 insertions(+), 119 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..110d641 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +on: + push: + +jobs: + test-liunux-gcc: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: test + run: make CC=gcc + test-liunux-clang: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: test + run: make CC=clang + test-macos: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: test + run: make diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 704a566..0000000 --- a/.travis.yml +++ /dev/null @@ -1,119 +0,0 @@ -language: c -script: make -matrix: - include: - # works on Precise and Trusty - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.9 - env: - - MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9" - - # works on Precise and Trusty - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-5 - env: - - MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" - - # works on Precise and Trusty - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-6 - env: - - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" - - # works on Precise and Trusty - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-7 - env: - - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - - # works on Precise and Trusty - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.6 - packages: - - clang-3.6 - env: - - MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6" - - # works on Precise and Trusty - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.7 - packages: - - clang-3.7 - env: - - MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7" - - # works on Precise and Trusty - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-precise-3.8 - packages: - - clang-3.8 - env: - - MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8" - - # works on Trusty - - os: linux - addons: - apt: - sources: - - llvm-toolchain-trusty-3.9 - packages: - - clang-3.9 - env: - - MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9" - - # works on Trusty - - os: linux - addons: - apt: - sources: - - llvm-toolchain-trusty-4.0 - packages: - - clang-4.0 - env: - - MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0" - - - os: osx - osx_image: xcode10.1 - - - os: osx - osx_image: xcode9.4 - - - os: osx - osx_image: xcode8 - env: - - MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9" - -before_install: - - eval "${MATRIX_EVAL}" \ No newline at end of file From 24134fee33c36a2bcfb422e15c9652266f737bf8 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 7 Feb 2024 21:24:00 -0800 Subject: [PATCH 02/16] Remove names as they are just confusing --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 110d641..841a3e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,6 @@ on: jobs: test-liunux-gcc: - name: Test runs-on: ubuntu-latest steps: - name: Checkout code @@ -11,7 +10,6 @@ jobs: - name: test run: make CC=gcc test-liunux-clang: - name: Test runs-on: ubuntu-latest steps: - name: Checkout code From 2aa3280a8bb693db3f572e43208d44656c4de000 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 7 Feb 2024 21:28:08 -0800 Subject: [PATCH 03/16] Checking versions --- .github/workflows/test.yml | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 841a3e7..7fc5adf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,23 +3,25 @@ on: jobs: test-liunux-gcc: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v2 - - name: test - run: make CC=gcc - test-liunux-clang: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: test - run: make CC=clang - test-macos: - runs-on: macos-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: test - run: make + # - name: test + # run: make CC=gcc + - run: ls /usr/bin/gcc* + - run: ls /usr/bin/clang* + # test-liunux-clang: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + # - name: test + # run: make CC=clang + # test-macos: + # runs-on: macos-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + # - name: test + # run: make From b67f387aa6089c1e4b61abb77a4c84cc0d2451e1 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 7 Feb 2024 21:36:56 -0800 Subject: [PATCH 04/16] Matrix for Linux; try to run windows tests --- .github/workflows/test.yml | 41 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fc5adf..8e89001 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,26 +2,29 @@ on: push: jobs: - test-liunux-gcc: + test-liunux: + strategy: + matrix: + cc: [gcc-10, gcc-11, gcc-12, gcc-13, clang-13, clang-14, clang-15] runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v2 - # - name: test - # run: make CC=gcc - - run: ls /usr/bin/gcc* - - run: ls /usr/bin/clang* - # test-liunux-clang: - # runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v2 - # - name: test - # run: make CC=clang - # test-macos: - # runs-on: macos-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v2 - # - name: test - # run: make + - name: test + run: make CC=${{ matrix.cc }} + test-macos: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: test + run: make + test-windows: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: test + run: cl /O3 stresstest.c + - name: stresstest + run: stresstest.exe From f259864614bb944141dce16a1c46f483925e1c61 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 7 Feb 2024 21:39:35 -0800 Subject: [PATCH 05/16] Pull in CLI --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e89001..25c9d33 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: test + - name: Setup cl + uses: ilammy/msvc-dev-cmd@v1 + - name: Compile stresstest run: cl /O3 stresstest.c - name: stresstest run: stresstest.exe From 620a65746394d1aa51636ad4b69a5b79e0ff2104 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Wed, 7 Feb 2024 21:45:18 -0800 Subject: [PATCH 06/16] Try to compile stresstest on windows --- .github/workflows/test.yml | 2 +- stresstest.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 25c9d33..118bc50 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,6 @@ jobs: - name: Setup cl uses: ilammy/msvc-dev-cmd@v1 - name: Compile stresstest - run: cl /O3 stresstest.c + run: cl /O2 stresstest.c - name: stresstest run: stresstest.exe diff --git a/stresstest.c b/stresstest.c index 224a894..508d169 100644 --- a/stresstest.c +++ b/stresstest.c @@ -2,7 +2,6 @@ /* Copyright (c) 2012 Google Inc. All Rights Reserved. */ #define _XOPEN_SOURCE -#include #define SORT_NAME sorter #define SORT_TYPE int64_t @@ -60,11 +59,23 @@ static __inline int simple_cmp(const void *a, const void *b) { return (da < db) ? -1 : (da == db) ? 0 : 1; } +#ifdef _WIN32 + +#include +static __inline double utime(void) { + struct timespec ts; + timespec_get(&ts, TIME_UTC); + return 1000000.0 * ts.tv_sec + ts.tv_nsec / 1000.0; +} +#else + +#include static __inline double utime(void) { struct timeval t; gettimeofday(&t, NULL); return (1000000.0 * t.tv_sec + t.tv_usec); } +#endif /* helper functions */ int verify(int64_t *dst, const int size) { From a8f8f4ec3c9cb2a7aec7c10b22a983ad038d4696 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Thu, 8 Feb 2024 16:42:37 -0800 Subject: [PATCH 07/16] Implement lrand48/srand48 --- .github/workflows/test.yml | 34 +++++++++++++++++----------------- stresstest.c | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 118bc50..12cc3dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,23 +2,23 @@ on: push: jobs: - test-liunux: - strategy: - matrix: - cc: [gcc-10, gcc-11, gcc-12, gcc-13, clang-13, clang-14, clang-15] - runs-on: ubuntu-22.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: test - run: make CC=${{ matrix.cc }} - test-macos: - runs-on: macos-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: test - run: make + # test-liunux: + # strategy: + # matrix: + # cc: [gcc-10, gcc-11, gcc-12, gcc-13, clang-13, clang-14, clang-15] + # runs-on: ubuntu-22.04 + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + # - name: test + # run: make CC=${{ matrix.cc }} + # test-macos: + # runs-on: macos-latest + # steps: + # - name: Checkout code + # uses: actions/checkout@v2 + # - name: test + # run: make test-windows: runs-on: windows-latest steps: diff --git a/stresstest.c b/stresstest.c index 508d169..91efe7f 100644 --- a/stresstest.c +++ b/stresstest.c @@ -62,10 +62,20 @@ static __inline int simple_cmp(const void *a, const void *b) { #ifdef _WIN32 #include +static __inline void srand48(long seed) { + srand(seed); +} + +static __inline long lrand48(void) { + int x; + rand_s(&x); + return x & 0x7fffffff; +} + static __inline double utime(void) { - struct timespec ts; - timespec_get(&ts, TIME_UTC); - return 1000000.0 * ts.tv_sec + ts.tv_nsec / 1000.0; + struct timespec ts; + timespec_get(&ts, TIME_UTC); + return 1000000.0 * ts.tv_sec + ts.tv_nsec / 1000.0; } #else @@ -240,7 +250,7 @@ int run_tests(int64_t *sizes, int sizes_cnt, int type) { int64_t * dst = (int64_t *)malloc(MAXSIZE * sizeof(int64_t)); printf("-------\nRunning tests with %s:\n-------\n", test_names[type]); TEST_STDLIB(qsort); -#if !defined(__linux__) && !defined(__CYGWIN__) +#if !defined(__linux__) && !defined(__CYGWIN__) && !defined(_WIN32) TEST_STDLIB(heapsort); TEST_STDLIB(mergesort); #endif From cd72dccd5ef52c2add6c79ba34c508e809331fb0 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Thu, 8 Feb 2024 16:45:18 -0800 Subject: [PATCH 08/16] Run with .\ --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12cc3dc..0e01396 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,4 +29,4 @@ jobs: - name: Compile stresstest run: cl /O2 stresstest.c - name: stresstest - run: stresstest.exe + run: .\stresstest.exe From 0c3af48116bde49548a1bc00f1e08bdc79a75950 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Thu, 8 Feb 2024 16:49:51 -0800 Subject: [PATCH 09/16] Try with bash --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e01396..391ff1e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,5 +28,8 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Compile stresstest run: cl /O2 stresstest.c - - name: stresstest - run: .\stresstest.exe + - shell: bash + run: ls + - shell: bash + name: stresstest + run: ./stresstest.exe From 10e7960b6ef998911a740d9ad5791da17371702a Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Thu, 8 Feb 2024 16:52:04 -0800 Subject: [PATCH 10/16] Reduce from O2 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 391ff1e..c31c138 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Setup cl uses: ilammy/msvc-dev-cmd@v1 - name: Compile stresstest - run: cl /O2 stresstest.c + run: cl stresstest.c - shell: bash run: ls - shell: bash From e7efa6d9ae19a79926bfe40295bb89a812561929 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Thu, 8 Feb 2024 16:56:38 -0800 Subject: [PATCH 11/16] Try to get stack trace out of windows --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c31c138..30e0b61 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,4 +32,4 @@ jobs: run: ls - shell: bash name: stresstest - run: ./stresstest.exe + run: gdb -batch -ex "run" -ex "bt" ./stresstest.ext 2>&1 | grep -v ^"No stack."$ From 1aa9418bf6f55387974020ab72450ecceed3b478 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Thu, 8 Feb 2024 16:58:20 -0800 Subject: [PATCH 12/16] Fix typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30e0b61..ea8c89a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,4 +32,4 @@ jobs: run: ls - shell: bash name: stresstest - run: gdb -batch -ex "run" -ex "bt" ./stresstest.ext 2>&1 | grep -v ^"No stack."$ + run: gdb -batch -ex "run" -ex "bt" ./stresstest.exe 2>&1 | grep -v ^"No stack."$ From 2d12a3fc3966723afb6e66b29652b6adb51d99db Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Thu, 8 Feb 2024 17:00:53 -0800 Subject: [PATCH 13/16] Compile with /Zi --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ea8c89a..e71c04e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Setup cl uses: ilammy/msvc-dev-cmd@v1 - name: Compile stresstest - run: cl stresstest.c + run: cl /Zi stresstest.c - shell: bash run: ls - shell: bash From 7de920571e19a1069c87849a7a1786d682eefdfa Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Mon, 12 Feb 2024 20:10:28 -0800 Subject: [PATCH 14/16] Divide by const, not RAND_MAX --- stresstest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stresstest.c b/stresstest.c index 91efe7f..50b9552 100644 --- a/stresstest.c +++ b/stresstest.c @@ -25,7 +25,7 @@ #define TESTS 1000 #define RAND_RANGE(__n, __min, __max) \ - (__n) = (__min) + (long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / (RAND_MAX + 1.0))) + (__n) = (__min) + (long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / (0x7fffffff + 1.0))) enum { FILL_RANDOM, From d356fa40c66db08c90c7ed37581873e08c4fa9cd Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Mon, 12 Feb 2024 20:16:35 -0800 Subject: [PATCH 15/16] Enable all tests --- .github/workflows/test.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e71c04e..79afd03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,23 +2,23 @@ on: push: jobs: - # test-liunux: - # strategy: - # matrix: - # cc: [gcc-10, gcc-11, gcc-12, gcc-13, clang-13, clang-14, clang-15] - # runs-on: ubuntu-22.04 - # steps: - # - name: Checkout code - # uses: actions/checkout@v2 - # - name: test - # run: make CC=${{ matrix.cc }} - # test-macos: - # runs-on: macos-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v2 - # - name: test - # run: make + test-liunux: + strategy: + matrix: + cc: [gcc-10, gcc-11, gcc-12, gcc-13, clang-13, clang-14, clang-15] + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: test + run: make CC=${{ matrix.cc }} + test-macos: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: test + run: make test-windows: runs-on: windows-latest steps: @@ -32,4 +32,4 @@ jobs: run: ls - shell: bash name: stresstest - run: gdb -batch -ex "run" -ex "bt" ./stresstest.exe 2>&1 | grep -v ^"No stack."$ + run: ./stresstest.exe From 28ec087597203318567121c3752b7fefdfd8cc20 Mon Sep 17 00:00:00 2001 From: Christopher Swenson Date: Mon, 12 Feb 2024 20:21:16 -0800 Subject: [PATCH 16/16] Compile with extra flags on Windows --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79afd03..1649634 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Setup cl uses: ilammy/msvc-dev-cmd@v1 - name: Compile stresstest - run: cl /Zi stresstest.c + run: cl /Zi /DDSET_SORT_EXTRA stresstest.c - shell: bash run: ls - shell: bash