1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestSleepCommand.cxx,v $
6 Date: $Date: 2008/01/23 15:28:01 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmCTestSleepCommand.h"
19 #include "cmCTestScriptHandler.h"
20 #include <stdlib.h> // required for atoi
22 bool cmCTestSleepCommand
23 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
27 this->SetError("called with incorrect number of arguments");
31 // sleep for specified seconds
32 unsigned int time1
= atoi(args
[0].c_str());
35 cmCTestScriptHandler::SleepInSeconds(time1
);
36 // update the elapsed time since it could have slept for a while
37 this->CTestScriptHandler
->UpdateElapsedTime();
41 // sleep up to a duration
44 unsigned int duration
= atoi(args
[1].c_str());
45 unsigned int time2
= atoi(args
[2].c_str());
46 if (time1
+ duration
> time2
)
48 duration
= (time1
+ duration
- time2
);
49 cmCTestScriptHandler::SleepInSeconds(duration
);
50 // update the elapsed time since it could have slept for a while
51 this->CTestScriptHandler
->UpdateElapsedTime();
56 this->SetError("called with incorrect number of arguments");