blob: 4968f31566973457d54edcc475c925ad0b8983c6 [file] [log] [blame]
mblighc9fdc402006-10-01 19:57:02 +00001import shutil, re, os, os.path, string
2from autotest_utils import *
mblighe4046192006-09-15 14:31:01 +00003
4class boottool:
5 def __init__(self, boottool_exec=None):
6 if boottool_exec:
7 self.boottool_exec = boottool_exec
8 else:
mblighc9fdc402006-10-01 19:57:02 +00009 autodir = os.environ['AUTODIR']
10 self.boottool_exec = autodir + '/tools/boottool'
mblighe4046192006-09-15 14:31:01 +000011
mblighf133d012006-10-05 06:57:19 +000012 def run_boottool(self, params):
13 return system_output('%s %s' % (self.boottool_exec, params))
mblighe4046192006-09-15 14:31:01 +000014
15 def bootloader(self):
mblighf133d012006-10-05 06:57:19 +000016 return self.run_boottool('--bootloader-probe')
mblighe4046192006-09-15 14:31:01 +000017
mblighf133d012006-10-05 06:57:19 +000018 def architecture(self):
19 return self.run_boottool('--arch-probe')
mblighe4046192006-09-15 14:31:01 +000020
21 def list_titles(self):
mblighf133d012006-10-05 06:57:19 +000022 print self.run_boottool('--info all | grep title')
mblighe4046192006-09-15 14:31:01 +000023
24 def print_entry(self, index):
mblighf133d012006-10-05 06:57:19 +000025 print self.run_boottool('--info=%s' % index)
mblighe4046192006-09-15 14:31:01 +000026
mblighc9fdc402006-10-01 19:57:02 +000027 def get_default(self):
mblighf133d012006-10-05 06:57:19 +000028 self.run_boottool('--default')
mblighc9fdc402006-10-01 19:57:02 +000029
mblighe4046192006-09-15 14:31:01 +000030 def set_default(self, index):
mblighf133d012006-10-05 06:57:19 +000031 self.run_boottool('--set-default=%s' % index)
mblighe4046192006-09-15 14:31:01 +000032
mblighf133d012006-10-05 06:57:19 +000033 # 'kernel' can be an position number or a title
34 def add_args(self, kernel, args):
35 self.run_boottool('--update-kernel=%s --args=%s' % \
mblighc9fdc402006-10-01 19:57:02 +000036 (kernel, args) )
mblighe4046192006-09-15 14:31:01 +000037
mblighf133d012006-10-05 06:57:19 +000038 def remove_args(self, kernel, args):
39 self.run_boottool('--update-kernel=%s --remove-args=%s' % \
mblighc9fdc402006-10-01 19:57:02 +000040 (kernel, args) )
mblighe4046192006-09-15 14:31:01 +000041
mbligh9ef1f8b2006-10-10 02:17:46 +000042 def add_kernel(self, path, title='autotest', initrd=''):
43 # boot tool needs a dummy argument for add_args to work
44 parameters = '--add-kernel=%s --title=%s --args=dummy' % \
45 (path, title)
46 # add an initrd now or forever hold your peace
47 if initrd:
48 parameters += ' --initrd=%s' % initrd
49 self.run_boottool(parameters)
50
mblighe4046192006-09-15 14:31:01 +000051
mblighf133d012006-10-05 06:57:19 +000052 def remove_kernel(self, kernel):
53 self.run_boottool('--remove-kernel=%s' % kernel)
mblighe4046192006-09-15 14:31:01 +000054
mblighf133d012006-10-05 06:57:19 +000055 def boot_once(self, title):
56 self.run_boottool('--boot-once --title=%s' % title)
mblighe4046192006-09-15 14:31:01 +000057
mblighf133d012006-10-05 06:57:19 +000058 def info(self, index):
apw227ef652006-10-16 09:24:16 +000059 return self.run_boottool('--info=%s' % index)
mblighe4046192006-09-15 14:31:01 +000060
61
62# TODO: backup()
63# TODO: set_timeout()
64