import collections
 import re
 
-CONFIG_IS_NOT_SET_PATTERN = r'^# CONFIG_\w+ is not set$'
-CONFIG_PATTERN = r'^CONFIG_\w+=\S+$'
-
-KconfigEntryBase = collections.namedtuple('KconfigEntry', ['raw_entry'])
+CONFIG_IS_NOT_SET_PATTERN = r'^# CONFIG_(\w+) is not set$'
+CONFIG_PATTERN = r'^CONFIG_(\w+)=(\S+)$'
 
+KconfigEntryBase = collections.namedtuple('KconfigEntry', ['name', 'value'])
 
 class KconfigEntry(KconfigEntryBase):
 
        def __str__(self) -> str:
-               return self.raw_entry
+               if self.value == 'n':
+                       return r'# CONFIG_%s is not set' % (self.name)
+               else:
+                       return r'CONFIG_%s=%s' % (self.name, self.value)
 
 
 class KconfigParseError(Exception):
                self._entries.append(entry)
 
        def is_subset_of(self, other: 'Kconfig') -> bool:
-               return self.entries().issubset(other.entries())
+               for a in self.entries():
+                       found = False
+                       for b in other.entries():
+                               if a.name != b.name:
+                                       continue
+                               if a.value != b.value:
+                                       return False
+                               found = True
+                       if a.value != 'n' and found == False:
+                               return False
+               return True
 
        def write_to_file(self, path: str) -> None:
                with open(path, 'w') as f:
                        line = line.strip()
                        if not line:
                                continue
-                       elif config_matcher.match(line) or is_not_set_matcher.match(line):
-                               self._entries.append(KconfigEntry(line))
-                       elif line[0] == '#':
+
+                       match = config_matcher.match(line)
+                       if match:
+                               entry = KconfigEntry(match.group(1), match.group(2))
+                               self.add_entry(entry)
+                               continue
+
+                       empty_match = is_not_set_matcher.match(line)
+                       if empty_match:
+                               entry = KconfigEntry(empty_match.group(1), 'n')
+                               self.add_entry(entry)
+                               continue
+
+                       if line[0] == '#':
                                continue
                        else:
                                raise KconfigParseError('Failed to parse: ' + line)
 
                self.assertTrue(kconfig0.is_subset_of(kconfig0))
 
                kconfig1 = kunit_config.Kconfig()
-               kconfig1.add_entry(kunit_config.KconfigEntry('CONFIG_TEST=y'))
+               kconfig1.add_entry(kunit_config.KconfigEntry('TEST', 'y'))
                self.assertTrue(kconfig1.is_subset_of(kconfig1))
                self.assertTrue(kconfig0.is_subset_of(kconfig1))
                self.assertFalse(kconfig1.is_subset_of(kconfig0))
 
                expected_kconfig = kunit_config.Kconfig()
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_UML=y'))
+                       kunit_config.KconfigEntry('UML', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_MMU=y'))
+                       kunit_config.KconfigEntry('MMU', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_TEST=y'))
+                       kunit_config.KconfigEntry('TEST', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_EXAMPLE_TEST=y'))
+                       kunit_config.KconfigEntry('EXAMPLE_TEST', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('# CONFIG_MK8 is not set'))
+                       kunit_config.KconfigEntry('MK8', 'n'))
 
                self.assertEqual(kconfig.entries(), expected_kconfig.entries())
 
 
                expected_kconfig = kunit_config.Kconfig()
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_UML=y'))
+                       kunit_config.KconfigEntry('UML', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_MMU=y'))
+                       kunit_config.KconfigEntry('MMU', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_TEST=y'))
+                       kunit_config.KconfigEntry('TEST', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('CONFIG_EXAMPLE_TEST=y'))
+                       kunit_config.KconfigEntry('EXAMPLE_TEST', 'y'))
                expected_kconfig.add_entry(
-                       kunit_config.KconfigEntry('# CONFIG_MK8 is not set'))
+                       kunit_config.KconfigEntry('MK8', 'n'))
 
                expected_kconfig.write_to_file(kconfig_path)