msl: Support for v-xx.xx.xx format version ID

The version ID of the pnor we have released is
similar to the following format.

Inspur-Dubai-v-4.1.01

This change adds support for parsing version ID
in v-xx.xx.xx format

Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I1a7dd04256d1901e3dafef14baf338b853e2ff97
diff --git a/msl_verify.cpp b/msl_verify.cpp
index 1d93613..b49b079 100644
--- a/msl_verify.cpp
+++ b/msl_verify.cpp
@@ -57,13 +57,13 @@
     std::smatch match;
     version = {0, 0, 0};
 
-    // Match for vX.Y.Z
-    std::regex regex{"v([0-9]+)\\.([0-9]+)\\.([0-9]+)", std::regex::extended};
+    // Match for vX.Y.Z or v-X.Y.Z
+    std::regex regex{"v-?([0-9]+)\\.([0-9]+)\\.([0-9]+)", std::regex::extended};
 
     if (!std::regex_search(versionStr, match, regex))
     {
-        // Match for vX.Y
-        std::regex regexShort{"v([0-9]+)\\.([0-9]+)", std::regex::extended};
+        // Match for vX.Y or v-X.Y
+        std::regex regexShort{"v-?([0-9]+)\\.([0-9]+)", std::regex::extended};
         if (!std::regex_search(versionStr, match, regexShort))
         {
             log<level::ERR>("Unable to parse PNOR version",
diff --git a/test/msl_verify.cpp b/test/msl_verify.cpp
index 5fdf505..a4de09c 100644
--- a/test/msl_verify.cpp
+++ b/test/msl_verify.cpp
@@ -71,6 +71,18 @@
     EXPECT_EQ(6, version.major);
     EXPECT_EQ(7, version.minor);
     EXPECT_EQ(0, version.rev);
+
+    versionStr = "Vendor-Model-v-4.1.01";
+    minimumShipLevel->parse(versionStr, version);
+    EXPECT_EQ(4, version.major);
+    EXPECT_EQ(1, version.minor);
+    EXPECT_EQ(1, version.rev);
+
+    versionStr = "Vendor-Model-v-4.1-abc";
+    minimumShipLevel->parse(versionStr, version);
+    EXPECT_EQ(4, version.major);
+    EXPECT_EQ(1, version.minor);
+    EXPECT_EQ(0, version.rev);
 }
 
 } // namespace image