diff options
author | luislavena <luislavena@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-04-18 07:09:36 +0000 |
---|---|---|
committer | luislavena <luislavena@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-04-18 07:09:36 +0000 |
commit | 043f49fbeaa9b347b9d7c500334f05a84dd11c51 (patch) | |
tree | e6858bd4e24a1840cb0bb5a7bb1d750aea744bef /projects/mongrel_service/tests/fixtures/mock_process.bas | |
parent | 931818a14a959c9279154ce2edb50f44eecc4e25 (diff) | |
download | unicorn-043f49fbeaa9b347b9d7c500334f05a84dd11c51.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/branches/stable_1-2@1009 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'projects/mongrel_service/tests/fixtures/mock_process.bas')
-rw-r--r-- | projects/mongrel_service/tests/fixtures/mock_process.bas | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/projects/mongrel_service/tests/fixtures/mock_process.bas b/projects/mongrel_service/tests/fixtures/mock_process.bas new file mode 100644 index 0000000..833967c --- /dev/null +++ b/projects/mongrel_service/tests/fixtures/mock_process.bas @@ -0,0 +1,56 @@ +'#--
+'# Copyright (c) 2006-2007 Luis Lavena, Multimedia systems
+'#
+'# This source code is released under the MIT License.
+'# See MIT-LICENSE file for details
+'#++
+
+'# this program mock a common process that will:
+'# output some text to stdout
+'# output some error messages to stderr
+'# will wait until Ctrl-C is hit (only if commandline contains "wait")
+'# or drop an error if commandline contains "error"
+
+#include once "crt.bi"
+#include once "windows.bi"
+
+dim shared stop_hit as BOOL
+
+function _console_handler(byval dwCtrlType as DWORD) as BOOL
+ dim result as BOOL
+
+ if (dwCtrlType = CTRL_C_EVENT) then
+ '# slow response, take 10 seconds...
+ fprintf(stdout, !"out: slow stop\r\n")
+ sleep (10*1000)
+ result = 1
+ stop_hit = TRUE
+ end if
+
+ return result
+end function
+
+sub main()
+ fprintf(stdout, !"out: message\r\n")
+ fprintf(stderr, !"err: error\r\n")
+
+ select case lcase(command(1))
+ case "wait":
+ sleep
+
+ case "error":
+ '# terminate with error code
+ end 1
+
+ case "slow":
+ stop_hit = FALSE
+ SetConsoleCtrlHandler(@_console_handler, 1)
+ do while (stop_hit = FALSE)
+ sleep 15
+ loop
+ SetConsoleCtrlHandler(@_console_handler, 0)
+ end 10
+ end select
+end sub
+
+main()
|