-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
46 lines (41 loc) · 2.2 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
CROSS_ARCH=$(shell if [ $$(arch) = "x86_64" ]; then echo "aarch64"; else echo "x86-64"; fi)
X86_64_NAP=$(shell if [ $$(arch) = "x86_64" ]; then echo "./nap"; else echo "qemu-x86_64-static ./nap"; fi)
ARM_64_NAP=$(shell if [ $$(arch) = "x86_64" ]; then echo "qemu-aarch64-static ./nap-aarch64"; else echo "./nap-aarch64"; fi)
ci_build:
rm -fr out
mkdir out
nasm -f elf64 nap.asm
x86_64-linux-gnu-ld -m elf_x86_64 -z noseparate-code -z noexecstack --strip-all -o out/nap nap.o && rm nap.o
aarch64-linux-gnu-as nap-aarch64.s -o nap-aarch64.o
aarch64-linux-gnu-ld -z noseparate-code -z noexecstack --strip-all -o out/nap-aarch64 nap-aarch64.o && rm nap-aarch64.o
ls -la out/
ci_tests: ci_build
if [ $$(arch) = "x86_64" ]; then \
echo "[x86_64] Testing 1s nap"; \
timeout 3s out/nap 1 2>&1 > /dev/null; \
echo "[x86_64] Testing 10s default/bad input nap"; \
timeout 12s out/nap bad_arg ; if [ $$? = "1" ]; then true; else false; fi; \
else \
echo "x86_64 testing not available on aarch64 platform"; \
fi
echo "[aarch64] Testing 1s nap"
timeout 3s qemu-aarch64-static out/nap-aarch64 1 2>&1 > /dev/null
echo "[aarch64] Testing 10s default/bad input nap"
timeout 12s qemu-aarch64-static out/nap-aarch64 bad_arg ; if [ $$? = "1" ]; then true; else false; fi
tests: install
if [ $$(arch) = "x86_64" ]; then \
echo "[x86_64] Testing 1s nap"; \
docker run --rm -v "$(shell pwd)/out:/work" -w /work nap bash -c 'timeout 3s $(X86_64_NAP) 1 2>&1 > /dev/null'; \
echo "[x86_64] Testing 10s default/bad input nap"; \
docker run --rm -v "$(shell pwd)/out:/work" -w /work nap bash -c 'timeout 12s $(X86_64_NAP) bad_arg ; if [ $$? = "1" ]; then true; else false; fi'; \
else \
echo "x86_64 testing not available on aarch64 platform"; \
fi
echo "[aarch64] Testing 1s nap"
docker run --rm -v "$(shell pwd)/out:/work" -w /work nap bash -c 'timeout 3s $(ARM_64_NAP) 1 2>&1 > /dev/null'
echo "[aarch64] Testing 10s default/bad input nap"
docker run --rm -v "$(shell pwd)/out:/work" -w /work nap bash -c 'timeout 12s $(ARM_64_NAP) bad_arg ; if [ $$? = "1" ]; then true; else false; fi'
docker:
docker build --build-arg CROSS_ARCH=$(CROSS_ARCH) -t nap .
install: docker
docker run --rm -v "$(shell pwd):/src" -w /src nap make ci_build