Skip to content

Commit 3535c86

Browse files
committed
Prepare files under testdata/ from Makefile
The testdata/ directory must have vmlinux, root-drive.img and firecracker binary, in order to run Go tests. This change prepares the files by just running "make". Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 56995a0 commit 3535c86

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

Makefile

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,42 @@
1313

1414
# Set this to pass additional commandline flags to the go compiler, e.g. "make test EXTRAGOARGS=-v"
1515
EXTRAGOARGS:=
16+
DISABLE_ROOT_TESTS?=1
17+
18+
# The below files are needed and can be downloaded from the internet
19+
testdata_objects = testdata/vmlinux testdata/root-drive.img testdata/firecracker
20+
21+
# --location is needed to follow redirects on github.com
22+
curl = curl --location
1623

1724
all: build
1825

1926
test: all-tests
2027

21-
unit-tests:
22-
go test -short ./... $(EXTRAGOARGS)
28+
unit-tests: $(testdata_objects) check-kvm
29+
DISABLE_ROOT_TESTS=$(DISABLE_ROOT_TESTS) go test -short ./... $(EXTRAGOARGS)
2330

24-
all-tests:
25-
go test ./... $(EXTRAGOARGS)
31+
all-tests: $(testdata_objects) check-kvm
32+
DISABLE_ROOT_TESTS=$(DISABLE_ROOT_TESTS) go test ./... $(EXTRAGOARGS)
33+
34+
check-kvm:
35+
@test -w /dev/kvm || \
36+
(echo "In order to run firecracker, $(shell whoami) must have write permission to /dev/kvm"; false)
2637

2738
generate build clean:
2839
go $@ $(EXTRAGOARGS)
2940

30-
.PHONY: all generate clean build test unit-tests all-tests
41+
distclean: clean
42+
rm -rf $(testdata_objects)
43+
44+
testdata/vmlinux:
45+
$(curl) -o $@ https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin
46+
47+
testdata/firecracker:
48+
$(curl) -o $@ https://github.com/firecracker-microvm/firecracker/releases/download/v0.18.0/firecracker-v0.18.0
49+
chmod +x $@
50+
51+
testdata/root-drive.img:
52+
$(curl) -o $@ https://s3.amazonaws.com/spec.ccfc.min/img/hello/fsfiles/hello-rootfs.ext4
53+
54+
.PHONY: all generate clean distclean build test unit-tests all-tests check-kvm

0 commit comments

Comments
 (0)