From 38da27b5d1705bf3535ee4c4d30e7ed04b45475c Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Wed, 6 Nov 2024 11:45:14 +0000 Subject: [PATCH] Fix. --- .github/workflows/test.yml | 4 ++-- vfs/shm_dotlk.go | 4 ++++ vfs/shm_windows.go | 19 +++++++++---------- vfs/tests/mptest/mptest_test.go | 14 ++++++++------ 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 71705c3..772a409 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -162,8 +162,8 @@ jobs: - name: Test ppc64le (interpreter) run: GOARCH=ppc64le go test -v -short ./... - - name: Test s390x (big-endian, z/OS like) - run: GOARCH=s390x go test -v -short -tags sqlite3_flock ./... + - name: Test s390x (big-endian) + run: GOARCH=s390x go test -v -short -tags sqlite3_dotlk ./... test-vm: runs-on: ubuntu-latest diff --git a/vfs/shm_dotlk.go b/vfs/shm_dotlk.go index 51b93ee..36e00a1 100644 --- a/vfs/shm_dotlk.go +++ b/vfs/shm_dotlk.go @@ -114,6 +114,7 @@ func (s *vfsShm) shmMap(ctx context.Context, mod api.Module, id, size int32, ext defer s.Unlock() defer s.shmAcquire() + // Extend shared memory. if int(id) >= len(s.shared) { if !extend { return 0, _OK @@ -121,10 +122,13 @@ func (s *vfsShm) shmMap(ctx context.Context, mod api.Module, id, size int32, ext s.shared = append(s.shared, make([][_WALINDEX_PGSZ]byte, int(id)-len(s.shared)+1)...) } + // Allocate shadow memory. if int(id) >= len(s.shadow) { s.shadow = append(s.shadow, make([][_WALINDEX_PGSZ]byte, int(id)-len(s.shadow)+1)...) + s.shadow[0][4] = 1 // force invalidation } + // Allocate local memory. for int(id) >= len(s.ptrs) { s.stack[0] = uint64(size) if err := s.alloc.CallWithStack(ctx, s.stack[:]); err != nil { diff --git a/vfs/shm_windows.go b/vfs/shm_windows.go index c821de7..218d8e2 100644 --- a/vfs/shm_windows.go +++ b/vfs/shm_windows.go @@ -94,21 +94,20 @@ func (s *vfsShm) shmMap(ctx context.Context, mod api.Module, id, size int32, ext } } - // Map the region into memory. - r, err := util.MapRegion(ctx, mod, s.File, int64(id)*int64(size), size) - if err != nil { - return 0, _IOERR_SHMMAP - } - s.regions = append(s.regions, r) - - if int(id) >= len(s.shared) { - s.shared = append(s.shared, make([][]byte, int(id)-len(s.shared)+1)...) + // Maps regions into memory. + for int(id) >= len(s.shared) { + r, err := util.MapRegion(ctx, mod, s.File, int64(id)*int64(size), size) + if err != nil { + return 0, _IOERR_SHMMAP + } + s.regions = append(s.regions, r) + s.shared = append(s.shared, r.Data) } - s.shared[id] = r.Data // Allocate shadow memory. if int(id) >= len(s.shadow) { s.shadow = append(s.shadow, make([][_WALINDEX_PGSZ]byte, int(id)-len(s.shadow)+1)...) + s.shadow[0][4] = 1 // force invalidation } // Allocate local memory. diff --git a/vfs/tests/mptest/mptest_test.go b/vfs/tests/mptest/mptest_test.go index 53a90fc..76f2769 100644 --- a/vfs/tests/mptest/mptest_test.go +++ b/vfs/tests/mptest/mptest_test.go @@ -35,6 +35,8 @@ var compressed string //go:embed testdata/*.*test var scripts embed.FS +const qemuCI = runtime.GOARCH != "386" && runtime.GOARCH != "amd64" && runtime.GOARCH != "arm64" + var ( rt wazero.Runtime module wazero.CompiledModule @@ -160,8 +162,8 @@ func Test_crash01(t *testing.T) { } func Test_multiwrite01(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") + if os.Getenv("CI") != "" && qemuCI { + t.Skip("skipping in CI") } if !vfs.SupportsFileLocking { t.Skip("skipping without locks") @@ -190,8 +192,8 @@ func Test_config01_memory(t *testing.T) { } func Test_multiwrite01_memory(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") + if os.Getenv("CI") != "" && qemuCI { + t.Skip("skipping in CI") } memdb.Create("test.db", nil) @@ -225,8 +227,8 @@ func Test_crash01_wal(t *testing.T) { } func Test_multiwrite01_wal(t *testing.T) { - if testing.Short() { - t.Skip("skipping in short mode") + if os.Getenv("CI") != "" && qemuCI { + t.Skip("skipping in CI") } if !vfs.SupportsSharedMemory { t.Skip("skipping without shared memory")