Support test fixtures in bpf package

Restructures the bpf package test setup code to create FixturePreparer
instances for setting up a test fixture and converts the test to use
it.

Bug: 181070625
Test: m nothing
Change-Id: I7c76ed6dc292ca92d76ef95c4167f7ca2d68e1af
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 8142f10..fa1a84d 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -26,7 +26,7 @@
 )
 
 func init() {
-	android.RegisterModuleType("bpf", BpfFactory)
+	registerBpfBuildComponents(android.InitRegistrationContext)
 	pctx.Import("android/soong/cc/config")
 }
 
@@ -43,6 +43,12 @@
 		"ccCmd", "cFlags")
 )
 
+func registerBpfBuildComponents(ctx android.RegistrationContext) {
+	ctx.RegisterModuleType("bpf", BpfFactory)
+}
+
+var PrepareForTestWithBpf = android.FixtureRegisterWithContext(registerBpfBuildComponents)
+
 // BpfModule interface is used by the apex package to gather information from a bpf module.
 type BpfModule interface {
 	android.Module