Camera2: Automated tests for testing HAL2.0 interface

Change-Id: I1f1afd5afc346d5493d5019af35c3026efcf19b5
diff --git a/tests/camera2/camera2_utils.cpp b/tests/camera2/camera2_utils.cpp
index cefe29a..166ac52 100644
--- a/tests/camera2/camera2_utils.cpp
+++ b/tests/camera2/camera2_utils.cpp
@@ -21,8 +21,11 @@
 
 #include "utils/Log.h"
 #include "camera2_utils.h"
+#include <dlfcn.h>
 
 namespace android {
+namespace camera2 {
+namespace tests {
 
 /**
  * MetadataQueue
@@ -578,4 +581,22 @@
     mCondition.signal();
 }
 
+int HWModuleHelpers::closeModule(hw_module_t* module) {
+    int status;
+
+    if (!module) {
+        return -EINVAL;
+    }
+
+    status = dlclose(module->dso);
+    if (status != 0) {
+        char const *err_str = dlerror();
+        ALOGE("%s dlclose failed, error: %s", __func__, err_str ?: "unknown");
+    }
+
+    return status;
+}
+
+} // namespace tests
+} // namespace camera2
 } // namespace android