Add unit test for the lock management

- The idea behind this commit is to enable the unit test
for the lock management algorithm, and below are the unit
test cases that are written:

Testedby:

[----------] 20 tests from locktest
[ RUN      ] locktest.ValidationGoodTestCase
[       OK ] locktest.ValidationGoodTestCase (3 ms)
[ RUN      ] locktest.ValidationBadTestWithLocktype
[       OK ] locktest.ValidationBadTestWithLocktype (1 ms)
[ RUN      ] locktest.ValidationBadTestWithlockFlags
[       OK ] locktest.ValidationBadTestWithlockFlags (0 ms)
[ RUN      ] locktest.ValidationBadTestWithSegmentlength
[       OK ] locktest.ValidationBadTestWithSegmentlength (1 ms)
[ RUN      ] locktest.MultiRequestWithoutConflict
[       OK ] locktest.MultiRequestWithoutConflict (3 ms)
[ RUN      ] locktest.MultiRequestWithConflictduetoSameSegmentLength
[       OK ] locktest.MultiRequestWithConflictduetoSameSegmentLength (2 ms)
[ RUN      ] locktest.MultiRequestWithoutConflictduetoDifferentSegmentData
[       OK ] locktest.MultiRequestWithoutConflictduetoDifferentSegmentData (1 ms)
[ RUN      ] locktest.MultiRequestWithConflictduetoSameSegmentData
[       OK ] locktest.MultiRequestWithConflictduetoSameSegmentData (2 ms)
[ RUN      ] locktest.MultiRequestWithoutConflictduetoDifferentSegmentLength
[       OK ] locktest.MultiRequestWithoutConflictduetoDifferentSegmentLength (1 ms)
[ RUN      ] locktest.MultiRequestWithoutConflictduetoReadLocktype
[       OK ] locktest.MultiRequestWithoutConflictduetoReadLocktype (1 ms)
[ RUN      ] locktest.MultiRequestWithoutConflictduetoReadLocktypeAndLockall
[       OK ] locktest.MultiRequestWithoutConflictduetoReadLocktypeAndLockall (2 ms)
[ RUN      ] locktest.RequestConflictedWithLockTableEntries
[       OK ] locktest.RequestConflictedWithLockTableEntries (6 ms)
[ RUN      ] locktest.RequestNotConflictedWithLockTableEntries
[       OK ] locktest.RequestNotConflictedWithLockTableEntries (3 ms)
[ RUN      ] locktest.TestGenerateTransactionIDFunction
[       OK ] locktest.TestGenerateTransactionIDFunction (1 ms)
[ RUN      ] locktest.ValidateTransactionIDsGoodTestCase
[       OK ] locktest.ValidateTransactionIDsGoodTestCase (3 ms)
[ RUN      ] locktest.ValidateTransactionIDsBadTestCase
[       OK ] locktest.ValidateTransactionIDsBadTestCase (2 ms)
[ RUN      ] locktest.ValidateisItMyLockGoodTestCase
[       OK ] locktest.ValidateisItMyLockGoodTestCase (2 ms)
[ RUN      ] locktest.ValidateisItMyLockBadTestCase
[       OK ] locktest.ValidateisItMyLockBadTestCase (2 ms)
[ RUN      ] locktest.ValidateSessionIDForGetlocklistBadTestCase
[       OK ] locktest.ValidateSessionIDForGetlocklistBadTestCase (3 ms)
[ RUN      ] locktest.ValidateSessionIDForGetlocklistGoodTestCase
[       OK ] locktest.ValidateSessionIDForGetlocklistGoodTestCase (3 ms)
[----------] 20 tests from locktest (82 ms total)

Signed-off-by: manojkiraneda <manojkiran.eda@gmail.com>
Change-Id: Id274ee356adfa7ba03da02d83b609d37c8c99f8d
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index 79079c4..3c4f8ec 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -1,5 +1,7 @@
 #pragma once
 
+#include <logging.h>
+
 #include <boost/algorithm/string.hpp>
 #include <boost/container/flat_map.hpp>
 #include <boost/endian/conversion.hpp>
