sleeptenmin.py 845 字节
Newer Older
1 2
#!/usr/bin/python

3
import os
4 5 6 7 8 9
import time

from avocado import job
from avocado import test


10
class SleepTenMin(test.Test):
11 12 13 14

    """
    Sleeps for 10 minutes
    """
15 16 17
    default_params = {'sleep_length': 600,
                      'sleep_cycles': 1,
                      'sleep_method': 'builtin'}
18

19
    def runTest(self):
20 21 22
        """
        Sleep for length seconds.
        """
23 24 25 26 27 28 29 30 31
        cycles = int(self.params.sleep_cycles)
        length = int(self.params.sleep_length)

        for cycle in xrange(0, cycles):
            self.log.debug("Sleeping for %.2f seconds", length)
            if self.params.sleep_method == 'builtin':
                time.sleep(length)
            elif self.params.sleep_method == 'shell':
                os.system("sleep %s" % length)
32
            self.report_state()
33 34 35

if __name__ == "__main__":
    job.main()