misc/cgo/testplugin: let TestMain run deferred functions
misc/cgo/testplugin: let TestMain run deferred functions

Split TestMain into two functions so that we can defer cleanups.

Updates #30500

Change-Id: I4a5c7ddb8218a8bd056c8733c3cb9feb895e77a0
Reviewed-on: https://go-review.googlesource.com/c/164859
Run-TryBot: Ian Lance Taylor <87e9c6d529889242b7e184afb632328636553ab4@golang.org>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Daniel Martí <29bf28b42a938ace12a5819da4ed4ba03d82f315@mvdan.cc>

golang/go,cloudflare/go,akutz/go,golang/go,nawawi/go,josharian/go,josharian/go,josharian/go,cloudflare/go,golang/go,akutz/go,golang/go,CAFxX/go,nawawi/go,golang/go,akutz/go,nawawi/go,CAFxX/go,nawawi/go,nawawi/go,CAFxX/go,josharian/go,CAFxX/go,golang/go,josharian/go,akutz/go,josharian/go,josharian/go,CAFxX/go,CAFxX/go,cloudflare/go,CAFxX/go,nawawi/go,akutz/go,golang/go,nawawi/go,akutz/go,nawawi/go,CAFxX/go,cloudflare/go,akutz/go,cloudflare/go,akutz/go,cloudflare/go,golang/go,josharian/go,cloudflare/go,cloudflare/go