• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import os
2from autotest_lib.client.bin import test, utils
3
4
5class scrashme(test.test):
6    """
7    Runs the scrashme syscalls test suite. This test mode will exercise
8    kernel syscalls randomically, or in a sequential fashion.
9
10    @note: As of the current version shipped, scrashme does support the
11            following options:
12
13    --mode must be one of random, rotate, regval, struct, or capcheck
14       --mode=random : pass random values in registers to random syscalls
15         -s#: use # as random seed.
16
17       --mode=rotate : rotate value through all register combinations
18         -k:  pass kernel addresses as arguments.
19         -u:  pass userspace addresses as arguments.
20         -x#: use value as register arguments.
21         -z:  use all zeros as register parameters.
22         -Sr: pass struct filled with random junk.
23         -Sxx: pass struct filled with hex value xx.
24
25       --mode=capcheck:  check syscalls that call capable() return -EPERM.
26
27       -b#: begin at offset #.
28       -c#: target syscall # only.
29       -N#: do # syscalls then exit.
30       -P:  poison buffers before calling syscall, and check afterwards.
31       -p:  pause after syscall.
32
33    @see: http://www.codemonkey.org.uk/projects/scrashme/
34    @author: Yi Yang <yang.y.yi@gmail.com>
35    """
36    version = 2
37
38    def initialize(self):
39        self.job.require_gcc()
40
41
42    def setup(self, tarball = 'scrashme-git-snapshot-03-18-2010.tar.bz2'):
43        diff_src = os.path.join(self.bindir, 'testfix.diff')
44        tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
45        utils.extract_tarball_to_dir(tarball, self.srcdir)
46        os.chdir(self.srcdir)
47        if os.path.exists(diff_src):
48            utils.system('patch -i %s' % diff_src)
49        utils.make()
50
51
52    def run_once(self, args_list=''):
53        if args_list:
54            args = args_list
55        else:
56            args = '--mode rotate'
57
58        scrashme_path = os.path.join(self.srcdir, 'scrashme')
59        utils.system("%s %s" % (scrashme_path, args))
60