mirror of
https://github.com/Cheviiot/Vintner.git
synced 2026-08-03 15:57:24 +00:00
Fix toolrelay.exe's mt.exe detection: it never matched a real path
IsMtExe() looked for the last '\\' in the target executable path to find the bare filename, but vintner passes toolExePath straight from Go's filepath.Join (forward slashes) all the way through to CreateProcessW - so the path toolrelay.exe actually receives has no backslash in it at all, and IsMtExe() compared the *entire path* against "mt.exe", which of course never matched. The whole point of this file - translating mt.exe's CMake-compatibility exit code (0x41020001 -> 0xbb) before Wine's own exit-code truncation destroys it - has silently never fired in real usage. This had gone unnoticed because MSBuild's rawStdout path bypasses toolrelay.exe entirely, and every real end-to-end test so far (msbuild-driven builds, including the KMDF driver) went through that path. Found while getting a CMake+Ninja-generated MSVC build of a real project (Ogre3D) past its `cmake -E vs_link_exe` manifest step, which depends on exactly this translation. Now checks for both '\\' and '/' and uses whichever separator occurs last in the path. Verified directly: `mt /manifest ... /notify_update` through the wrapper now exits 187 (0xbb) instead of 1, and the Ogre build gets past the manifest-embedding step it was failing at.
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
package download
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWDKNuGetID(t *testing.T) {
|
||||
for _, tc := range []struct{ arch, want string }{
|
||||
{"x64", "Microsoft.Windows.WDK.x64"},
|
||||
{"x86", "Microsoft.Windows.WDK.x64"}, // no 32-bit package exists
|
||||
{"arm64", "Microsoft.Windows.WDK.ARM64"},
|
||||
} {
|
||||
if got := WDKNuGetID(tc.arch); got != tc.want {
|
||||
t.Errorf("WDKNuGetID(%q) = %q, want %q", tc.arch, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSDKBuildPrefix(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
selected []*Package
|
||||
want string
|
||||
}{
|
||||
{"no SDK package", []*Package{{ID: "Something.Else"}}, ""},
|
||||
{"win10sdk", []*Package{{ID: "Win10SDK_10.0.26100", Version: "10.0.26100.1742"}}, "10.0.26100"},
|
||||
{"win11sdk case-insensitive id", []*Package{{ID: "WIN11SDK_10.0.22621", Version: "10.0.22621.5"}}, "10.0.22621"},
|
||||
{"short version", []*Package{{ID: "Win10SDK_x", Version: "10.0"}}, ""},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := SDKBuildPrefix(tc.selected); got != tc.want {
|
||||
t.Errorf("SDKBuildPrefix(...) = %q, want %q", got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFillMissingHostToolsCopiesWithoutOverwriting(t *testing.T) {
|
||||
cDir := t.TempDir()
|
||||
writeFile(t, filepath.Join(cDir, "bin", "10.0.26100.0", "x64", "stampinf.exe"), "x64-stampinf")
|
||||
writeFile(t, filepath.Join(cDir, "bin", "10.0.26100.0", "x64", "inf2cat.exe"), "x64-inf2cat")
|
||||
// x86 already ships its own real inf2cat.exe - must not be clobbered.
|
||||
writeFile(t, filepath.Join(cDir, "bin", "10.0.26100.0", "x86", "inf2cat.exe"), "real-x86-inf2cat")
|
||||
|
||||
if err := fillMissingHostTools(cDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
x86Dir := filepath.Join(cDir, "bin", "10.0.26100.0", "x86")
|
||||
stampinf, err := os.ReadFile(filepath.Join(x86Dir, "stampinf.exe"))
|
||||
if err != nil {
|
||||
t.Fatalf("expected stampinf.exe to be copied into x86: %v", err)
|
||||
}
|
||||
if string(stampinf) != "x64-stampinf" {
|
||||
t.Errorf("copied stampinf.exe content = %q, want the x64 copy's content", stampinf)
|
||||
}
|
||||
|
||||
inf2cat, err := os.ReadFile(filepath.Join(x86Dir, "inf2cat.exe"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(inf2cat) != "real-x86-inf2cat" {
|
||||
t.Errorf("inf2cat.exe = %q, want the original x86 file preserved (not overwritten by the x64 copy)", inf2cat)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFillMissingHostToolsNoBinDirIsNoop(t *testing.T) {
|
||||
if err := fillMissingHostTools(t.TempDir()); err != nil {
|
||||
t.Fatalf("missing bin/ dir should be a no-op, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDuplicateVersionedBuildTaskAssemblies(t *testing.T) {
|
||||
cDir := t.TempDir()
|
||||
buildDir := filepath.Join(cDir, "build")
|
||||
writeFile(t, filepath.Join(buildDir, "Microsoft.DriverKit.Build.Tasks.17.0.dll"), "task-dll-bytes")
|
||||
writeFile(t, filepath.Join(buildDir, "Microsoft.DriverKit.Build.Tasks.18.0.dll"), "already-there")
|
||||
writeFile(t, filepath.Join(buildDir, "unrelated.dll"), "unrelated")
|
||||
|
||||
if err := duplicateVersionedBuildTaskAssemblies(cDir, "18.0"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Already had an 18.0 copy - must not have been overwritten.
|
||||
got, err := os.ReadFile(filepath.Join(buildDir, "Microsoft.DriverKit.Build.Tasks.18.0.dll"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(got) != "already-there" {
|
||||
t.Errorf("pre-existing 18.0 dll was overwritten: got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDuplicateVersionedBuildTaskAssembliesCreatesMissingCopy(t *testing.T) {
|
||||
cDir := t.TempDir()
|
||||
buildDir := filepath.Join(cDir, "build")
|
||||
writeFile(t, filepath.Join(buildDir, "sub", "Foo.Bar.17.0.dll"), "bytes")
|
||||
|
||||
if err := duplicateVersionedBuildTaskAssemblies(cDir, "18.0"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
got, err := os.ReadFile(filepath.Join(buildDir, "sub", "Foo.Bar.18.0.dll"))
|
||||
if err != nil {
|
||||
t.Fatalf("expected a Foo.Bar.18.0.dll duplicate: %v", err)
|
||||
}
|
||||
if string(got) != "bytes" {
|
||||
t.Errorf("duplicated dll content = %q, want %q", got, "bytes")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDuplicateVersionedBuildTaskAssembliesNoBuildDirIsNoop(t *testing.T) {
|
||||
if err := duplicateVersionedBuildTaskAssemblies(t.TempDir(), "18.0"); err != nil {
|
||||
t.Fatalf("missing build/ dir should be a no-op, got: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user