When running locally *TS with lunch set

--module is searching for all files based on a pattern in a
directory which results in several files found because of
the ANDROID_HOST_OUT copy in tests dir.
Deduping the files when looking for modules in directories.

Test: unit tests
run gts-dev -m GtsGmscoreHostTestCases with and without lunch
Bug: 73290763

Change-Id: I7f23adb96b5e25888075aeb619da32b15baf7e20
diff --git a/src/com/android/tradefed/config/ConfigurationUtil.java b/src/com/android/tradefed/config/ConfigurationUtil.java
index 790914e..639173c 100644
--- a/src/com/android/tradefed/config/ConfigurationUtil.java
+++ b/src/com/android/tradefed/config/ConfigurationUtil.java
@@ -201,6 +201,22 @@
                 CLog.w("Failed to get test config files from directory %s", dir.getAbsolutePath());
             }
         }
-        return configNames;
+        return dedupFiles(configNames);
+    }
+
+    /**
+     * From a same tests dir we only expect a single instance of each names, so we dedup the files
+     * if that happens.
+     */
+    private static Set<File> dedupFiles(Set<File> origSet) {
+        Set<String> tracker = new HashSet<>();
+        Set<File> newSet = new HashSet<>();
+        for (File f : origSet) {
+            if (!tracker.contains(f.getName())) {
+                tracker.add(f.getName());
+                newSet.add(f);
+            }
+        }
+        return newSet;
     }
 }