Commit 57a4bd41 authored by Marco Buttu's avatar Marco Buttu
Browse files

Fix #147: python library for testing

parent 0494a2f9
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
PY_PACKAGES = PyMinorServoTest

# CPP UNIT TESTING SETUP
#--------------
# GTEST_HOME=/usr/local/include/gtest
@@ -62,7 +60,6 @@ clean_test:
	rm -f pyunit/*.pyc
	rm -f external/*.pyc
	rm -rf ../lib/python/site-packages/*
	rm -rf $(INTROOT)/lib/python/site-packages/PyMinorServoTest*

unit: do_unit
	@echo " . . . 'unit' done"
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#    None
#------------------------------------------------------------------------


#
# Modules in the various ACS sub-packages.
#
@@ -29,7 +30,7 @@

SUBSYSTEM = Libraries 

MODULES =  SlaLibrary IRALibrary TextWindowLibrary ParserLibrary PyACSWrapper
MODULES =  PyACSWrapper PyTesting


MAKE_FLAGS = "-k"
+34 −0
Original line number Diff line number Diff line
#*****************************************
#-----------------------------------------
# Marco Buttu <mbuttu@oa-cagliari.inaf.it>
#-----------------------------------------
#*****************************************

PY_PACKAGES = testing

# -----------------
# Include Standards
# -----------------

MAKEDIRTMP := $(shell searchFile include/acsMakefile)
ifneq ($(MAKEDIRTMP),\#error\#)
   MAKEDIR := $(MAKEDIRTMP)/include
   include $(MAKEDIR)/acsMakefile
endif


# TARGETS
all:	do_all
	@echo " . . . 'all' done" 

clean : clean_all 
	$(RM) *.pyc testing/*.pyc
	$(RM) ../lib ../bin ../config ../doc ../idl ../include \
		  ../object ../rtai ../test
	$(RM) $(INTROOT)/lib/python/site-packages/testing*
	@echo " . . . clean done"

install : install_all
	@echo " . . . installation done"

#___oOo___
+7 −6
Original line number Diff line number Diff line
@@ -6,16 +6,16 @@ import unittest
import subprocess


def run(test_case):
    # Use the simulators and the testing CDB
    server_name = 'srt-mscu' if test_case.telescope == 'SRT' else ''
    if not server_name:
def run(test_case, server_name='antenna'):
    # In case of `server_name=='antenna'`, the simulator will not
    # be run because we are exectuting the tests on the real hardware
    if server_name == 'antenna':
        sys.exit(0) 

    try:
        FNULL = open(os.devnull, 'w')
        process = subprocess.Popen(
            '%s-sim start' % server_name, stdout=FNULL, stderr=FNULL,
            '%s start' % server_name, stdout=FNULL, stderr=FNULL,
            shell=True, preexec_fn=os.setsid)
        time.sleep(1) # Give the server the time to start
        suite = unittest.TestSuite()
@@ -24,6 +24,7 @@ def run(test_case):
        print 'Running the tests using the antenna simulators...'
        unittest.TextTestRunner(verbosity=2).run(suite)
    finally:
        os.killpg(os.getpgid(process.pid), signal.SIGTERM) 
        subprocess.Popen('%s stop' % server_name, shell=True)
        time.sleep(2) # Give the server the time to stop
        os.killpg(os.getpgid(process.pid), signal.SIGTERM) 
        FNULL.close()
Loading