Skip to content

Commit cad3acf

Browse files
authored
Switch test runner image to amd64 (#25)
This changes the test runner image to be based on a amd64 ubuntu:24.04 base image. To build students' solutions, we use a cross toolchain. To run solutions, we use qemu-user. Students are asked to use the exact same workflow. To this end we unify the tests Makefiles with those from the arm64-assembly exercises repository.
1 parent 157311a commit cad3acf

File tree

10 files changed

+48
-67
lines changed

10 files changed

+48
-67
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ jobs:
1616
- name: Checkout code
1717
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1818

19-
- name: Install QEMU and dependencies
20-
run: |
21-
sudo apt-get update
22-
sudo apt-get install -y qemu binfmt-support qemu-user-static
23-
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
24-
2519
- name: Set up Docker Buildx
2620
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5
2721
with:
@@ -34,7 +28,7 @@ jobs:
3428
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
3529
with:
3630
context: .
37-
platforms: linux/arm64
31+
platforms: linux/amd64
3832
push: false
3933
load: true
4034
tags: exercism/arm64-assembly-test-runner

Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
FROM arm64v8/alpine:3.20.1
1+
FROM ubuntu:24.04
22

33
# install packages required to run the tests
4-
RUN apk add --no-cache jq coreutils gcc libc-dev make python3
4+
RUN apt-get update \
5+
&& DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install --no-install-recommends \
6+
gcc-aarch64-linux-gnu \
7+
libc6-dev-arm64-cross \
8+
make \
9+
python3 \
10+
qemu-user \
11+
&& rm -rf /var/lib/apt/lists/*
512

613
WORKDIR /opt/test-runner
714
COPY . .

bin/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ test_file=$(echo "${slug}" | sed 's/-/_/g')_test.c
3131
cd "${solution_dir}" || exit
3232
sed -i 's#TEST_IGNORE();#// &#' "${test_file}"
3333
make clean
34-
stdbuf -oL make > "${output_dir}/results.out" 2>&1
34+
make > "${output_dir}/results.out" 2>&1
3535
python3 "${cwd}"/process_results.py "${output_dir}/results.out"

tests/all-fail/Makefile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
# Variables
2-
AS = as
3-
CC = gcc
1+
AS = aarch64-linux-gnu-as
2+
CC = aarch64-linux-gnu-gcc
43

54
CFLAGS = -g -Wall -Wextra -pedantic -Werror
65
LDFLAGS =
7-
ASFLAGS = -g
86

9-
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
107
ALL_LDFLAGS = -pie -Wl,--fatal-warnings
11-
ALL_ASFLAGS = $(ASFLAGS)
128

13-
# File lists
9+
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
10+
ALL_LDFLAGS += $(LDFLAGS)
11+
1412
C_OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
1513
AS_OBJS = $(patsubst %.s,%.o,$(wildcard *.s))
1614
ALL_OBJS = $(filter-out example.o,$(C_OBJS) $(AS_OBJS) vendor/unity.o)
1715

18-
# Commands
1916
CC_CMD = $(CC) $(ALL_CFLAGS) -c -o $@ $<
2017

21-
# Targets
2218
all: tests
23-
@./$<
19+
@qemu-aarch64 -L /usr/aarch64-linux-gnu ./$<
2420

2521
tests: $(ALL_OBJS)
2622
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $(ALL_OBJS)
2723

2824
%.o: %.s
29-
@$(AS) $(ALL_ASFLAGS) -o $@ $<
25+
@$(AS) -o $@ $<
3026

3127
%.o: %.c
3228
@$(CC_CMD)

tests/empty-file/Makefile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
# Variables
2-
AS = as
3-
CC = gcc
1+
AS = aarch64-linux-gnu-as
2+
CC = aarch64-linux-gnu-gcc
43

54
CFLAGS = -g -Wall -Wextra -pedantic -Werror
65
LDFLAGS =
7-
ASFLAGS = -g
86

9-
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
107
ALL_LDFLAGS = -pie -Wl,--fatal-warnings
11-
ALL_ASFLAGS = $(ASFLAGS)
128

13-
# File lists
9+
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
10+
ALL_LDFLAGS += $(LDFLAGS)
11+
1412
C_OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
1513
AS_OBJS = $(patsubst %.s,%.o,$(wildcard *.s))
1614
ALL_OBJS = $(filter-out example.o,$(C_OBJS) $(AS_OBJS) vendor/unity.o)
1715

18-
# Commands
1916
CC_CMD = $(CC) $(ALL_CFLAGS) -c -o $@ $<
2017

21-
# Targets
2218
all: tests
23-
@./$<
19+
@qemu-aarch64 -L /usr/aarch64-linux-gnu ./$<
2420

2521
tests: $(ALL_OBJS)
2622
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $(ALL_OBJS)
2723

2824
%.o: %.s
29-
@$(AS) $(ALL_ASFLAGS) -o $@ $<
25+
@$(AS) -o $@ $<
3026

3127
%.o: %.c
3228
@$(CC_CMD)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 2,
33
"status": "error",
4-
"message": "/usr/lib/gcc/aarch64-alpine-linux-musl/13.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: empty_file_test.o: in function `test_add':\n/opt/test-runner/tests/empty-file/empty_file_test.c:14:(.text+0x20): undefined reference to `add'\ncollect2: error: ld returned 1 exit status\nmake: *** [Makefile:26: tests] Error 1\n",
4+
"message": "/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: empty_file_test.o: in function `test_add':\n/opt/test-runner/tests/empty-file/empty_file_test.c:14:(.text+0x20): undefined reference to `add'\ncollect2: error: ld returned 1 exit status\nmake: *** [Makefile:22: tests] Error 1\n",
55
"tests": []
66
}

tests/partial-fail/Makefile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
# Variables
2-
AS = as
3-
CC = gcc
1+
AS = aarch64-linux-gnu-as
2+
CC = aarch64-linux-gnu-gcc
43

54
CFLAGS = -g -Wall -Wextra -pedantic -Werror
65
LDFLAGS =
7-
ASFLAGS = -g
86

9-
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
107
ALL_LDFLAGS = -pie -Wl,--fatal-warnings
11-
ALL_ASFLAGS = $(ASFLAGS)
128

13-
# File lists
9+
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
10+
ALL_LDFLAGS += $(LDFLAGS)
11+
1412
C_OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
1513
AS_OBJS = $(patsubst %.s,%.o,$(wildcard *.s))
1614
ALL_OBJS = $(filter-out example.o,$(C_OBJS) $(AS_OBJS) vendor/unity.o)
1715

18-
# Commands
1916
CC_CMD = $(CC) $(ALL_CFLAGS) -c -o $@ $<
2017

21-
# Targets
2218
all: tests
23-
@./$<
19+
@qemu-aarch64 -L /usr/aarch64-linux-gnu ./$<
2420

2521
tests: $(ALL_OBJS)
2622
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $(ALL_OBJS)
2723

2824
%.o: %.s
29-
@$(AS) $(ALL_ASFLAGS) -o $@ $<
25+
@$(AS) -o $@ $<
3026

3127
%.o: %.c
3228
@$(CC_CMD)

tests/success/Makefile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
# Variables
2-
AS = as
3-
CC = gcc
1+
AS = aarch64-linux-gnu-as
2+
CC = aarch64-linux-gnu-gcc
43

54
CFLAGS = -g -Wall -Wextra -pedantic -Werror
65
LDFLAGS =
7-
ASFLAGS = -g
86

9-
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
107
ALL_LDFLAGS = -pie -Wl,--fatal-warnings
11-
ALL_ASFLAGS = $(ASFLAGS)
128

13-
# File lists
9+
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
10+
ALL_LDFLAGS += $(LDFLAGS)
11+
1412
C_OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
1513
AS_OBJS = $(patsubst %.s,%.o,$(wildcard *.s))
1614
ALL_OBJS = $(filter-out example.o,$(C_OBJS) $(AS_OBJS) vendor/unity.o)
1715

18-
# Commands
1916
CC_CMD = $(CC) $(ALL_CFLAGS) -c -o $@ $<
2017

21-
# Targets
2218
all: tests
23-
@./$<
19+
@qemu-aarch64 -L /usr/aarch64-linux-gnu ./$<
2420

2521
tests: $(ALL_OBJS)
2622
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $(ALL_OBJS)
2723

2824
%.o: %.s
29-
@$(AS) $(ALL_ASFLAGS) -o $@ $<
25+
@$(AS) -o $@ $<
3026

3127
%.o: %.c
3228
@$(CC_CMD)

tests/syntax-error/Makefile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
# Variables
2-
AS = as
3-
CC = gcc
1+
AS = aarch64-linux-gnu-as
2+
CC = aarch64-linux-gnu-gcc
43

54
CFLAGS = -g -Wall -Wextra -pedantic -Werror
65
LDFLAGS =
7-
ASFLAGS = -g
86

9-
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
107
ALL_LDFLAGS = -pie -Wl,--fatal-warnings
11-
ALL_ASFLAGS = $(ASFLAGS)
128

13-
# File lists
9+
ALL_CFLAGS = -std=c99 -fPIE $(CFLAGS)
10+
ALL_LDFLAGS += $(LDFLAGS)
11+
1412
C_OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
1513
AS_OBJS = $(patsubst %.s,%.o,$(wildcard *.s))
1614
ALL_OBJS = $(filter-out example.o,$(C_OBJS) $(AS_OBJS) vendor/unity.o)
1715

18-
# Commands
1916
CC_CMD = $(CC) $(ALL_CFLAGS) -c -o $@ $<
2017

21-
# Targets
2218
all: tests
23-
@./$<
19+
@qemu-aarch64 -L /usr/aarch64-linux-gnu ./$<
2420

2521
tests: $(ALL_OBJS)
2622
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $(ALL_OBJS)
2723

2824
%.o: %.s
29-
@$(AS) $(ALL_ASFLAGS) -o $@ $<
25+
@$(AS) -o $@ $<
3026

3127
%.o: %.c
3228
@$(CC_CMD)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 2,
33
"status": "error",
4-
"message": "fake.s: Assembler messages:\nfake.s:5: Error: unknown mnemonic `return' -- `return'\nmake: *** [Makefile:29: fake.o] Error 1\n",
4+
"message": "fake.s: Assembler messages:\nfake.s:5: Error: unknown mnemonic `return' -- `return'\nmake: *** [Makefile:25: fake.o] Error 1\n",
55
"tests": []
66
}

0 commit comments

Comments
 (0)