You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

buildAndRun 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. if [ "$(uname --operating-system)" == "Msys" ]
  2. then
  3. CFLAGS='-I.. -Wall -std=c++11 -DWIN32 -pthread -DDEBUG_LOG_FILE="/c/serviceDebug.log"'
  4. else
  5. CFLAGS='-I.. -Wall -std=c++0x -g -O0 -pthread'
  6. fi
  7. progName=serviceProgram
  8. g++ $CFLAGS $progName.cpp ../CodeDweller/service.cpp -o $progName
  9. if [ $? -ne 0 ]
  10. then
  11. exit -1
  12. fi
  13. # Run test.
  14. logFileName=$progName.log
  15. rm -f $logFileName
  16. if [ "$(uname --operating-system)" == "Msys" ]
  17. then
  18. sc create "Test Service" binPath= "$(pwd)/$progName.exe"
  19. sc start "Test Service" "$(pwd)/$logFileName"
  20. sleep 1
  21. sc pause "Test Service" "$(pwd)/$logFileName"
  22. sleep 2
  23. sc continue "Test Service" "$(pwd)/$logFileName"
  24. sleep 2
  25. sc stop "Test Service"
  26. sleep 1
  27. sc delete "Test Service"
  28. else
  29. ./$progName $(pwd)/$logFileName
  30. PID=$(ps axl | grep -i $progName |grep -v grep | cut -d ' ' -f 4)
  31. sleep 1
  32. kill -TSTP $PID
  33. sleep 2
  34. kill -CONT $PID
  35. sleep 2
  36. kill -TERM $PID
  37. sleep 1
  38. fi
  39. if diff --strip-trailing-cr expected_$logFileName $logFileName > /dev/null 2>&1
  40. then
  41. echo CodeDweller::Service: ok
  42. else
  43. echo CodeDweller::Service: fail
  44. fi