1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright 2019 The ChromiumOS Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7"""Unittest for command_executer.py.""" 8 9 10import time 11import unittest 12 13from cros_utils import command_executer 14 15 16class CommandExecuterTest(unittest.TestCase): 17 """Test for CommandExecuter class.""" 18 19 def testTimeout(self): 20 timeout = 1 21 logging_level = "average" 22 ce = command_executer.CommandExecuter(logging_level) 23 start = time.time() 24 command = "sleep 20" 25 ce.RunCommand( 26 command, command_timeout=timeout, terminated_timeout=timeout 27 ) 28 end = time.time() 29 self.assertTrue(round(end - start) == timeout) 30 31 32if __name__ == "__main__": 33 unittest.main() 34