Home | History | Annotate | Download | only in test
      1 #!/usr/bin/python
      2 #
      3 # Copyright 2016 The Android Open Source Project
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 # http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 
     17 import unittest
     18 
     19 import gzip
     20 import net_test
     21 
     22 
     23 class RemovedFeatureTest(net_test.NetworkTest):
     24   KCONFIG = None
     25 
     26   @classmethod
     27   def loadKernelConfig(cls):
     28     cls.KCONFIG = {}
     29     with gzip.open('/proc/config.gz') as f:
     30       for line in f:
     31         line = line.strip()
     32         parts = line.split("=")
     33         if (len(parts) == 2):
     34           # Lines of the form:
     35           # CONFIG_FOO=y
     36           cls.KCONFIG[parts[0]] = parts[1]
     37 
     38   @classmethod
     39   def setUpClass(cls):
     40     cls.loadKernelConfig()
     41 
     42   def assertFeatureEnabled(self, featureName):
     43     return self.assertEqual("y", self.KCONFIG[featureName])
     44 
     45   def assertFeatureAbsent(self, featureName):
     46     return self.assertTrue(featureName not in self.KCONFIG)
     47 
     48   def testNetfilterRejectWithSocketError(self):
     49     """Verify that the CONFIG_IP{,6}_NF_TARGET_REJECT_SKERR option is gone.
     50 
     51        The commits to be reverted include:
     52 
     53            android-3.10: 6f489c42
     54            angler: 6f489c42
     55            bullhead: 6f489c42
     56            shamu: 6f489c42
     57            flounder: 6f489c42
     58 
     59        See b/28424847 and b/28719525 for more context.
     60     """
     61     self.assertFeatureEnabled("CONFIG_IP_NF_FILTER")
     62     self.assertFeatureEnabled("CONFIG_IP_NF_TARGET_REJECT")
     63     self.assertFeatureAbsent("CONFIG_IP_NF_TARGET_REJECT_SKERR")
     64 
     65     self.assertFeatureEnabled("CONFIG_IP6_NF_FILTER")
     66     self.assertFeatureEnabled("CONFIG_IP6_NF_TARGET_REJECT")
     67     self.assertFeatureAbsent("CONFIG_IP6_NF_TARGET_REJECT_SKERR")
     68 
     69 
     70 if __name__ == "__main__":
     71   unittest.main()
     72