|
|
|
|
|
|
|
|
if [ "$(uname --operating-system)" == "Msys" ] |
|
|
if [ "$(uname --operating-system)" == "Msys" ] |
|
|
then |
|
|
then |
|
|
CFLAGS='-I.. -std=c++11 -g -O0 -DWIN32 -pthread' |
|
|
|
|
|
|
|
|
CFLAGS='-I.. -Wall -std=c++11 -DWIN32 -pthread -DDEBUG_LOG_FILE="/c/serviceDebug.log"' |
|
|
else |
|
|
else |
|
|
CFLAGS='-I.. -std=c++0x -g -O0 -pthread' |
|
|
|
|
|
|
|
|
CFLAGS='-I.. -Wall -std=c++0x -g -O0 -pthread' |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
g++ $CFLAGS serviceProgram.cpp ../CodeDweller/service.cpp -o serviceProgram |
|
|
|
|
|
|
|
|
progName=serviceProgram |
|
|
|
|
|
|
|
|
|
|
|
g++ $CFLAGS $progName.cpp ../CodeDweller/service.cpp -o $progName |
|
|
if [ $? -ne 0 ] |
|
|
if [ $? -ne 0 ] |
|
|
then |
|
|
then |
|
|
exit -1 |
|
|
|
|
|
|
|
|
exit -1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# Run test. |
|
|
# Run test. |
|
|
logFileName=serviceProgram.log |
|
|
|
|
|
|
|
|
logFileName=$progName.log |
|
|
|
|
|
|
|
|
rm -f $logFileName |
|
|
rm -f $logFileName |
|
|
|
|
|
|
|
|
./serviceProgram $(pwd)/$logFileName |
|
|
|
|
|
|
|
|
if [ "$(uname --operating-system)" == "Msys" ] |
|
|
|
|
|
then |
|
|
|
|
|
sc create "Test Service" binPath= "$(pwd)/$progName.exe" |
|
|
|
|
|
|
|
|
|
|
|
sc start "Test Service" "$(pwd)/$logFileName" |
|
|
|
|
|
sleep 1 |
|
|
|
|
|
|
|
|
|
|
|
sc pause "Test Service" "$(pwd)/$logFileName" |
|
|
|
|
|
sleep 2 |
|
|
|
|
|
|
|
|
PID=$(ps axl | grep -i serviceProgram |grep -v grep | cut -d ' ' -f 4) |
|
|
|
|
|
sleep 1 |
|
|
|
|
|
|
|
|
sc continue "Test Service" "$(pwd)/$logFileName" |
|
|
|
|
|
sleep 2 |
|
|
|
|
|
|
|
|
kill -TSTP $PID |
|
|
|
|
|
sleep 2 |
|
|
|
|
|
|
|
|
sc stop "Test Service" |
|
|
|
|
|
sleep 1 |
|
|
|
|
|
|
|
|
kill -CONT $PID |
|
|
|
|
|
sleep 2 |
|
|
|
|
|
|
|
|
sc delete "Test Service" |
|
|
|
|
|
else |
|
|
|
|
|
./$progName $(pwd)/$logFileName |
|
|
|
|
|
|
|
|
|
|
|
PID=$(ps axl | grep -i $progName |grep -v grep | cut -d ' ' -f 4) |
|
|
|
|
|
sleep 1 |
|
|
|
|
|
|
|
|
|
|
|
kill -TSTP $PID |
|
|
|
|
|
sleep 2 |
|
|
|
|
|
|
|
|
kill -TERM $PID |
|
|
|
|
|
sleep 1 |
|
|
|
|
|
|
|
|
kill -CONT $PID |
|
|
|
|
|
sleep 2 |
|
|
|
|
|
|
|
|
|
|
|
kill -TERM $PID |
|
|
|
|
|
sleep 1 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
if diff --strip-trailing-cr expected_$logFileName $logFileName > /dev/null 2>&1 |
|
|
if diff --strip-trailing-cr expected_$logFileName $logFileName > /dev/null 2>&1 |
|
|
then |
|
|
then |
|
|
echo CodeDweller::Service under Linux: ok |
|
|
|
|
|
|
|
|
echo CodeDweller::Service: ok |
|
|
else |
|
|
else |
|
|
echo CodeDweller::Service under Linux: fail |
|
|
|
|
|
|
|
|
echo CodeDweller::Service: fail |
|
|
fi |
|
|
fi |