Skip to content

Commit f7e8bf9

Browse files
committed
Run internal tests in Cygwin
1 parent af9de81 commit f7e8bf9

File tree

3 files changed

+68
-51
lines changed

3 files changed

+68
-51
lines changed

.github/workflows/testing.yml

+37
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,40 @@ jobs:
320320
shell: bash
321321
run: |
322322
test/run-tests.sh
323+
324+
cygwin:
325+
strategy:
326+
matrix:
327+
bits: [32, 64]
328+
include:
329+
- bits: 32
330+
arch: x86
331+
- bits: 64
332+
arch: x86_64
333+
fail-fast: false
334+
runs-on: windows-2019
335+
timeout-minutes: 30
336+
steps:
337+
- name: Checkout repo
338+
uses: actions/checkout@v4
339+
- name: Setup Cygwin
340+
uses: cygwin/cygwin-install-action@v4
341+
with:
342+
platform: ${{ matrix.arch }}
343+
packages: >-
344+
bison
345+
gcc-g++
346+
git
347+
libpng-devel
348+
make
349+
pkg-config
350+
- name: Build & install using Make
351+
shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -o igncr '{0}'
352+
run: | # Cygwin does not support `make develop` sanitizers ASan or UBSan
353+
make -kj Q=
354+
make install -j Q=
355+
- name: Run tests
356+
shell: C:\cygwin\bin\env.exe CYGWIN_NOWINPATH=1 CHERE_INVOKING=1 C:\cygwin\bin\bash.exe -o igncr '{0}'
357+
run: | # Allow asm/test.sh to run `git describe` for the version test
358+
git config --global --add safe.directory '*'
359+
test/run-tests.sh --only-internal

test/gfx/rgbgfx_test.cpp

+20-49
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
/* SPDX-License-Identifier: MIT */
22

3-
// For `execProg` (Windows is its special little snowflake again)
4-
#if !defined(_MSC_VER) && !defined(__MINGW32__)
5-
#include <sys/stat.h>
6-
#include <sys/wait.h>
7-
8-
#include <signal.h>
9-
#include <spawn.h>
10-
#include <unistd.h>
11-
#else
12-
#define WIN32_LEAN_AND_MEAN // Include less from `windows.h` to avoid conflicts
13-
#include <windows.h>
14-
#include <errhandlingapi.h>
15-
#include <processthreadsapi.h>
16-
#undef max // This macro conflicts with `std::numeric_limits<...>::max()`
17-
#endif
18-
193
#include <algorithm>
204
#include <array>
215
#include <cassert>
@@ -34,6 +18,22 @@
3418

3519
#include "gfx/rgba.hpp" // Reused from RGBGFX
3620

21+
// For `execProg` (Windows and POSIX spawn child processes differently)
22+
#if !defined(_MSC_VER) && !defined(__MINGW32__)
23+
#include <sys/stat.h>
24+
#include <sys/wait.h>
25+
26+
#include <signal.h>
27+
#include <spawn.h>
28+
#include <unistd.h>
29+
#else
30+
#define WIN32_LEAN_AND_MEAN // Include less from `windows.h` to avoid conflicts
31+
#include <windows.h>
32+
#include <errhandlingapi.h>
33+
#include <processthreadsapi.h>
34+
#undef max // This macro conflicts with `std::numeric_limits<...>::max()`
35+
#endif
36+
3737
static uintmax_t nbErrors;
3838

3939
static void warning(char const *fmt, ...) {
@@ -308,23 +308,13 @@ static char *execProg(char const *name, char * const *argv) {
308308
return strerror(err);
309309
}
310310

311-
siginfo_t info;
312-
if (waitid(P_PID, pid, &info, WEXITED) != 0) {
311+
if (int info; waitpid(pid, &info, 0) == -1 || !WIFEXITED(info)) {
313312
fatal("Error waiting for %s: %s", name, strerror(errno));
314-
} else if (info.si_code != CLD_EXITED) {
315-
assert(info.si_code == CLD_KILLED || info.si_code == CLD_DUMPED);
316-
fatal(
317-
"%s was terminated by signal %s%s\n\tThe command was: [%s]",
318-
name,
319-
strsignal(info.si_status),
320-
info.si_code == CLD_DUMPED ? " (core dumped)" : "",
321-
formatArgv()
322-
);
323-
} else if (info.si_status != 0) {
313+
} else if (int status = WEXITSTATUS(info); status != 0) {
324314
fatal(
325315
"%s returned with status %d\n\tThe command was: [%s]",
326316
name,
327-
info.si_status,
317+
status,
328318
formatArgv()
329319
);
330320
}
@@ -359,26 +349,7 @@ static char *execProg(char const *name, char * const *argv) {
359349

360350
STARTUPINFOA startupInfo;
361351
GetStartupInfoA(&startupInfo);
362-
STARTUPINFOA childStartupInfo{
363-
sizeof(startupInfo),
364-
nullptr,
365-
nullptr,
366-
nullptr,
367-
0,
368-
0,
369-
0,
370-
0,
371-
0,
372-
0,
373-
0,
374-
0,
375-
0,
376-
0,
377-
nullptr,
378-
0,
379-
0,
380-
0,
381-
};
352+
STARTUPINFOA childStartupInfo = {sizeof(startupInfo)};
382353

383354
PROCESS_INFORMATION child;
384355
if (CreateProcessA(

test/run-tests.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ cd "$(dirname "$0")"
66
usage() {
77
echo "Runs regression tests on RGBDS."
88
echo "Options:"
9-
echo " -h, --help show this help message"
10-
echo " --only-free skip tests that build nonfree codebases"
9+
echo " -h, --help show this help message"
10+
echo " --only-free skip tests that build nonfree codebases"
11+
echo " --only-internal skip tests that build external codebases"
1112
}
1213

1314
# Parse options in pure Bash because macOS `getopt` is stuck
1415
# in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode
1516
nonfree=true
17+
external=true
1618
FETCH_TEST_DEPS="fetch-test-deps.sh"
1719
while [[ $# -gt 0 ]]; do
1820
case "$1" in
@@ -24,6 +26,9 @@ while [[ $# -gt 0 ]]; do
2426
nonfree=false
2527
FETCH_TEST_DEPS="fetch-test-deps.sh --only-free"
2628
;;
29+
--only-internal)
30+
external=false
31+
;;
2732
--)
2833
break
2934
;;
@@ -49,6 +54,10 @@ for dir in asm link fix gfx; do
4954
popd
5055
done
5156

57+
if ! "$external"; then
58+
exit
59+
fi
60+
5261
# Test some significant external projects that use RGBDS
5362
# When adding new ones, don't forget to add them to the .gitignore!
5463
# When updating subprojects, change the commit being checked out, and set the `shallow-since`

0 commit comments

Comments
 (0)