Home | History | Annotate | Download | only in crashme
      1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import os
      6 from autotest_lib.client.bin import test, utils
      7 
      8 
      9 class crashme(test.test):
     10     """
     11     Runs the crashme random code test suite.
     12 
     13     crashme [+]<nbytes>[.inc] <srand> <ntrys> [nsub] [verbose]
     14 
     15       [NBYTES]
     16          The [NBYTES] should be an integer, specifying the size of
     17          the random data string in bytes. If given negative then the
     18          bytes are printed instead of being executed. If given with
     19          an explicit plus sign then the storage for the bytes is
     20          freshly malloc'ed each time. This can have an effect on
     21          machines with seperate I and D cache mechanisms. The
     22          argument can also have a dot in it, X.Y, in which case Y is
     23          a increment for a pointer into the random data. The buffer
     24          is recalculated only when the pointer gets near the end of
     25          the data.
     26 
     27       [SRAND]
     28          The [SRAND] is an input seed to the random number generator,
     29          passed to srand.
     30 
     31       [NTRIES]
     32          The [NTRIES] is how many times to loop before exiting
     33          normally from the program.
     34 
     35       [NSUB]
     36          The [NSUB] is optional, the number of vfork subprocesses
     37          running all at once. If negative run one after another. If
     38          given as a time hrs:mns:scs (hours, minutes, seconds) then
     39          one sub-process will be run to completion, followed by
     40          another, until the time limit has been reached. If this
     41          argument is given as the empty string or . then it is
     42          ignored.
     43 
     44          When in sequential-subprocess mode there is a 30 second time
     45          limit on each subprocess. This is to allow the
     46          instruction-set-space random walk to continue when a
     47          process bashes itself into an infinite loop. For example,
     48          the ntrys can be bashed to a very large number with nbytes
     49          bashed to zero. (10 second limit on Windows NT).
     50 
     51          The SRAND argument is incremented by one for each subprocess.
     52 
     53       [VERBOSE]
     54          The [VERBOSE] arg is optional. 0 is the least verbose, 5 the
     55          most.
     56 """
     57     version = 2
     58 
     59     def initialize(self):
     60         self.job.require_gcc()
     61 
     62     def setup(self, tarball = 'crashme_2.4.orig.tar.bz2'):
     63         tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
     64         utils.extract_tarball_to_dir(tarball, self.srcdir)
     65         os.chdir(self.srcdir)
     66         utils.system('patch -p 1 <../crashme_2.4-9.diff')
     67         utils.make()
     68 
     69     def run_once(self, args_list=''):
     70         if args_list:
     71             args = args_list
     72         else:
     73             args = ''
     74 
     75         crashme_path = os.path.join(self.srcdir, 'crashme')
     76         utils.system("%s %s" % (crashme_path, args))
     77