'''Reboot test module'''
import time
from oeqa.oetest import oeRuntimeTest
from oeqa.runtime.helper import shell_cmd_timeout

class RebootTest(oeRuntimeTest):
    '''Reboot target device'''
    def _alive(self):
        '''check if device alive'''
        ret = shell_cmd_timeout("ping -c 1 %s" % self.target.ip, 4)[0]
        return True if ret == 0 else False

    def _wait_offline(self):
        '''wait till device offline'''
        for _ in range(60):
            time.sleep(2)
            if not self._alive():
                return True
        return False

    def _wait_online(self):
        '''wait till device online'''
        for _ in range(60):
            time.sleep(2)
            if self._alive():
                return True
        return False

    def test_reboot(self):
        '''reboot target device for several times'''
        for _ in range(3):
            ret = self.target.run('reboot')[0]
            self.assertEqual(ret, 0, msg="Fail to trigger reboot command")
            time.sleep(4)
            status = self._wait_offline()
            self.assertTrue(status, msg="Fail to drive system off")
            time.sleep(4)
            status = self._wait_online()
            self.assertTrue(status, msg="Fail to bring up system")

@@ -179,24 +179,161 @@
 t device'''%0A
+    def setUp(self):%0A        '''pre condition check'''%0A        self.assertTrue(self._alive(), msg=%22device is not alive before test%22)%0A   %0A
     def _ali
@@ -334,32 +334,32 @@
 f _alive(self):%0A
-
         '''check
@@ -593,34 +593,8 @@
 0):%0A
-            time.sleep(2)%0A
     
@@ -771,34 +771,8 @@
 0):%0A
-            time.sleep(2)%0A
     
@@ -931,33 +931,35 @@
 '''%0A        for 
-_
+cnt
  in range(3):%0A  
@@ -956,16 +956,57 @@
 nge(3):%0A
+            print %22Reboot %25d time%22 %25 cnt%0A
         
@@ -1040,24 +1040,25 @@
 reboot')%5B0%5D%0A
+#
             

fix reboot return false issue, and add setUp to check status before test