Skip to content

Commit

Permalink
Merge pull request #220 from dmcgowan/enable-tests-all-platforms
Browse files Browse the repository at this point in the history
Enable tests for all platforms
  • Loading branch information
estesp authored Apr 22, 2023
2 parents 72c70fe + b449cd0 commit 58654a2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,16 @@ jobs:
run: make build binaries
working-directory: src/github.com/containerd/continuity

- name: Linux Tests
if: startsWith(matrix.os, 'ubuntu')
- name: Tests
run: |
make test
make root-test
working-directory: src/github.com/containerd/continuity

- name: Non-Linux Tests
if: ${{ !startsWith(matrix.os, 'ubuntu') }}
shell: bash
run: make test-compile
- name: Root Tests
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
make root-test
working-directory: src/github.com/containerd/continuity

cross:
name: Cross-compile
runs-on: ubuntu-22.04
Expand Down
5 changes: 5 additions & 0 deletions fs/copy_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"io"
"os"
"runtime"
"syscall"

"github.com/containerd/continuity/sysx"
Expand Down Expand Up @@ -71,6 +72,10 @@ func copyFileContent(dst, src *os.File) error {
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
xattrKeys, err := sysx.LListxattr(src)
if err != nil {
if os.IsPermission(err) && runtime.GOOS == "darwin" {
// On darwin, character devices do not permit listing xattrs
return nil
}
e := fmt.Errorf("failed to list xattrs on %s: %w", src, err)
if errorHandler != nil {
e = errorHandler(dst, src, "", e)
Expand Down
11 changes: 7 additions & 4 deletions fs/copy_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package fs
import (
"os"
"path/filepath"
"runtime"
"syscall"
"testing"

Expand Down Expand Up @@ -89,11 +90,13 @@ func TestCopyIrregular(t *testing.T) {
t.Fatal(err)
}
prepared++
f2Socket := filepath.Join(src, "f2.sock")
if err := unix.Mknod(f2Socket, 0o600|unix.S_IFSOCK, 0); err != nil {
t.Fatal(err)
if runtime.GOOS != "darwin" {
f2Socket := filepath.Join(src, "f2.sock")
if err := unix.Mknod(f2Socket, 0o600|unix.S_IFSOCK, 0); err != nil {
t.Fatal(err)
}
prepared++
}
prepared++
f3Dev := filepath.Join(src, "f3.dev")
if err := unix.Mknod(f3Dev, 0o600|unix.S_IFCHR, 42); err != nil {
t.Logf("skipping testing S_IFCHR: %v", err)
Expand Down
3 changes: 3 additions & 0 deletions fs/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ func TestRemoveDirectoryTree(t *testing.T) {
}

func TestRemoveDirectoryTreeWithDash(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("windows fails this test with `-` files reported as modified")
}
l1 := fstest.Apply(
fstest.CreateDir("/dir1/dir2/dir3", 0o755),
fstest.CreateFile("/dir1/f1", []byte("f1"), 0o644),
Expand Down
26 changes: 15 additions & 11 deletions fs/du_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@ func TestUsage(t *testing.T) {
}
if runtime.GOOS != "windows" {
testCases = append(testCases, []testCase{
{
name: "SparseFiles",
fs: fstest.Apply(
fstest.CreateDir("/dir", 0o755),
fstest.CreateRandomFile("/dir/file1", 7, 5, 0o644),
createSparseFile("/dir/sparse1", 8, 0o644, 5, 1024*1024, 5),
createSparseFile("/dir/sparse2", 9, 0o644, 0, 1024*1024),
createSparseFile("/dir/sparse2", 10, 0o644, 0, 1024*1024*1024, 1024),
),
size: dirs(2) + align(5)*3 + align(1024),
},
{
name: "Hardlinks",
fs: fstest.Apply(
Expand All @@ -104,6 +93,21 @@ func TestUsage(t *testing.T) {
},
}...)
}
if runtime.GOOS != "windows" && runtime.GOOS != "darwin" {
testCases = append(testCases, []testCase{
{
name: "SparseFiles",
fs: fstest.Apply(
fstest.CreateDir("/dir", 0o755),
fstest.CreateRandomFile("/dir/file1", 7, 5, 0o644),
createSparseFile("/dir/sparse1", 8, 0o644, 5, 1024*1024, 5),
createSparseFile("/dir/sparse2", 9, 0o644, 0, 1024*1024),
createSparseFile("/dir/sparse2", 10, 0o644, 0, 1024*1024*1024, 1024),
),
size: dirs(2) + align(5)*3 + align(1024),
},
}...)
}

for i := range testCases {
tc := testCases[i]
Expand Down
2 changes: 1 addition & 1 deletion fs/du_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func getTmpAlign(t testing.TB) (func(int64) int64, func(int64) int64, error) {
return func(s int64) int64 {
return s
}, func(c int64) int64 {
return c * 4096
return 0
}, nil
}

Expand Down

0 comments on commit 58654a2

Please sign in to comment.