Port testing state to new gradle set up

This copies the functionality almost "as is" to the new build set
up. The automatic state path is pulled out to test.py so that the
build set up config is based on just the state directory. The
flag to remove the state is also removed from the config. Users
can delete the state directory externally if it should be removed.

The state is still written to build/test-state. This looks like it
does not work well with the new modules. Follow up work should
verify and fix the set up so it works for multiple modules.

Bug: b/297316723
Change-Id: I2e3314dcbcb42e67d47902c0e5d633ad40df7489
diff --git a/tools/utils.py b/tools/utils.py
index 96c09ea..279e1d0 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -355,6 +355,10 @@
                                      'HEAD']).decode('utf-8')
   return 'origin/main' in remotes
 
+def get_HEAD_branch():
+  result = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8')
+  return result.strip()
+
 def get_HEAD_sha1():
   return get_HEAD_sha1_for_checkout(REPO_ROOT)