unit_test: allow targets to specify their own test main

This allows having test-specific, per-target init logic.
Kept the existing test main as default.

Change-Id: I418dc4f9eefe0bc9d66fcb24d6c4573757f37144
diff --git a/pw_preprocessor/BUILD.gn b/pw_preprocessor/BUILD.gn
index 4bd8742..6c197fb 100644
--- a/pw_preprocessor/BUILD.gn
+++ b/pw_preprocessor/BUILD.gn
@@ -55,7 +55,6 @@
   pw_test(target_name) {
     deps = [
       ":pw_preprocessor",
-      "$dir_pw_unit_test:main",
     ]
     sources = [
       "$target_name.cc",
diff --git a/pw_span/BUILD.gn b/pw_span/BUILD.gn
index 52ed013..e28e253 100644
--- a/pw_span/BUILD.gn
+++ b/pw_span/BUILD.gn
@@ -36,7 +36,6 @@
 pw_test("test") {
   deps = [
     ":pw_span",
-    "$dir_pw_unit_test:main",
   ]
   sources = [
     "span_test.cc",
diff --git a/pw_status/BUILD.gn b/pw_status/BUILD.gn
index c358931..6757fd8 100644
--- a/pw_status/BUILD.gn
+++ b/pw_status/BUILD.gn
@@ -40,7 +40,6 @@
 pw_test("status_test") {
   deps = [
     ":pw_status",
-    "$dir_pw_unit_test:main",
   ]
   sources = [
     "status_test.cc",
@@ -50,7 +49,6 @@
 pw_test("status_with_size_test") {
   deps = [
     ":pw_status",
-    "$dir_pw_unit_test:main",
   ]
   sources = [
     "status_with_size_test.cc",
diff --git a/pw_string/BUILD.gn b/pw_string/BUILD.gn
index 46938c4..3221e02 100644
--- a/pw_string/BUILD.gn
+++ b/pw_string/BUILD.gn
@@ -57,7 +57,6 @@
 pw_test("format_test") {
   deps = [
     ":pw_string",
-    "$dir_pw_unit_test:main",
   ]
   sources = [
     "format_test.cc",
@@ -67,7 +66,6 @@
 pw_test("to_string_test") {
   deps = [
     ":pw_string",
-    "$dir_pw_unit_test:main",
   ]
   sources = [
     "to_string_test.cc",
@@ -77,7 +75,6 @@
 pw_test("type_to_string_test") {
   deps = [
     ":pw_string",
-    "$dir_pw_unit_test:main",
   ]
   sources = [
     "type_to_string_test.cc",
diff --git a/pw_unit_test/test.gni b/pw_unit_test/test.gni
index 2f5654a..7893f8a 100644
--- a/pw_unit_test/test.gni
+++ b/pw_unit_test/test.gni
@@ -42,6 +42,11 @@
     }
 
     forward_variables_from(invoker, "*", [ "metadata" ])
+
+    if (!defined(deps)) {
+      deps = []
+    }
+    deps += [ pw_unit_test_main ]
   }
 
   if (pw_unit_test_create_run_targets) {