/usr/lib/python2.7/dist-packages/vamos/golem/Kbuild_test.py is in undertaker 1.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | #
# Copyright (C) 2011 Reinhard Tartler <tartler@informatik.uni-erlangen.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest2 as t
import vamos
from vamos.tools import execute, CommandFailed
from vamos.golem.kbuild import *
class testTools(t.TestCase):
def setUp(self):
pass
def test_execute(self):
(output, rc) = execute("false", failok=True)
self.assertEqual(rc, 1)
self.assertIs(len(output), 1)
self.assertIs(len(output[0]), 0)
with self.assertRaises(CommandFailed):
execute("false", failok=False)
def test_guessfilename(self):
vamos.prefer_32bit = False
(arch, subarch) = guess_arch_from_filename('arch/x86/init.c')
self.assertEqual(arch, 'x86')
self.assertEqual(subarch, 'x86_64')
vamos.prefer_32bit = False
(arch, subarch) = guess_arch_from_filename('arch/x86/../x86/init.c')
self.assertEqual(arch, 'x86')
self.assertEqual(subarch, 'x86_64')
(arch, subarch) = guess_arch_from_filename('kernel/init.c')
self.assertEqual(arch, 'x86')
self.assertEqual(subarch, 'x86_64')
(arch, subarch) = guess_arch_from_filename('././kernel/init.c')
self.assertEqual(arch, 'x86')
self.assertEqual(subarch, 'x86_64')
vamos.prefer_32bit = True
(arch, subarch) = guess_arch_from_filename('arch/x86/init.c')
self.assertEqual(arch, 'x86')
self.assertEqual(subarch, 'i386')
(arch, subarch) = guess_arch_from_filename('arch/sparc/init.c')
self.assertEqual(arch, 'sparc')
self.assertEqual(subarch, 'sparc')
(arch, subarch) = guess_arch_from_filename('arch/h8300/kernel/timer/tpu.c')
self.assertEqual(arch, 'h8300')
self.assertEqual(subarch, 'h8300')
(arch, subarch) = guess_arch_from_filename('kernel/init.c')
self.assertEqual(arch, 'x86')
self.assertEqual(subarch, 'i386')
def test_call_linux_makefile(self):
vamos.prefer_32bit = True
(cmd, rc) = call_linux_makefile('', dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', ' ARCH=i386', 'SUBARCH=i386'):
self.assertIn(needle, cmd)
(cmd, rc) = call_linux_makefile('allnoconfig', dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', 'allnoconfig', ' ARCH=i386', 'SUBARCH=i386'):
self.assertIn(needle, cmd)
(cmd, rc) = call_linux_makefile('silentoldconfig', dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', 'silentoldconfig', 'ARCH=i386', 'SUBARCH=i386'):
self.assertIn(needle, cmd)
(cmd, rc) = call_linux_makefile('', filename='./arch/x86/init.o', dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', 'ARCH=i386', 'SUBARCH=i386'):
self.assertIn(needle, cmd)
(cmd, rc) = call_linux_makefile('', filename='./arch/um/init.o', dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', ' ARCH=um', 'SUBARCH=i386'):
self.assertIn(needle, cmd)
(cmd, rc) = call_linux_makefile('arch/h8300/kernel/timer/tpu.o',
filename='arch/h8300/kernel/timer/tpu.c',
extra_variables="C=2",
dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', ' ARCH=h8300', 'SUBARCH=h8300', 'C=2', 'tpu.o'):
self.assertIn(needle, cmd)
vamos.prefer_32bit = False
(cmd, rc) = call_linux_makefile('', filename='./arch/x86/init.o', dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', ' ARCH=x86_64', 'SUBARCH=x86_64'):
self.assertIn(needle, cmd)
(cmd, rc) = call_linux_makefile('', filename='./arch/um/init.o', dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', ' ARCH=um', 'SUBARCH=x86_64'):
self.assertIn(needle, cmd)
(cmd, rc) = call_linux_makefile('arch/h8300/kernel/timer/tpu.o',
filename='arch/h8300/kernel/timer/tpu.c',
extra_variables="C=2",
dryrun=True)
self.assertEqual(rc, 0)
for needle in ('make', ' ARCH=h8300', 'SUBARCH=h8300', 'C=2', 'tpu.o'):
self.assertIn(needle, cmd)
if __name__ == '__main__':
t.main()
|