Merge "Fix full content test"
diff --git a/contents/tests/configuration/baseconfig_test.cc b/contents/tests/configuration/baseconfig_test.cc
index 5a2dead..f8bedbe 100644
--- a/contents/tests/configuration/baseconfig_test.cc
+++ b/contents/tests/configuration/baseconfig_test.cc
@@ -25,7 +25,7 @@
 
 TEST(linkerconfig_configuration_fulltest, baseconfig_test) {
   MockGenericVariables();
-  Context ctx;
+  Context ctx = GenerateContextWithVndk();
   auto base_config = CreateBaseConfiguration(ctx);
   ConfigWriter config_writer;
 
@@ -38,7 +38,7 @@
      baseconfig_vndk_using_core_variant_test) {
   MockGenericVariables();
   MockVndkUsingCoreVariant();
-  Context ctx;
+  Context ctx = GenerateContextWithVndk();
   auto base_config = CreateBaseConfiguration(ctx);
   ConfigWriter config_writer;
 
@@ -50,7 +50,7 @@
 TEST(linkerconfig_configuration_fulltest, baseconfig_vndk_27_test) {
   MockGenericVariables();
   MockVndkVersion("27");
-  Context ctx;
+  Context ctx = GenerateContextWithVndk();
   auto base_config = CreateBaseConfiguration(ctx);
   ConfigWriter config_writer;
 
@@ -62,7 +62,7 @@
 TEST(linkerconfig_configuration_fulltest, vndklite_test) {
   MockGenericVariables();
   MockVnkdLite();
-  Context ctx;
+  Context ctx = GenerateContextWithVndk();
   auto vndklite_config = CreateBaseConfiguration(ctx);
   ConfigWriter config_writer;
 
diff --git a/contents/tests/configuration/include/linkerconfigparser.h b/contents/tests/configuration/include/linkerconfigparser.h
index 880dfae..16a5e77 100644
--- a/contents/tests/configuration/include/linkerconfigparser.h
+++ b/contents/tests/configuration/include/linkerconfigparser.h
@@ -35,8 +35,8 @@
   static std::regex dir_regex(kDirRegex);
   std::smatch match;
 
-  ASSERT_TRUE(std::regex_match(line, match, dir_regex));
-  ASSERT_EQ(3u, match.size());
+  ASSERT_TRUE(std::regex_match(line, match, dir_regex)) << line;
+  ASSERT_EQ(3u, match.size()) << line;
   std::string section_name = match[1];
   std::string dir_path = match[2];
 
@@ -55,7 +55,8 @@
   std::stringstream namespaces(match[1]);
   for (std::string namespace_name;
        std::getline(namespaces, namespace_name, ',');) {
-    EXPECT_FALSE(MapContainsKey(current_section.namespaces, namespace_name));
+    EXPECT_FALSE(MapContainsKey(current_section.namespaces, namespace_name))
+        << "Namespace " << namespace_name << " already exists";
     Namespace new_namespace;
     new_namespace.name = namespace_name;
     current_section.namespaces[namespace_name] = new_namespace;
@@ -80,7 +81,7 @@
     target_path = &current_namespace.asan_permitted_path;
   }
 
-  ASSERT_NE(nullptr, target_path);
+  ASSERT_NE(nullptr, target_path) << line;
   EXPECT_EQ(is_additional, target_path->size() != 0)
       << "Path should be marked as = if and only if it is mentioned first : "
       << line;
@@ -114,9 +115,10 @@
                       const std::string& line) {
   // namespace.from.link.to.shared_libs = a.so
   // namespace.from.link.to.allow_all_shared_libs = true
-  ASSERT_EQ(3u, property_descs.size());
+  ASSERT_EQ(3u, property_descs.size()) << line;
   ASSERT_TRUE(property_descs[2] == "shared_libs" ||
-              property_descs[2] == "allow_all_shared_libs");
+              property_descs[2] == "allow_all_shared_libs")
+      << line;
   std::string namespace_to = property_descs[1];
 
   ASSERT_TRUE(MapContainsKey(current_section.namespaces, namespace_to))
@@ -132,7 +134,7 @@
 
     current_namespace.links[namespace_to].shared_libs.push_back(value);
   } else {
-    EXPECT_EQ("true", value);
+    EXPECT_EQ("true", value) << line;
     current_namespace.links[namespace_to].allow_all_shared = true;
   }
 }
@@ -161,13 +163,13 @@
 
   if (property_descs[0].compare("isolated") == 0) {
     // namespace.test.isolated = true
-    EXPECT_EQ(1u, property_descs.size());
-    EXPECT_TRUE(value == "true" || value == "false");
+    EXPECT_EQ(1u, property_descs.size()) << line;
+    EXPECT_TRUE(value == "true" || value == "false") << line;
     current_namespace.is_isolated = value == "true";
   } else if (property_descs[0].compare("visible") == 0) {
     // namespace.test.visible = true
-    EXPECT_EQ(1u, property_descs.size());
-    EXPECT_TRUE(value == "true" || value == "false");
+    EXPECT_EQ(1u, property_descs.size()) << line;
+    EXPECT_TRUE(value == "true" || value == "false") << line;
     current_namespace.is_visible = value == "true";
   } else if (property_descs[property_descs.size() - 1] == "paths") {
     // namespace.test.search.path += /system/lib
@@ -186,7 +188,7 @@
               current_section,
               line);
   } else if (property_descs[0] == "whitelisted") {
-    EXPECT_EQ(1u, property_descs.size());
+    EXPECT_EQ(1u, property_descs.size()) << line;
     current_namespace.whitelisted.push_back(value);
   } else {
     EXPECT_TRUE(false) << "Failed to parse line : " << line;
@@ -214,9 +216,9 @@
 
     if (std::regex_match(line, match, section_name_regex)) {
       // [section_name]
-      ASSERT_EQ(2u, match.size());
+      ASSERT_EQ(2u, match.size()) << line;
       std::string section_name = match[1];
-      ASSERT_TRUE(MapContainsKey(conf.sections, section_name));
+      ASSERT_TRUE(MapContainsKey(conf.sections, section_name)) << line;
       current_section = &conf.sections[section_name];
 
       continue;
@@ -228,8 +230,8 @@
       if (std::regex_match(line, match, additional_namespaces_regex)) {
         ParseAdditionalNamespaces(match, *current_section);
       } else {
-        EXPECT_TRUE(std::regex_match(line, match, namespace_base_regex));
-        ASSERT_EQ(5u, match.size());
+        EXPECT_TRUE(std::regex_match(line, match, namespace_base_regex)) << line;
+        ASSERT_EQ(5u, match.size()) << line;
         std::string namespace_name = match[1];
         std::string property_desc = match[2];
         bool is_additional_property = match[3] == "+=";
diff --git a/contents/tests/configuration/include/mockenv.h b/contents/tests/configuration/include/mockenv.h
index 00cc508..d72be4a 100644
--- a/contents/tests/configuration/include/mockenv.h
+++ b/contents/tests/configuration/include/mockenv.h
@@ -64,3 +64,13 @@
 inline void MockVnkdLite() {
   android::linkerconfig::modules::Variables::AddValue("ro.vndk.lite", "true");
 }
+
+inline android::linkerconfig::contents::Context GenerateContextWithVndk() {
+  android::linkerconfig::modules::ApexInfo vndk_apex;
+  vndk_apex.name = "com.android.vndk.v99";
+
+  android::linkerconfig::contents::Context ctx;
+  ctx.AddApexModule(vndk_apex);
+
+  return ctx;
+}