Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -5,11 +5,11 @@ SRCFILES = common.scm items.scm launch.scm \ ods.scm runconfig.scm server.scm configf.scm \ db.scm keys.scm margs.scm megatest-version.scm \ process.scm runs.scm tasks.scm tests.scm genexample.scm \ fs-transport.scm zmq-transport.scm http-transport.scm \ - client.scm gutils.scm synchash.scm + client.scm gutils.scm synchash.scm daemon.scm GUISRCF = dashboard-tests.scm dashboard-guimonitor.scm OFILES = $(SRCFILES:%.scm=%.o) GOFILES = $(GUISRCF:%.scm=%.o) ADDED daemon.scm Index: daemon.scm ================================================================== --- /dev/null +++ daemon.scm @@ -0,0 +1,45 @@ +;; Taken from the chicken 3.x daemon egg +;; +;; Copyright (c) 2007 Hans Bulfone +;; All rights reserved. +;; +;; Redistribution and use in source and binary forms, with or without +;; modification, are permitted provided that the following conditions are met: +;; +;; * Redistributions of source code must retain the above copyright notice, +;; this list of conditions and the following disclaimer. +;; * Redistributions in binary form must reproduce the above copyright +;; notice, this list of conditions and the following disclaimer in the +;; documentation and/or other materials provided with the distribution. +;; * Neither the name of the author nor the names of his contributors may +;; be used to endorse or promote products derived from this software +;; without specific prior written permission. +;; +;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +;; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +;; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +;; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +;; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +;; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +;; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(declare (unit daemon)) + +(define (daemon:ize) + (change-directory "/") + (let ((fd-r (file-open "/dev/null" open/rdonly)) + (fd-w (file-open "/dev/null" open/wronly))) + (duplicate-fileno fd-r 0) + (duplicate-fileno fd-w 1) + (file-close fd-r) + (file-close fd-w)) + (let ((child-pid (process-fork))) + (if (not (zero? child-pid)) + (exit 0))) + (create-session) + (duplicate-fileno 1 2) + (void)) Index: http-transport.scm ================================================================== --- http-transport.scm +++ http-transport.scm @@ -274,10 +274,11 @@ (if (not (setup-for-run)) (begin (debug:print 0 "ERROR: cannot find megatest.config, exiting") (exit)))) (debug:print-info 2 "Starting the standalone server") + (daemon:ize) (let ((hostinfo (open-run-close tasks:get-best-server tasks:open-db))) (debug:print 11 "http-transport:launch hostinfo=" hostinfo) ;; #(1 "143.182.207.24" 5736 -1 "http" 22771 "hostname") (if hostinfo (debug:print-info 2 "NOT starting new server, one is already running on " (vector-ref hostinfo 1) ":" (vector-ref hostinfo 2)) Index: megatest.scm ================================================================== --- megatest.scm +++ megatest.scm @@ -218,11 +218,10 @@ ;; queries "-test-paths" ;; get path(s) to a test, ordered by youngest first "-runall" ;; run all tests "-remove-runs" - "-usequeue" "-rebuild-db" "-rollup" "-update-meta" "-gen-megatest-area" @@ -289,11 +288,29 @@ ;;====================================================================== (if (args:get-arg "-server") (let ((transport (args:get-arg "-transport" "http"))) (debug:print 2 "Launching server using transport " transport) - (server:launch (string->symbol transport)))) + (server:launch (string->symbol transport))) + (if (not (null? (lset-intersection + equal? + (hash-table-keys args:arg-hash) + '("-runtests" "-list-runs" "-rollup" + "-remove-runs" "-lock" "-unlock" + "-update-meta" "-extract-ods")))) + (if (setup-for-run) + (let ((servers (open-run-close tasks:get-best-server tasks:open-db))) + (if (or (not servers) + (null? servers)) + (begin + (debug:print 0 "INFO: Starting server as none running ...") + ;; (server:launch (string->symbol (args:get-arg "-transport" "http")))) + (system (conc (car (argv)) " -server - -transport " (args:get-arg "-transport" "http"))) + (thread-sleep! 3)) ;; give the server a few seconds to start + (debug:print 0 "INFO: Servers already running " servers) + ))))) + (if (args:get-arg "-list-servers") ;; (args:get-arg "-kill-server")) (let ((tl (setup-for-run))) (if tl Index: server.scm ================================================================== --- server.scm +++ server.scm @@ -20,10 +20,11 @@ (declare (uses db)) (declare (uses tasks)) ;; tasks are where stuff is maintained about what is running. (declare (uses synchash)) (declare (uses http-transport)) (declare (uses zmq-transport)) +(declare (uses daemon)) (include "common_records.scm") (include "db_records.scm") (define (server:make-server-url hostport) Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -20,14 +20,14 @@ all : test1 test2 test3 test4 test5 server : (cd ..;make;make install) && \ - (cd fullrun;../../bin/megatest -server - -debug 22) & + (cd fullrun;../../bin/megatest -server - -debug 22) test0 : cleanprep - cd simplerun ; $(MEGATEST) -server - -debug $(DEBUG)& + cd simplerun ; $(MEGATEST) -server - -debug $(DEBUG) test1 : cleanprep rm -f simplerun/megatest.db rm -rf simplelinks/ simpleruns/ mkdir -p simplelinks simpleruns ADDED tests/fullrun/tests/priority_3/README Index: tests/fullrun/tests/priority_3/README ================================================================== --- /dev/null +++ tests/fullrun/tests/priority_3/README @@ -0,0 +1,3 @@ +This test used to look for envfile.txt but that file should NOT have been there. + +By changing to lookithome.log it is possible that an error is masked. Index: tests/fullrun/tests/priority_3/main.sh ================================================================== --- tests/fullrun/tests/priority_3/main.sh +++ tests/fullrun/tests/priority_3/main.sh @@ -6,11 +6,11 @@ sleep 2 $MT_MEGATEST -step step$i :state end :status 0 done # get a previous test -export EZFAILPATH=`$MT_MEGATEST -test-files envfile.txt -target $MT_TARGET :runname $MT_RUNNAME -testpatt ez_fail` +export EZFAILPATH=`$MT_MEGATEST -test-files lookithome.log -target $MT_TARGET :runname $MT_RUNNAME -testpatt ez_fail` if [[ -e $EZFAILPATH ]];then echo All good! else echo NOT good! exit 1 Index: tests/simplerun/megatest.config ================================================================== --- tests/simplerun/megatest.config +++ tests/simplerun/megatest.config @@ -5,11 +5,11 @@ [setup] # Adjust max_concurrent_jobs to limit how much you load your machines max_concurrent_jobs 50 # This is your link path, you can move it but it is generally better to keep it stable -linktree #{shell realpath #{getenv PWD}/../simplelinks} +linktree #{shell readlink -f #{getenv PWD}/../simplelinks} # Valid values for state and status for steps, NB// It is not recommended you use this [validvalues] state start end completed @@ -22,6 +22,6 @@ [env-override] EXAMPLE_VAR example value # As you run more tests you may need to add additional disks, the names are arbitrary but must be unique [disks] -disk0 #{shell realpath #{getenv PWD}/../simpleruns} +disk0 #{shell readlink -f #{getenv PWD}/../simpleruns}