Skip to content

Commit 24f5b8b

Browse files
authored
Add GitHub Actions (#88)
Tests for Windows, macOS, and many different compilers on Linux.
1 parent 13df0d1 commit 24f5b8b

File tree

3 files changed

+59
-122
lines changed

3 files changed

+59
-122
lines changed

.github/workflows/test.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
push:
3+
4+
jobs:
5+
test-liunux:
6+
strategy:
7+
matrix:
8+
cc: [gcc-10, gcc-11, gcc-12, gcc-13, clang-13, clang-14, clang-15]
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
- name: test
14+
run: make CC=${{ matrix.cc }}
15+
test-macos:
16+
runs-on: macos-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
- name: test
21+
run: make
22+
test-windows:
23+
runs-on: windows-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v2
27+
- name: Setup cl
28+
uses: ilammy/msvc-dev-cmd@v1
29+
- name: Compile stresstest
30+
run: cl /Zi /DDSET_SORT_EXTRA stresstest.c
31+
- shell: bash
32+
run: ls
33+
- shell: bash
34+
name: stresstest
35+
run: ./stresstest.exe

.travis.yml

-119
This file was deleted.

stresstest.c

+24-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/* Copyright (c) 2012 Google Inc. All Rights Reserved. */
33

44
#define _XOPEN_SOURCE
5-
#include <sys/time.h>
65

76
#define SORT_NAME sorter
87
#define SORT_TYPE int64_t
@@ -26,7 +25,7 @@
2625
#define TESTS 1000
2726

2827
#define RAND_RANGE(__n, __min, __max) \
29-
(__n) = (__min) + (long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / (RAND_MAX + 1.0)))
28+
(__n) = (__min) + (long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / (0x7fffffff + 1.0)))
3029

3130
enum {
3231
FILL_RANDOM,
@@ -60,11 +59,33 @@ static __inline int simple_cmp(const void *a, const void *b) {
6059
return (da < db) ? -1 : (da == db) ? 0 : 1;
6160
}
6261

62+
#ifdef _WIN32
63+
64+
#include <time.h>
65+
static __inline void srand48(long seed) {
66+
srand(seed);
67+
}
68+
69+
static __inline long lrand48(void) {
70+
int x;
71+
rand_s(&x);
72+
return x & 0x7fffffff;
73+
}
74+
75+
static __inline double utime(void) {
76+
struct timespec ts;
77+
timespec_get(&ts, TIME_UTC);
78+
return 1000000.0 * ts.tv_sec + ts.tv_nsec / 1000.0;
79+
}
80+
#else
81+
82+
#include <sys/time.h>
6383
static __inline double utime(void) {
6484
struct timeval t;
6585
gettimeofday(&t, NULL);
6686
return (1000000.0 * t.tv_sec + t.tv_usec);
6787
}
88+
#endif
6889

6990
/* helper functions */
7091
int verify(int64_t *dst, const int size) {
@@ -229,7 +250,7 @@ int run_tests(int64_t *sizes, int sizes_cnt, int type) {
229250
int64_t * dst = (int64_t *)malloc(MAXSIZE * sizeof(int64_t));
230251
printf("-------\nRunning tests with %s:\n-------\n", test_names[type]);
231252
TEST_STDLIB(qsort);
232-
#if !defined(__linux__) && !defined(__CYGWIN__)
253+
#if !defined(__linux__) && !defined(__CYGWIN__) && !defined(_WIN32)
233254
TEST_STDLIB(heapsort);
234255
TEST_STDLIB(mergesort);
235256
#endif

0 commit comments

Comments
 (0)