Skip to content

Commit 6a89d7c

Browse files
chqrlieFGasper
andauthored
Add CI targets, fix test_std.js (bellard#247)
This switches the exec test to `SIGTERM` rather than `SIGQUIT` since the latter didn’t seem to work in QEMU, and the distinction doesn’t really matter for this test. This also makes the `isatty()` check smarter by checking whether `STDIN` is, in fact, a terminal. Added qemu-alpine targets i386, arm32v6, arm32v7, arm64v8, s390x Co-authored-by: Felipe Gasper <[email protected]>
1 parent ebe7496 commit 6a89d7c

File tree

2 files changed

+58
-31
lines changed

2 files changed

+58
-31
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,41 @@ on:
1212
- '.github/workflows/ci.yml'
1313
push:
1414
branches:
15-
- master
15+
- '*'
1616

1717
jobs:
1818
linux:
19+
name: Linux (Ubuntu)
1920
runs-on: ubuntu-latest
2021
strategy:
2122
fail-fast: false
2223
steps:
23-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2425
with:
2526
submodules: true
26-
- name: build
27+
- name: Build
2728
run: |
2829
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
29-
- name: stats
30+
- name: Stats
3031
run: |
3132
./qjs -qd
32-
- name: test
33+
- name: Run built-in tests
3334
run: |
3435
make test
35-
- name: microbench
36+
- name: Run microbench
3637
run: |
3738
make microbench
3839
3940
linux-asan:
4041
runs-on: ubuntu-latest
4142
steps:
42-
- uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
4344
with:
4445
submodules: true
45-
- name: build
46+
- name: Build
4647
run: |
4748
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_ASAN=y
48-
- name: test
49+
- name: Run built-in tests
4950
env:
5051
ASAN_OPTIONS: halt_on_error=1
5152
run: |
@@ -54,15 +55,15 @@ jobs:
5455
linux-msan:
5556
runs-on: ubuntu-latest
5657
steps:
57-
- uses: actions/checkout@v3
58+
- uses: actions/checkout@v4
5859
with:
5960
submodules: true
60-
- name: build
61+
- name: Build
6162
env:
6263
CC: clang
6364
run: |
6465
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_MSAN=y CONFIG_CLANG=y
65-
- name: test
66+
- name: Run built-in tests
6667
env:
6768
MSAN_OPTIONS: halt_on_error=1
6869
run: |
@@ -71,42 +72,43 @@ jobs:
7172
linux-ubsan:
7273
runs-on: ubuntu-latest
7374
steps:
74-
- uses: actions/checkout@v3
75+
- uses: actions/checkout@v4
7576
with:
7677
submodules: true
77-
- name: build
78+
- name: Build
7879
run: |
7980
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_UBSAN=y
80-
- name: test
81+
- name: Run built-in tests
8182
env:
8283
UBSAN_OPTIONS: halt_on_error=1
8384
run: |
8485
make CONFIG_UBSAN=y test
8586
8687
macos:
88+
name: macOS
8789
runs-on: macos-latest
8890
strategy:
8991
fail-fast: false
9092
steps:
91-
- uses: actions/checkout@v3
92-
- name: build
93+
- uses: actions/checkout@v4
94+
- name: Build
9395
run: |
9496
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
95-
- name: stats
97+
- name: Stats
9698
run: |
9799
./qjs -qd
98-
- name: test
100+
- name: Run built-in tests
99101
run: |
100102
make test
101103
102104
macos-asan:
103105
runs-on: macos-latest
104106
steps:
105-
- uses: actions/checkout@v3
106-
- name: build
107+
- uses: actions/checkout@v4
108+
- name: Build
107109
run: |
108110
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_ASAN=y
109-
- name: test
111+
- name: Run built-in tests
110112
env:
111113
ASAN_OPTIONS: halt_on_error=1
112114
run: |
@@ -115,11 +117,11 @@ jobs:
115117
macos-ubsan:
116118
runs-on: macos-latest
117119
steps:
118-
- uses: actions/checkout@v3
119-
- name: build
120+
- uses: actions/checkout@v4
121+
- name: Build
120122
run: |
121123
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_UBSAN=y
122-
- name: test
124+
- name: Run built-in tests
123125
env:
124126
UBSAN_OPTIONS: halt_on_error=1
125127
run: |
@@ -128,8 +130,8 @@ jobs:
128130
freebsd:
129131
runs-on: ubuntu-latest
130132
steps:
131-
- uses: actions/checkout@v3
132-
- name: build + test
133+
- uses: actions/checkout@v4
134+
- name: Build + test
133135
uses: vmactions/freebsd-vm@v1
134136
with:
135137
usesh: true
@@ -139,3 +141,26 @@ jobs:
139141
gmake
140142
./qjs -qd
141143
gmake test
144+
145+
qemu-alpine:
146+
runs-on: ubuntu-latest
147+
148+
strategy:
149+
fail-fast: false
150+
matrix:
151+
platform:
152+
- i386
153+
- arm32v6
154+
- arm32v7
155+
- arm64v8
156+
- s390x
157+
158+
steps:
159+
- uses: actions/checkout@v4
160+
with:
161+
submodules: recursive
162+
- name: Get qemu
163+
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
164+
- name: Run tests on ${{ matrix.platform }}
165+
run: docker run --rm --interactive --mount type=bind,source=$(pwd),target=/host ${{ matrix.platform }}/alpine sh -c "apk add git patch make gcc libc-dev && cd /host && make test"
166+

tests/test_std.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ function test_os()
144144
{
145145
var fd, fpath, fname, fdir, buf, buf2, i, files, err, fdate, st, link_path;
146146

147-
// XXX(bnoordhuis) disabled because stdio is not a tty on CI
148-
//assert(os.isatty(0));
147+
const stdinIsTTY = !os.exec(["/bin/sh", "-c", "test -t 0"], { usePath: false });
148+
149+
assert(os.isatty(0), stdinIsTTY, `isatty(STDIN)`);
149150

150151
fdir = "test_tmp_dir";
151152
fname = "tmp_file.txt";
@@ -254,10 +255,11 @@ function test_os_exec()
254255

255256
pid = os.exec(["cat"], { block: false } );
256257
assert(pid >= 0);
257-
os.kill(pid, os.SIGQUIT);
258+
os.kill(pid, os.SIGTERM);
258259
[ret, status] = os.waitpid(pid, 0);
259260
assert(ret, pid);
260-
assert(status & 0x7f, os.SIGQUIT);
261+
assert(status !== 0, true, `expect nonzero exit code (got ${status})`);
262+
assert(status & 0x7f, os.SIGTERM);
261263
}
262264

263265
function test_timer()

0 commit comments

Comments
 (0)