1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright 2019 The Chromium OS Authors. All rights reserved. 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 9from __future__ import print_function 10 11import time 12import unittest 13 14from cros_utils import command_executer 15 16 17class CommandExecuterTest(unittest.TestCase): 18 """Test for CommandExecuter class.""" 19 20 def testTimeout(self): 21 timeout = 1 22 logging_level = 'average' 23 ce = command_executer.CommandExecuter(logging_level) 24 start = time.time() 25 command = 'sleep 20' 26 ce.RunCommand(command, command_timeout=timeout, terminated_timeout=timeout) 27 end = time.time() 28 self.assertTrue(round(end - start) == timeout) 29 30 31if __name__ == '__main__': 32 unittest.main() 33