mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 18:19:07 +01:00
Substring version checks admitted stale agents and dependency literals, while ARMv6 executables could select ARMv7 updates. Share compiler target and exact release identity admission across producers, downloads and activation, and keep validated local downloads bound to their open file descriptor. Cover bounded runtime probes, failure atomicity, canonical executable formats, ARM emulation and saved-state installer repair boundaries. Retain the installed ARM fleet and physical-device gap, and leave release qualification open.
64 lines
2.4 KiB
Go
64 lines
2.4 KiB
Go
package agentupdate
|
|
|
|
import "context"
|
|
|
|
// PerformUpdateWithExecPathForTest runs the real update path while suppressing
|
|
// the process restart side effect so integration tests can inspect the result.
|
|
func PerformUpdateWithExecPathForTest(u *Updater, ctx context.Context, execPath string) error {
|
|
origRestart := restartProcessFn
|
|
origSelfTest := u.selfTestFn
|
|
origIdentity := u.verifyIdentityFn
|
|
restartProcessFn = func(string) error { return nil }
|
|
u.verifyIdentityFn = func(context.Context, string, string, string) error { return nil }
|
|
u.selfTestFn = func(context.Context, string) error { return nil }
|
|
defer func() {
|
|
restartProcessFn = origRestart
|
|
u.selfTestFn = origSelfTest
|
|
u.verifyIdentityFn = origIdentity
|
|
}()
|
|
return u.performUpdateWithExecPathForVersion(ctx, execPath, "6.0.0")
|
|
}
|
|
|
|
// WithExecutablePathForTest temporarily points update-info lookups at the
|
|
// supplied executable path so tests can exercise the real one-shot handoff.
|
|
func WithExecutablePathForTest(execPath string, fn func()) {
|
|
origExec := osExecutableFn
|
|
origEval := evalSymlinksFn
|
|
osExecutableFn = func() (string, error) { return execPath, nil }
|
|
evalSymlinksFn = func(string) (string, error) { return execPath, nil }
|
|
defer func() {
|
|
osExecutableFn = origExec
|
|
evalSymlinksFn = origEval
|
|
}()
|
|
fn()
|
|
}
|
|
|
|
// UseExecPathForUpdateChecksForTest wires CheckAndUpdate to the real update
|
|
// implementation while forcing a deterministic executable path.
|
|
func UseExecPathForUpdateChecksForTest(u *Updater, execPath string) func() {
|
|
origPerform := u.performUpdateFn
|
|
origExec := osExecutableFn
|
|
origEval := evalSymlinksFn
|
|
origRestart := restartProcessFn
|
|
origSelfTest := u.selfTestFn
|
|
origIdentity := u.verifyIdentityFn
|
|
|
|
osExecutableFn = func() (string, error) { return execPath, nil }
|
|
evalSymlinksFn = func(string) (string, error) { return execPath, nil }
|
|
restartProcessFn = func(string) error { return nil }
|
|
u.verifyIdentityFn = func(context.Context, string, string, string) error { return nil }
|
|
u.selfTestFn = func(context.Context, string) error { return nil }
|
|
u.performUpdateFn = func(ctx context.Context, targetVersion string) error {
|
|
return u.performUpdateWithExecPathForVersion(ctx, execPath, targetVersion)
|
|
}
|
|
|
|
return func() {
|
|
u.performUpdateFn = origPerform
|
|
u.selfTestFn = origSelfTest
|
|
u.verifyIdentityFn = origIdentity
|
|
osExecutableFn = origExec
|
|
evalSymlinksFn = origEval
|
|
restartProcessFn = origRestart
|
|
}
|
|
}
|