Selaa lähdekoodia

Tested callback timeout on Windows. Tests fail, because SERVICE_STATUS::dwWaitHint seems to be ignored by Windows.

git-svn-id: https://svn.microneil.com/svn/CodeDweller-Tests/trunk@25 b3372362-9eaa-4a85-aa2b-6faa1ab7c995
master
adeniz 10 vuotta sitten
vanhempi
commit
379cf03d37
2 muutettua tiedostoa jossa 43 lisäystä ja 18 poistoa
  1. 33
    17
      TestService/buildAndRun
  2. 10
    1
      TestService/serviceProgram.cpp

+ 33
- 17
TestService/buildAndRun Näytä tiedosto

@@ -3,8 +3,9 @@ debugFileName=$progName"Debug.log"

if [ "$(uname --operating-system)" == "Msys" ]
then
CFLAGS='-I.. -Wall -std=c++11 -DWIN32 -pthread -DDEBUG_LOG_FILE="'
CFLAGS='-I.. -Wall -std=c++11 -DWIN32 -pthread -static -DDEBUG_LOG_FILE="'
CFLAGS=$CFLAGS$(pwd)/$debugFileName\"
CFLAGS='-I.. -Wall -std=c++11 -DWIN32 -pthread -static'
else
CFLAGS='-I.. -Wall -std=c++11 -g -O0 -pthread -DDEBUG_LOG_FILE="'
CFLAGS=$CFLAGS$(pwd)/$debugFileName\"
@@ -36,21 +37,29 @@ run_test() {
if [ "$(uname --operating-system)" == "Msys" ]
then

sc create "Test Service" binPath= "$(pwd)/$progName.exe"
sc create "Test Service" binPath= "$(pwd)/$progName.exe" > /dev/null 2>&1

sc start "Test Service" "$(pwd)/$logFile"
#echo "Starting at "$(date +"%H:%M:%S.%N")
sc start "Test Service" "$(pwd)/$logFile" $message > /dev/null 2>&1
#echo "Sleeping 1 s at "$(date +"%H:%M:%S.%N")
sleep 1

sc pause "Test Service" "$(pwd)/$logFile"
#echo "Pausing at "$(date +"%H:%M:%S.%N")
sc pause "Test Service" > /dev/null 2>&1
#echo "Sleeping 2 s at "$(date +"%H:%M:%S.%N")
sleep 2

sc continue "Test Service" "$(pwd)/$logFile"
#echo "Continuing at "$(date +"%H:%M:%S.%N")
sc continue "Test Service" > /dev/null 2>&1
#echo "Sleeping 2 s at "$(date +"%H:%M:%S.%N")
sleep 2

sc stop "Test Service"
#echo "Stopping at "$(date +"%H:%M:%S.%N")
sc stop "Test Service" > /dev/null 2>&1
#echo "Returned at "$(date +"%H:%M:%S.%N")
sleep 1

sc delete "Test Service"
sc delete "Test Service" > /dev/null 2>&1

else

@@ -114,21 +123,28 @@ return 0

stat=0

# Normal test.
# Run tests.
run_test Nominal
nominal_status=$?

# Pause timeout.
run_test Pause
pause_status=$?
if [ "$(uname --operating-system)" != "Msys" ]
then
# Pause timeout.
run_test Pause
pause_status=$?

# Resume timeout.
run_test Resume
resume_status=$?
# Resume timeout.
run_test Resume
resume_status=$?

# Stop timeout.
run_test Stop
stop_status=$?
# Stop timeout.
run_test Stop
stop_status=$?
else
pause_status=0
resume_status=0
stop_status=0
fi

if [ $nominal_status == "0" -a \
$pause_status == "0" -a \

+ 10
- 1
TestService/serviceProgram.cpp Näytä tiedosto

@@ -51,6 +51,15 @@
// Configuration ////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////

// How long to sleep between iterations. This value is longer for
// Windows because the sc command takes about 0.7 s to execute on the
// development/text Windows 7 system.
#ifdef WIN32
const int delayTime_ms = 2700;
#else
const int delayTime_ms = 2000;
#endif

// Callback timeout time.
const int timeoutTime_ms = 500;

@@ -184,7 +193,7 @@ int CodeDweller::Service::run() {

logStream << "Sleeping 2 s...";
logStream.flush();
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
std::this_thread::sleep_for(std::chrono::milliseconds(delayTime_ms));
logStream << "done." << std::endl;

logStream << "receivedPause(): "

Loading…
Peruuta
Tallenna