@@ -43,69 +45,6 @@
     boost::container::flat_map<uint32_t, LockRequests> lockTable;
 
     /*
-     * This function implements the logic for validating an incoming
-     * lock request/requests.
-     *
-     * Returns : True (if Valid)
-     * Returns : False (if not a Valid lock request)
-     */
-
-    bool isValidLockRequest(const LockRequest);
-
-    /*
-     * This function implements the logic of checking if the incoming
-     * multi-lock request is not having conflicting requirements.
-     *
-     * Returns : True (if conflicting)
-     * Returns : False (if not conflicting)
-     */
-
-    bool isConflictRequest(const LockRequests);
-    /*
-     * Implements the core algorithm to find the conflicting
-     * lock requests.
-     *
-     * This functions takes two lock requests and check if both
-     * are conflicting to each other.
-     *
-     * Returns : True (if conflicting)
-     * Returns : False (if not conflicting)
-     */
-    bool isConflictRecord(const LockRequest, const LockRequest);
-
-    /*
-     * This function implements the logic of checking the conflicting
-     * locks from a incoming single/multi lock requests with the already
-     * existing lock request in the lock table.
-     *
-     */
-
-    Rc isConflictWithTable(const LockRequests);
-    /*
-     * This function implements the logic of checking the ownership of the
-     * lock from the releaselock request.
-     *
-     * Returns : True (if the requesting HMC & Session owns the lock(s))
-     * Returns : False (if the request HMC or Session does not own the lock(s))
-     */
-
-    RcRelaseLock isItMyLock(const ListOfTransactionIds &, const SessionFlags &);
-
-    /*
-     * This function validates the the list of transactionID's and returns false
-     * if the transaction ID is not valid & not present in the lock table
-     */
-
-    bool validateRids(const ListOfTransactionIds &);
-
-    /*
-     * This function releases the locks that are already obtained by the
-     * requesting Management console.
-     */
-
-    void releaseLock(const ListOfTransactionIds &);
-
-    /*
      * This API implements the logic to persist the locks that are contained in
      * the lock table into a json file.
      */
@@ -117,6 +56,79 @@
      */
     void loadLocks();
 
+    bool createPersistentLockFilePath();
+
+  protected:
+    /*
+     * This function implements the logic for validating an incoming
+     * lock request/requests.
+     *
+     * Returns : True (if Valid)
+     * Returns : False (if not a Valid lock request)
+     */
+
+    virtual bool isValidLockRequest(const LockRequest);
+
+    /*
+     * This function implements the logic of checking if the incoming
+     * multi-lock request is not having conflicting requirements.
+     *
+     * Returns : True (if conflicting)
+     * Returns : False (if not conflicting)
+     */
+
+    virtual bool isConflictRequest(const LockRequests);
+    /*
+     * Implements the core algorithm to find the conflicting
+     * lock requests.
+     *
+     * This functions takes two lock requests and check if both
+     * are conflicting to each other.
+     *
+     * Returns : True (if conflicting)
+     * Returns : False (if not conflicting)
+     */
+    virtual bool isConflictRecord(const LockRequest, const LockRequest);
+
+    /*
+     * This function implements the logic of checking the conflicting
+     * locks from a incoming single/multi lock requests with the already
+     * existing lock request in the lock table.
+     *
+     */
+
+    virtual Rc isConflictWithTable(const LockRequests);
+    /*
+     * This function implements the logic of checking the ownership of the
+     * lock from the releaselock request.
+     *
+     * Returns : True (if the requesting HMC & Session owns the lock(s))
+     * Returns : False (if the request HMC or Session does not own the lock(s))
+     */
+
+    virtual RcRelaseLock isItMyLock(const ListOfTransactionIds &,
+                                    const SessionFlags &);
+
+    /*
+     * This function validates the the list of transactionID's and returns false
+     * if the transaction ID is not valid & not present in the lock table
+     */
+
+    virtual bool validateRids(const ListOfTransactionIds &);
+
+    /*
+     * This function releases the locks that are already obtained by the
+     * requesting Management console.
+     */
+
+    void releaseLock(const ListOfTransactionIds &);
+
+    Lock()
+    {
+        loadLocks();
+        transactionId = lockTable.empty() ? 0 : prev(lockTable.end())->first;
+    }
+
     /*
      * This function implements the algorithm for checking the respective
      * bytes of the resource id based on the lock management algorithm.
@@ -129,9 +141,7 @@
      * number for every successful transaction. This number will be used by
      * the Management Console for debug.
      */
-    uint32_t generateTransactionId();
-
-    bool createPersistentLockFilePath();
+    virtual uint32_t generateTransactionId();
 
   public:
     /*
@@ -171,17 +181,15 @@
 
     void releaseLock(const std::string &);
 
-    Lock()
-    {
-        loadLocks();
-        transactionId = lockTable.empty() ? 0 : prev(lockTable.end())->first;
-    }
-
     static Lock &getInstance()
     {
         static Lock lockObject;
         return lockObject;
     }
+
+    virtual ~Lock()
+    {
+    }
 };
 
 inline bool Lock::createPersistentLockFilePath()