Skip to content

Commit

Permalink
Merge pull request #65 from kolyshkin/go116
Browse files Browse the repository at this point in the history
ci/gha: add go 1.16; run as root; fix some tests; add fedora
  • Loading branch information
AkihiroSuda committed Mar 8, 2021
2 parents 4836a5f + eb2a60a commit d038b10
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .ci/Vagrantfile.fedora32 → .ci/Vagrantfile.fedora33
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Vagrant.configure("2") do |config|
# Fedora box is used for testing cgroup v2 support
config.vm.box = "fedora/32-cloud-base"
config.vm.box = "fedora/33-cloud-base"
config.vm.provider :virtualbox do |v|
v.memory = 2048
v.cpus = 2
Expand Down
20 changes: 0 additions & 20 deletions .ci/install-vagrant.sh

This file was deleted.

29 changes: 24 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,39 @@ jobs:
test:
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
platform: [ubuntu-latest, windows-latest]
go-version: [1.14.x, 1.15.x, 1.16.x]
platform: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: make test
- name: Lint
run: make lint
- name: Cross build
if: ${{ runner.os == 'Linux' }}
run: make cross
- name: Test
run: make test

# some features, like openat2, require a newer kernel
fedora:
# nested virtualization is only available on macOS hosts
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- name: prepare vagrant
run: |
ln -sf .ci/Vagrantfile.fedora33 Vagrantfile
# Retry if it fails (download.fedoraproject.org returns 404 sometimes)
vagrant up || vagrant up
vagrant ssh-config >> ~/.ssh/config
- name: system info
run: ssh default 'sh -exc "uname -a && df -T"'

- name: tests
run: ssh default 'cd /vagrant && make test'
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ PACKAGES ?= mountinfo mount symlink
BINDIR ?= _build/bin
CROSS ?= linux/arm linux/arm64 linux/ppc64le linux/s390x \
freebsd/amd64 openbsd/amd64 darwin/amd64 darwin/arm64 windows/amd64
SUDO ?= sudo -n

.PHONY: all
all: lint test cross

.PHONY: test
test: RUN_VIA_SUDO = $(shell $(SUDO) true && echo -exec \"$(SUDO)\")
test:
for p in $(PACKAGES); do \
(cd $$p && go test -v .); \
(cd $$p && go test $(RUN_VIA_SUDO) -v .); \
done

.PHONY: lint
Expand Down
4 changes: 3 additions & 1 deletion mount/mounter_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ func validateMount(t *testing.T, mnt string, opts, optional, vfs string) {
if mi.VFSOptions != "" {
for _, opt := range strings.Split(mi.VFSOptions, ",") {
opt = clean(opt)
if !has(wantedVFS, opt) && opt != "seclabel" { // can be added by selinux
if !has(wantedVFS, opt) &&
opt != "seclabel" && // can be added by selinux
opt != "inode64" && opt != "inode32" { // can be added by kernel 5.9+
t.Errorf("unexpected vfs option %q, expected %q", opt, vfs)
}
delete(wantedVFS, opt)
Expand Down
18 changes: 12 additions & 6 deletions mountinfo/mounted_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,20 @@ func cleanupMounts(t *testing.T, dir string, mounts []string) {
}
}

func TestMountedBy(t *testing.T) {
func requireOpenat2(t *testing.T) {
t.Helper()
if os.Getuid() != 0 {
t.Skip("requires root")
}
fd, err := unix.Openat2(unix.AT_FDCWD, ".", &unix.OpenHow{Flags: unix.O_RDONLY})
if err != nil {
t.Skipf("openat2: %v (old kernel? need Linux 5.6+)", err)
}
unix.Close(fd)
}

func TestMountedBy(t *testing.T) {
requireOpenat2(t)

dir, mounts, err := prepareMounts(t)
defer cleanupMounts(t, dir, mounts)
Expand Down Expand Up @@ -224,11 +234,7 @@ func TestMountedBy(t *testing.T) {
}

func TestMountedByOpenat2VsMountinfo(t *testing.T) {
fd, err := unix.Openat2(unix.AT_FDCWD, ".", &unix.OpenHow{Flags: unix.O_RDONLY})
if err != nil {
t.Skipf("openat2: %v (old kernel? need Linux 5.6+)", err)
}
unix.Close(fd)
requireOpenat2(t)

mounts, err := GetMounts(nil)
if err != nil {
Expand Down

0 comments on commit d038b10

Please sign in to comment.