Documentation
¶
Overview ¶
Package winetest is the harness of the tests that run a Windows program under Wine (SPEC §25.13): it makes the Wine prefix in .wine-test/prefix at the module root (with the workaround for the first boot, under a lock), starts a headless X server (scripts/headless-x11.sh) and the program under `timeout -k`, in a process group of its own and with the environment of §25.13, stops everything with `wineserver -k`, and finds what is left (Leftovers reads /proc).
The harness runs on Linux: the tests of the packages that need Windows run inside Wine with scripts/wine-exec.sh (go test -exec), and the tests of this package, of cmd/glutter-windows and of the examples start Wine themselves. On Windows the package has only UnderWine, which tells a test whether it runs under Wine.
Flutter: no counterpart (flutter drive)
Index ¶
- Constants
- func Leftovers(root string) []string
- func PrefixDir(root string, environ []string) string
- type Command
- type Harness
- func (h *Harness) Capture(ctx context.Context, exe, out string, opts RunOptions) (Result, error)
- func (h *Harness) EnsurePrefix(ctx context.Context) error
- func (h *Harness) Environment(extra ...string) []string
- func (h *Harness) Run(ctx context.Context, exe string, opts RunOptions) (Result, error)
- func (h *Harness) Stop(ctx context.Context) error
- type Result
- type RunOptions
- type Runner
Constants ¶
const ( // WineInstall installs Wine on Fedora. // // Flutter: no counterpart WineInstall = "sudo dnf install wine-core" // XvfbInstall installs the headless X server on Fedora. // // Flutter: no counterpart XvfbInstall = "sudo dnf install xorg-x11-server-Xvfb" )
WineInstall and XvfbInstall are the commands that install what the harness needs.
const ( // TagWineNotFound is the tag of the error for a Wine that is not installed; the metadata // "install" has the command. TagWineNotFound = "WineNotFound" // TagWinePrefixFailed is the tag of the error for a prefix that cannot be made. TagWinePrefixFailed = "WinePrefixFailed" // TagWineStartFailed is the tag of the error for a program, a server or a display that cannot // be started. TagWineStartFailed = "WineStartFailed" )
The tags of the errors that this file makes (rm4n0s/errors, R5).
const DebugEnv = "GLUTTER_WINEDEBUG"
DebugEnv names the environment variable that sets WINEDEBUG (the default is -all).
Flutter: no counterpart
const PrefixEnv = "GLUTTER_WINEPREFIX"
PrefixEnv names the environment variable that moves the Wine prefix, as scripts/wine-exec.sh reads it.
Flutter: no counterpart
Variables ¶
This section is empty.
Functions ¶
func Leftovers ¶
Leftovers lists the processes (as "pid command") that were started with the Wine prefix of the module at root (WINEPREFIX in their environment): Wine, its server, winedevice, the headless X server and what they started. A test checks that there are none after it stopped Wine. The prefix is root/.wine-test/prefix, or the value of GLUTTER_WINEPREFIX. It reads /proc.
Flutter: no counterpart
Types ¶
type Command ¶
type Command struct {
// Argv is the program and its arguments.
Argv []string
// Env is the whole environment of the process (KEY=value).
Env []string
// Dir is the working directory; empty means the current one.
Dir string
}
Command is a command line for the Runner: the program and its arguments, the environment, and the directory.
Flutter: no counterpart
type Harness ¶
type Harness struct {
// Root is the module root; the prefix and the scripts are below it.
Root string
// Prefix is the Wine prefix (WINEPREFIX): Root/.wine-test/prefix, or the value of GLUTTER_WINEPREFIX.
Prefix string
// Environ is the environment the commands start from; New sets it to os.Environ().
Environ []string
// LookPath finds a program; New sets it to exec.LookPath.
LookPath func(string) (string, error)
// Stat tells whether a file exists; New sets it to os.Stat.
Stat func(string) (os.FileInfo, error)
// Exec runs the commands; New sets it to the real runner.
Exec Runner
}
Harness starts Windows programs under Wine. The zero value is not usable: make it with New.
Flutter: no counterpart
func New ¶
New makes a Harness for the module at root (found from the working directory when empty). The prefix is root/.wine-test/prefix unless GLUTTER_WINEPREFIX is set. It fails with ModuleRootNotFound when no go.mod is above the working directory.
Flutter: no counterpart
func (*Harness) Capture ¶
Capture starts the Windows program exe under Wine on a headless X server, as Run does, and saves the root window of the server to the PNG file out after GLUTTER_SHOT_DELAY seconds (3 unless the environment of opts says another value), with scripts/wine-screenshot.sh (proof method F, SPEC §25.13): it shows what lies outside the program's own window, such as a dialog. The script ends the program afterwards. A script status other than 0 (the program ended before the capture, or the capture failed) is in the Result. opts.OnDisplay is ignored. It fails as Run does.
Flutter: no counterpart
func (*Harness) EnsurePrefix ¶
EnsurePrefix makes the Wine prefix if it is not there (system.reg is its mark), under a lock file, so that tests of different packages that start together make it once. The first boot of a new prefix hangs when the wine-cms package is not installed (setupapi loops on the missing mscms.dll), so the boot is cut after 20 seconds and the server stopped: `timeout 20 wine wineboot --init`, then `wineserver -k` (SPEC §25.13). It fails with WineNotFound, and with WinePrefixFailed when the prefix is still not there afterwards.
Flutter: no counterpart
func (*Harness) Environment ¶
Environment is the environment of a Wine command (SPEC §25.13): the environment of the harness without WAYLAND_DISPLAY and WAYLAND_SOCKET, plus WINEPREFIX, WINEARCH=win64, WINEDLLOVERRIDES ("mscoree,mshtml=", so that Wine does not offer to download Mono or Gecko), WINEDEBUG (-all unless GLUTTER_WINEDEBUG is set) and VK_DRIVER_FILES pointing at lavapipe's ICD when that file exists and the variable is not set. extra are added last (KEY=value).
Flutter: no counterpart
func (*Harness) Run ¶
Run starts the Windows program exe under Wine on a headless X server and waits for it. The prefix is made first if it is not there. The Result has the exit code and the output of the program. A non-zero exit code is not an error: the test reads it. Wine and the server are stopped afterwards with `wineserver -k`, also when ctx ends the run early. It fails with WineNotFound, with WinePrefixFailed, and with WineStartFailed when the process cannot be started or ctx ends.
Flutter: no counterpart
type Result ¶
type Result struct {
// ExitCode is the exit status of the command; 124 means that `timeout` ended it.
ExitCode int
// Output is the standard output and the standard error together.
Output string
}
Result is what a command left.
Flutter: no counterpart
type RunOptions ¶
type RunOptions struct {
// Args are the arguments of the program.
Args []string
// Env are more environment variables (KEY=value), such as GLUTTER_SCREENSHOT=...
Env []string
// Dir is the working directory of the program; empty means the module root.
Dir string
// Timeout is how long the program may run; zero means 120 seconds. When it passes, `timeout`
// ends the program and the exit code is 124.
Timeout time.Duration
// OnDisplay starts the program on the display of the environment (DISPLAY) instead of a headless
// X server: the window shows on the user's screen. Tests never set it; `glutter-windows run`
// does when it is not given -headless.
OnDisplay bool
}
RunOptions are the optional parts of Run.
Flutter: no counterpart