[autotest] Make SERVER_JOB failures dedupe better by excluding the build name from the anchor

Remove build and suite name from the test name that used to form anchor when
deduping server job failure.

BUG=chromium:310148
TEST=unitest, test with bug filing:
./run_suite.py --build=trybot-lumpy-paladin/R33-4997.0.0-b1385  --board=lumpy
--suite_name=dummy -f True
old behavior:
https://code.google.com/p/autotest-bug-filing-test/issues/detail?id=1883

new behavior:
https://code.google.com/p/autotest-bug-filing-test/issues/detail?id=1880

Change-Id: I41ad7405aaca3fd5d99cae1bcc1b7ed58fda6e8e
Reviewed-on: https://chromium-review.googlesource.com/175623
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/server/cros/dynamic_suite/tools.py b/server/cros/dynamic_suite/tools.py
index 374af59..1ffb59d 100644
--- a/server/cros/dynamic_suite/tools.py
+++ b/server/cros/dynamic_suite/tools.py
@@ -234,3 +234,30 @@
     bug_count = keyvals.get(keyval_base + _BUG_COUNT_KEYVAL)
     bug_count = int(bug_count) if bug_count else None
     return bug_id, bug_count
+
+
+def create_job_name(build, suite, test_name):
+    """Create the name of a test job based on given build, suite, and test_name.
+
+    @param build: name of the build, e.g., lumpy-release/R31-1234.0.0.
+    @param suite: name of the suite, e.g., bvt.
+    @param test_name: name of the test, e.g., dummy_Pass.
+    @return: the test job's name, e.g.,
+             lumpy-release/R31-1234.0.0/bvt/dummy_Pass.
+    """
+    return '/'.join([build, suite, test_name])
+
+
+def get_test_name(build, suite, test_job_name):
+    """Get the test name from test job name.
+
+    Name of test job may contain information like build and suite. This method
+    strips these information and return only the test name.
+
+    @param build: name of the build, e.g., lumpy-release/R31-1234.0.0.
+    @param suite: name of the suite, e.g., bvt.
+    @param test_job_name: name of the test job, e.g.,
+                          lumpy-release/R31-1234.0.0/bvt/dummy_Pass_SERVER_JOB.
+    @return: the test name, e.g., dummy_Pass_SERVER_JOB.
+    """
+    return test_job_name.replace('%s/%s/' % (build, suite), '')
\ No newline at end of file