diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1649634 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,35 @@ +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-windows: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup cl + uses: ilammy/msvc-dev-cmd@v1 + - name: Compile stresstest + run: cl /Zi /DDSET_SORT_EXTRA stresstest.c + - shell: bash + run: ls + - shell: bash + name: stresstest + run: ./stresstest.exe 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 diff --git a/stresstest.c b/stresstest.c index 224a894..50b9552 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 @@ -26,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, @@ -60,11 +59,33 @@ static __inline int simple_cmp(const void *a, const void *b) { return (da < db) ? -1 : (da == db) ? 0 : 1; } +#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; +} +#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) { @@ -229,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