mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 06:13:42 +00:00
fix(windows): release FFmpeg memory and capture native crashes (#1668)
This commit is contained in:
17 files changed
+486
-17
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package download
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLogPanicPreservesPreviousCrash(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "crash.log")
|
||||
const previous = "previous crash traceback\n"
|
||||
if err := os.WriteFile(path, []byte(previous), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
logPanic(dir)
|
||||
t.Cleanup(func() { _ = debug.SetCrashOutput(nil, debug.CrashOptions{}) })
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(data) != previous {
|
||||
t.Fatalf("previous crash was overwritten: %q", data)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user