vts sysfuzzer common lib - fuzz tester

Change-Id: Ia401c74f54d185a2054a47053fd94d52e66f128d
diff --git a/sysfuzzer/common/fuzz_tester/FuzzerBase.cpp b/sysfuzzer/common/fuzz_tester/FuzzerBase.cpp
new file mode 100644
index 0000000..48eb715
--- /dev/null
+++ b/sysfuzzer/common/fuzz_tester/FuzzerBase.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "fuzz_tester/FuzzerBase.h"
+
+#include <string>
+#include <iostream>
+
+#include "test/vts/sysfuzzer/common/proto/InterfaceSpecificationMessage.pb.h"
+
+#include "component_loader/DllLoader.h"
+#include "utils/InterfaceSpecUtil.h"
+
+using namespace std;
+using namespace android;
+
+namespace android {
+namespace vts {
+
+FuzzerBase::FuzzerBase() {}
+
+
+FuzzerBase::~FuzzerBase() {}
+
+
+bool FuzzerBase::LoadTargetComponent(const char* target_dll_path) {
+  target_dll_path_ = target_dll_path;
+  if (!target_loader_.Load(target_dll_path_)) return false;
+  return (device_ = target_loader_.GetHWDevice()) != NULL;
+}
+
+
+bool FuzzerBase::Fuzz(const vts::InterfaceSpecificationMessage& message) {
+  cout << "Fuzzing target component: "
+      << "class " << message.component_class()
+      << " type " << message.component_type()
+      << " version " << message.component_type_version() << endl;
+
+  string function_name_prefix = GetFunctionNamePrefix(message);
+  function_name_prefix_ = function_name_prefix.c_str();
+  for (const vts::FunctionSpecificationMessage& func_msg : message.api()) {
+    Fuzz(func_msg);
+  }
+  return true;
+}
+
+}  // namespace vts
+}  // namespace android