ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/golang/1.22.0/src/cmd/go/testdata/script/test_fuzz_cleanup.txt
[!fuzz] skip
[short] skip
env GOCACHE=$WORK/cache

# Cleanup should run after F.Skip.
go test -run=FuzzTargetSkip
stdout cleanup

# Cleanup should run after F.Fatal.
! go test -run=FuzzTargetFatal
stdout cleanup

# Cleanup should run after an unexpected runtime.Goexit.
! go test -run=FuzzTargetGoexit
stdout cleanup

# Cleanup should run after panic.
! go test -run=FuzzTargetPanic
stdout cleanup

# Cleanup should run in fuzz function on seed corpus.
go test -v -run=FuzzFunction
stdout '(?s)inner.*outer'

# TODO(jayconrod): test cleanup while fuzzing. For now, the worker process's
# stdout and stderr is connected to the coordinator's, but it should eventually
# be connected to os.DevNull, so we wouldn't see t.Log output.

-- go.mod --
module cleanup

go 1.15
-- cleanup_test.go --
package cleanup

import (
	"runtime"
	"testing"
)

func FuzzTargetSkip(f *testing.F) {
	f.Cleanup(func() { f.Log("cleanup") })
	f.Skip()
}

func FuzzTargetFatal(f *testing.F) {
	f.Cleanup(func() { f.Log("cleanup") })
	f.Fatal()
}

func FuzzTargetGoexit(f *testing.F) {
	f.Cleanup(func() { f.Log("cleanup") })
	runtime.Goexit()
}

func FuzzTargetPanic(f *testing.F) {
	f.Cleanup(func() { f.Log("cleanup") })
	panic("oh no")
}

func FuzzFunction(f *testing.F) {
	f.Add([]byte{0})
	f.Cleanup(func() { f.Log("outer") })
	f.Fuzz(func(t *testing.T, b []byte) {
		t.Cleanup(func() { t.Logf("inner") })
	})
}