115ae2509SBrad Bishop# Copyright (C) 2019 Armin Kuster <akuster808@gmail.com>
215ae2509SBrad Bishop#
315ae2509SBrad Bishopimport re
415ae2509SBrad Bishop
515ae2509SBrad Bishopfrom oeqa.runtime.case import OERuntimeTestCase
615ae2509SBrad Bishopfrom oeqa.core.decorator.depends import OETestDepends
715ae2509SBrad Bishopfrom oeqa.runtime.decorator.package import OEHasPackage
815ae2509SBrad Bishop
915ae2509SBrad Bishop
1015ae2509SBrad Bishopclass CheckSecTest(OERuntimeTestCase):
1115ae2509SBrad Bishop
1215ae2509SBrad Bishop    @OEHasPackage(['checksec'])
1315ae2509SBrad Bishop    @OETestDepends(['ssh.SSHTest.test_ssh'])
1415ae2509SBrad Bishop    def test_checksec_help(self):
1515ae2509SBrad Bishop        status, output = self.target.run('checksec --help ')
1615ae2509SBrad Bishop        msg = ('checksec  command does not work as expected. '
1715ae2509SBrad Bishop                'Status and output:%s and %s' % (status, output))
1815ae2509SBrad Bishop        self.assertEqual(status, 0, msg = msg)
1915ae2509SBrad Bishop
2015ae2509SBrad Bishop    @OETestDepends(['checksec.CheckSecTest.test_checksec_help'])
2115ae2509SBrad Bishop    def test_checksec_xml(self):
22*615f2f11SAndrew Geissler        status, output = self.target.run('checksec --format=xml --proc=1')
2315ae2509SBrad Bishop        msg = ('checksec xml failed. Output: %s' % output)
2415ae2509SBrad Bishop        self.assertEqual(status, 0, msg = msg)
2515ae2509SBrad Bishop
2615ae2509SBrad Bishop    @OETestDepends(['checksec.CheckSecTest.test_checksec_xml'])
2749fa52dbSBrad Bishop    @OEHasPackage(['binutils'])
2815ae2509SBrad Bishop    def test_checksec_fortify(self):
2915ae2509SBrad Bishop        status, output = self.target.run('checksec --fortify-proc 1')
3015ae2509SBrad Bishop        match = re.search('FORTIFY_SOURCE support:', output)
3115ae2509SBrad Bishop        if not match:
3215ae2509SBrad Bishop            msg = ('checksec : fortify-proc failed. '
3315ae2509SBrad Bishop               'Status and output:%s and %s' % (status, output))
3415ae2509SBrad Bishop            self.assertEqual(status, 1, msg = msg)
35