From 6545add45f54e00e86aaa92754fe290b3fe17304 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Sun, 13 Sep 2026 17:21:09 +0200 Subject: [PATCH] internal/gamepad: drop the inotify test, as requested in review --- internal/gamepad/export_linux_test.go | 8 --- internal/gamepad/gamepad_linux_test.go | 74 -------------------------- 2 files changed, 82 deletions(-) delete mode 100644 internal/gamepad/gamepad_linux_test.go diff --git a/internal/gamepad/export_linux_test.go b/internal/gamepad/export_linux_test.go index f58e2f3..24090a2 100644 --- a/internal/gamepad/export_linux_test.go +++ b/internal/gamepad/export_linux_test.go @@ -23,11 +23,3 @@ const ( FFEffectUnionOffset = unsafe.Offsetof(ff_effect{}.u) FFEffectRumbleOffset = unsafe.Offsetof(ff_effect{}.u) + unsafe.Offsetof(ff_effect_union{}.rumble) ) - -const DirName = dirName - -// InitNativeGamepadsForTest initializes the device-polling backend, as the first [Update] does. -func InitNativeGamepadsForTest() error { - var gs gamepads - return newNativeGamepadsImpl().init(&gs) -} diff --git a/internal/gamepad/gamepad_linux_test.go b/internal/gamepad/gamepad_linux_test.go deleted file mode 100644 index 7144d08..0000000 --- a/internal/gamepad/gamepad_linux_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2026 The Ebitengine Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !android && !nintendosdk && !playstation5 - -package gamepad_test - -import ( - "os" - "strconv" - "strings" - "testing" - - "golang.org/x/sys/unix" - - "github.com/hajimehoshi/ebiten/v2/internal/gamepad" -) - -// TestInitWithoutInotify verifies that initialization succeeds when no inotify instance can be -// created, because another program of the same user took them all (#3304). -func TestInitWithoutInotify(t *testing.T) { - if _, err := os.Stat(gamepad.DirName); err != nil { - t.Skipf("%s is not available, initialization never reaches inotify", gamepad.DirName) - } - - // Reading the limit up front bounds the loop below and keeps file descriptors to spare. - var rlimit unix.Rlimit - if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil { - t.Skipf("unix.Getrlimit: %v", err) - } - content, err := os.ReadFile("/proc/sys/fs/inotify/max_user_instances") - if err != nil { - t.Skipf("os.ReadFile: %v", err) - } - limit, err := strconv.Atoi(strings.TrimSpace(string(content))) - if err != nil { - t.Skipf("strconv.Atoi: %v", err) - } - if uint64(limit)+256 > uint64(rlimit.Cur) { - t.Skipf("fs.inotify.max_user_instances is %d, too close to the file descriptor limit %d to exhaust", limit, rlimit.Cur) - } - - var held []int - defer func() { - for _, fd := range held { - _ = unix.Close(fd) - } - }() - for len(held) <= limit { - fd, err := unix.InotifyInit1(unix.IN_NONBLOCK | unix.IN_CLOEXEC) - if err != nil { - break - } - held = append(held, fd) - } - if len(held) > limit { - t.Skip("could not exhaust the inotify instances of this user") - } - - if err := gamepad.InitNativeGamepadsForTest(); err != nil { - t.Errorf("gamepad.InitNativeGamepadsForTest(): got: %v, want: nil", err) - } -}