Split test sims and fun sims into separate directories.

Moved most of the rest of the sims to test.

refs #191
This commit is contained in:
Alex Lin 2016-02-23 16:19:30 -06:00
parent cf0ac7a5a1
commit 9ddc786ace
47 changed files with 199 additions and 259 deletions

View File

@ -6,7 +6,7 @@ PURPOSE:
#include "sim_objects/default_trick_sys.sm" #include "sim_objects/default_trick_sys.sm"
##include "test/allocation/include/AllocTest.hh" ##include "allocation/include/AllocTest.hh"
class AllocTestSimObject : public Trick::SimObject { class AllocTestSimObject : public Trick::SimObject {

View File

@ -0,0 +1,4 @@
TRICK_CFLAGS += -I./models
TRICK_CXXFLAGS += -I./models

View File

@ -4,7 +4,7 @@ def main():
trick.exec_add_sim_object(ball, "ball") trick.exec_add_sim_object(ball, "ball")
# instead of using collect, we are using a class specific add_external_force # instead of using collect, we are using a class specific add_external_force
# function that accepts a "double *" and is checkpointable. # function that accepts a "double *" and is checkpointable.
ball.obj.state.add_external_force( ball.obj.force.output.force ) #ball.obj.state.add_external_force( ball.obj.force.output.force )
# declare a new Integrator loop sim object # declare a new Integrator loop sim object
my_integ_loop = trick.IntegLoopSimObject(0.01, 0, ball, None, TMMName="my_integ_loop") ; my_integ_loop = trick.IntegLoopSimObject(0.01, 0, ball, None, TMMName="my_integ_loop") ;
@ -14,15 +14,15 @@ def main():
my_integ_loop.integ_sched.rebuild_jobs() my_integ_loop.integ_sched.rebuild_jobs()
# Data recording Ascii # Data recording Ascii
drg0 = trick.DRAscii("Ball") #drg0 = trick.DRAscii("Ball")
for param in [ 'position' , 'velocity' , 'acceleration' , 'external_force' ] : #for param in [ 'position' , 'velocity' , 'acceleration' , 'external_force' ] :
for index in range(0,2) : # for index in range(0,2) :
var = "ball.obj.state.output." + param + "[" + str(index) + "]" # var = "ball.obj.state.output." + param + "[" + str(index) + "]"
drg0.add_variable(var) # drg0.add_variable(var)
drg0.set_cycle(0.01) #drg0.set_cycle(0.01)
drg0.freq = trick.DR_Always #drg0.freq = trick.DR_Always
drg0.thisown = 0 #drg0.thisown = 0
trick.add_data_record_group(drg0, trick.DR_Buffer) #trick.add_data_record_group(drg0, trick.DR_Buffer)
trick.checkpoint(120.0) trick.checkpoint(120.0)
trick.stop(300.0) trick.stop(300.0)

View File

@ -0,0 +1,24 @@
/************************TRICK HEADER*************************
PURPOSE:
(blah blah blah)
LIBRARY DEPENDENCIES:
(
)
*************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "sim_services/Integrator/include/integrator_c_intf.h"
class ballSimObject : public Trick::SimObject {
public:
/** Constructor to add the jobs */
ballSimObject() {
("integration") trick_ret = integrate() ;
}
} ;
// No instantiations made in this S_define file. They are made in the input file.

View File

@ -9,7 +9,6 @@ LIBRARY DEPENDENCIES:
#include "sim_objects/default_trick_sys.sm" #include "sim_objects/default_trick_sys.sm"
##include "Ball++/L1/include/Ball.hh"
%{ %{
int Leaker() ; int Leaker() ;
%} %}

View File

@ -0,0 +1,3 @@
TRICK_CFLAGS += -I./models
TRICK_CXXFLAGS += -I./models

View File

@ -3,7 +3,6 @@
#include <string.h> #include <string.h>
/* Model include files. */ /* Model include files. */
#include "Ball++/L1/include/Ball.hh"
#include "sim_services/MemoryManager/include/memorymanager_c_intf.h" #include "sim_services/MemoryManager/include/memorymanager_c_intf.h"
std::vector< int > dv ; std::vector< int > dv ;
@ -12,30 +11,20 @@ std::vector< int > dv ;
int Leaker() { int Leaker() {
int * i_malloc = (int *)malloc( sizeof(int) ) ; int * i_malloc = (int *)malloc( sizeof(int) ) ;
Ball * b_malloc = (Ball *)malloc( sizeof(Ball) ) ;
int * i_calloc = (int *)calloc( 1 , sizeof(int) ) ; int * i_calloc = (int *)calloc( 1 , sizeof(int) ) ;
Ball * b_calloc = (Ball *)calloc( 1 , sizeof(Ball) ) ;
#if 0 #if 0
int * i_realloc = NULL ; int * i_realloc = NULL ;
Ball * b_realloc = NULL ;
i_realloc = (int *)realloc( i_realloc, sizeof(int) ) ; i_realloc = (int *)realloc( i_realloc, sizeof(int) ) ;
b_realloc = (Ball *)realloc( b_realloc, sizeof(Ball) ) ;
#endif #endif
int * i_new = new int ; int * i_new = new int ;
Ball * b_new = new Ball ;
int * ia_new = new int[10] ; int * ia_new = new int[10] ;
Ball * ba_new = new Ball[10] ;
char * str = strdup("hello") ; char * str = strdup("hello") ;
Ball * b_tmms = (Ball *)TMM_declare_var_s("Ball") ;
Ball * b_tmm1d = (Ball *)TMM_declare_var_1d("Ball", 2) ;
Ball * b_tmmal = (Ball *)alloc_type(2, "Ball") ;
int ii ; int ii ;
for ( ii = 0 ; ii < 100 ; ii++ ) { for ( ii = 0 ; ii < 100 ; ii++ ) {
dv.push_back(ii) ; dv.push_back(ii) ;

View File

@ -1,4 +1,4 @@
TRICK_CFLAGS += -I${TRICK_HOME}/trick_models TRICK_CFLAGS += -I./models
TRICK_CXXFLAGS += -I${TRICK_HOME}/trick_models -std=c++11 TRICK_CXXFLAGS += -I./models -std=c++11

View File

@ -2,18 +2,18 @@
PURPOSE: ( S_define ) PURPOSE: ( S_define )
LIBRARY DEPENDENCIES: LIBRARY DEPENDENCIES:
( (
(test/varserv/src/VS.cpp) (varserv/src/VS.cpp)
(test/varserv/src/VS_init.cpp) (varserv/src/VS_init.cpp)
(test/varserv/src/VS_default_data.cpp) (varserv/src/VS_default_data.cpp)
(test/varserv/src/VS_commands.cpp) (varserv/src/VS_commands.cpp)
(test/varserv/src/VS_tests.cpp) (varserv/src/VS_tests.cpp)
(test/varserv/src/VS_shutdown.cpp) (varserv/src/VS_shutdown.cpp)
) )
*************************************************************/ *************************************************************/
#include "sim_objects/default_trick_sys.sm" #include "sim_objects/default_trick_sys.sm"
##include "test/varserv/include/VS.hh" ##include "varserv/include/VS.hh"
class testSimObject : public Trick::SimObject { class testSimObject : public Trick::SimObject {
public: public:

View File

@ -0,0 +1,4 @@
TRICK_CFLAGS += -I./models
TRICK_CXXFLAGS += -I./models

1
test/SIM_trickcomm/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
tc_server

View File

@ -0,0 +1,3 @@
trick.real_time_enable()
trick.exec_set_terminate_time(5.0)

View File

@ -0,0 +1,56 @@
/************************TRICK HEADER*************************
PURPOSE:
( This S_define is to be used with RUN_trickcomm input file )
*************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "test_struct.h"
// Put an extern line for attrTEST_DATA_STRUCT in S_source.hh
// Don't let SWIG process the line
%header{
##ifndef SWIG
extern ATTRIBUTES attrTEST_DATA_STRUCT[] ;
##endif
%}
class CannonSimObject : public Trick::SimObject {
public:
TCDevice connection ;
TEST_DATA_STRUCT tds ;
TEST_DATA_STRUCT read_tds ;
/* Initialize client's connection to server */
void init_comm() {
connection.port = 9000 ;
connection.hostname = strdup("localhost") ;
connection.disable_handshaking = TC_COMM_TRUE ;
tc_connect( &connection ) ;
}
void send_test() {
usleep(100) ;
fprintf(stderr, "before write int1 =%x int2 =%x\n", tds.int1 , tds.int2 ) ;
fprintf(stderr, "before write long1=%lx long2=%lx\n", tds.long1 , tds.long2 ) ;
tc_write_byteswap( &connection, (char *)&tds, sizeof(TEST_DATA_STRUCT), attrTEST_DATA_STRUCT) ;
tc_read_byteswap( &connection, (char *)&read_tds, sizeof(TEST_DATA_STRUCT), attrTEST_DATA_STRUCT) ;
fprintf(stderr, "after read int1 =%x int2 =%x\n", read_tds.int1 , read_tds.int2 ) ;
fprintf(stderr, "after read long1=%lx long2=%lx\n", read_tds.long1 , read_tds.long2 ) ;
}
CannonSimObject() : connection() , tds() {
tds.int1 = 1234 ;
tds.int2 = 5678 ;
tds.long1 = 8888 ;
tds.long2 = 9999 ;
("initialization") init_comm() ;
(1.0, "scheduled") send_test() ;
}
} ;
// Instantiations
CannonSimObject dyn ;

View File

@ -0,0 +1,14 @@
TRICK_CFLAGS += -I.
TRICK_CXXFLAGS += -I.
S_main: tc_server
tc_server: tc_server.c
${TRICK_CC} ${TRICK_CFLAGS} ${TRICK_SYSTEM_CFLAGS} -I${TRICK_HOME}/trick_source -o $@ $< -L${TRICK_LIB_DIR} -ltrick_comm ${TRICK_EXEC_LINK_LIBS}
clean: clean_tc_apps
spotless: clean_tc_apps
clean_tc_apps:
${RM} -f tc_server

View File

@ -0,0 +1,50 @@
#include <stdio.h>
#include <string.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <unistd.h>
#include "test_struct.h"
int main () {
int nbytes ;
TEST_DATA_STRUCT tds ;
int on = 1;
int listen_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);;
struct sockaddr_in s_in;
setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, (socklen_t) sizeof(on));
setsockopt(listen_socket, IPPROTO_TCP, TCP_NODELAY, (const char *) &on, (socklen_t) sizeof(on));
memset(&s_in, 0 , sizeof(struct sockaddr_in)) ;
s_in.sin_family = AF_INET;
s_in.sin_addr.s_addr = INADDR_ANY ;
s_in.sin_port = htons((short)9000);
bind(listen_socket, (struct sockaddr *)&s_in, sizeof(s_in)) ;
listen(listen_socket, SOMAXCONN) ;
socklen_t length;
int connection = accept(listen_socket, (struct sockaddr *) &s_in, &length);
setsockopt(connection, IPPROTO_TCP, TCP_NODELAY, (const void *) &on, (socklen_t) sizeof(on));
struct sockaddr_in cliAddr;
struct sockaddr_in remoteServAddr;
unsigned int cliLen = sizeof(struct sockaddr_in);
nbytes = 1 ;
while( nbytes > 0 ) {
nbytes = recvfrom(connection, &tds, sizeof(TEST_DATA_STRUCT),
MSG_NOSIGNAL, (struct sockaddr *) &cliAddr, &cliLen) ;
fprintf(stderr, "nbytes = %d\n", nbytes ) ;
fprintf(stderr, "tc_server int1 =%x int2 =%x\n", tds.int1 , tds.int2 ) ;
fprintf(stderr, "tc_server long1=%lx long2=%lx\n", tds.long1 , tds.long2 ) ;
if ( nbytes == sizeof(TEST_DATA_STRUCT)) {
sendto(connection, &tds, sizeof(TEST_DATA_STRUCT), MSG_NOSIGNAL,
(struct sockaddr *) &remoteServAddr,
(socklen_t) sizeof(struct sockaddr_in)) ;
}
}
return 0 ;
}

View File

@ -0,0 +1,16 @@
#ifndef TEST_STRUCT_H
#define TEST_STRUCT_H
typedef struct {
int int1; /* -- Foo */
int int2; /* -- Foo */
long long1; /* -- Foo */
long long2; /* -- Foo */
double double1; /* -- Foo */
double double2; /* -- Foo */
} TEST_DATA_STRUCT ;
#endif

View File

@ -1,38 +0,0 @@
/************************TRICK HEADER*************************
PURPOSE:
(blah blah blah)
LIBRARY DEPENDENCIES:
(
)
*************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "Ball++/L1/include/Ball.hh"
/**
This class is the base ball class
*/
class ballSimObject : public Trick::SimObject {
public:
/** The actual ball object */
Ball obj ;
/** Constructor to add the jobs */
ballSimObject() {
("initialization") obj.state_init() ;
("derivative") obj.force_field() ;
("derivative") obj.state_deriv() ;
("integration") trick_ret = obj.state_integ() ;
{BLUE} (10.0, "scheduled") trick_ret = obj.state_print() ;
{BLUE} (1.0, "freeze_scheduled") trick_ret = obj.state_print() ;
("shutdown") obj.shutdown() ;
}
} ;
// No instantiations made in this S_define file. They are made in the input file.

View File

@ -1,4 +0,0 @@
TRICK_CFLAGS += -I${TRICK_HOME}/trick_models
TRICK_CXXFLAGS += -I${TRICK_HOME}/trick_models

View File

@ -1,3 +0,0 @@
TRICK_CFLAGS += -I${TRICK_HOME}/trick_models
TRICK_CXXFLAGS += -I${TRICK_HOME}/trick_models

View File

@ -1,4 +0,0 @@
TRICK_CFLAGS += -I${TRICK_HOME}/trick_models
TRICK_CXXFLAGS += -I${TRICK_HOME}/trick_models

View File

@ -1,4 +0,0 @@
tc_client
tc_client.dSYM
tc_server
tc_server.dSYM

View File

@ -1,17 +0,0 @@
global DR_GROUP_ID
global drg
try:
if DR_GROUP_ID >= 0:
DR_GROUP_ID += 1
except NameError:
DR_GROUP_ID = 0
drg = []
drg.append(trick.DRAscii("cannon"))
drg[DR_GROUP_ID].set_freq(trick.DR_Always)
drg[DR_GROUP_ID].set_cycle(0.01)
drg[DR_GROUP_ID].set_single_prec_only(False)
drg[DR_GROUP_ID].add_variable("dyn.cannon.pos[0]")
drg[DR_GROUP_ID].add_variable("dyn.cannon.pos[1]")
trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer)
drg[DR_GROUP_ID].enable()

View File

@ -1,7 +0,0 @@
execfile("Modified_data/cannon.dr")
trick.exec_set_sim_object_onoff("server", False) ;
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4)
trick.exec_set_terminate_time(5.2)

View File

@ -1,59 +0,0 @@
/************************TRICK HEADER*************************
PURPOSE:
( This S_define is to be used with RUN_trickcomm input file )
LIBRARY_DEPENDENCY:
(
(cannon/gravity/src/cannon_deriv_impact.c)
(cannon/gravity/src/cannon_integ.c)
(cannon/gravity/src/cannon_impact.c)
(cannon/gravity/src/cannon_init.c)
(cannon/gravity/src/cannon_default_data.c)
(cannon/gravity/src/cannon_init_comm.c)
(cannon/gravity/src/cannon_send_position.c)
)
*************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "cannon/gravity/include/cannon.h"
##include "cannon/gravity/include/cannon_comm_proto.h"
/*class ServerSimObject : public Trick::SimObject {
public:
ServerSimObject() {
("initialization") main() ;
}
} ;
ServerSimObject server ;
*/
class CannonSimObject : public Trick::SimObject {
public:
CANNON cannon ;
CannonSimObject() {
("default_data") cannon_default_data( &cannon ) ;
("initialization") cannon_init( &cannon ) ;
("initialization") cannon_init_comm( &cannon ) ;
("initialization") cannon_send_position( &cannon ) ;
("derivative") cannon_deriv_impact( &cannon ) ;
("integration") trick_ret = cannon_integ( &cannon ) ;
("dynamic_event") cannon_impact( &cannon) ;
(0.01, "scheduled") cannon_send_position( &cannon ) ;
}
} ;
// Instantiations
CannonSimObject dyn ;
IntegLoop dyn_integloop (0.01) dyn ;

View File

@ -1,17 +0,0 @@
TRICK_CFLAGS += -I${TRICK_HOME}/trick_models
TRICK_CXXFLAGS += -I${TRICK_HOME}/trick_models
S_main: tc_server tc_client
tc_server: tc_server.c
${TRICK_CC} ${TRICK_CFLAGS} ${TRICK_SYSTEM_CFLAGS} -I${TRICK_HOME}/trick_source -o $@ $< -L${TRICK_LIB_DIR} -ltrick_comm ${TRICK_EXEC_LINK_LIBS}
tc_client: tc_client.c
${TRICK_CC} ${TRICK_CFLAGS} ${TRICK_SYSTEM_CFLAGS} -I${TRICK_HOME}/trick_source -o $@ $< -L${TRICK_LIB_DIR} -ltrick_comm ${TRICK_EXEC_LINK_LIBS}
clean: clean_tc_apps
spotless: clean_tc_apps
clean_tc_apps:
${RM} -rf tc_server tc_client

View File

@ -1,29 +0,0 @@
#include <string.h>
#include "trick_utils/comm/include/tc.h"
#include "trick_utils/comm/include/tc_proto.h"
int main( int narg, char** args) {
TCDevice connection;
double x, y ;
memset(&connection, '\0', sizeof(TCDevice)) ;
connection.port = 9000;
connection.hostname = (char*) malloc(16);
strcpy(connection.hostname, "localhost");
tc_connect(&connection);
x = 123.45;
y = 67.89 ;
tc_write(&connection, (char*) &x, sizeof(double));
tc_write(&connection, (char*) &y, sizeof(double));
tc_disconnect(&connection) ;
return 0;
}

View File

@ -1,32 +0,0 @@
#define send_hs fprintf
#include <stdio.h>
#include <string.h>
#include "trick_utils/comm/include/tc.h"
#include "trick_utils/comm/include/tc_proto.h"
int main (int narg, char** args)
{
double x, y;
int nbytes ;
TCDevice listen_device ;
TCDevice connection ;
memset(&listen_device, '\0', sizeof(TCDevice)) ;
memset(&connection, '\0', sizeof(TCDevice)) ;
listen_device.port = 9000;
tc_init(&listen_device) ;
tc_accept(&listen_device, &connection) ;
while(tc_isValid(&connection)) {
nbytes = tc_read(&connection, (char*) &x, sizeof(double));
nbytes = tc_read(&connection, (char*) &y, sizeof(double));
fprintf(stderr, "x=%lf y=%lf \n", x, y) ;
}
return 0 ;
}

View File

@ -6,6 +6,7 @@ COMPILE_DIRS = \
Ball/SIM_ball_L1 \ Ball/SIM_ball_L1 \
Ball/SIM_ball_L2 \ Ball/SIM_ball_L2 \
Ball/SIM_ball_L3 \ Ball/SIM_ball_L3 \
Ball/SIM_ball_default_data \
Cannon/SIM_amoeba \ Cannon/SIM_amoeba \
Cannon/SIM_cannon_aero \ Cannon/SIM_cannon_aero \
Cannon/SIM_cannon_analytic \ Cannon/SIM_cannon_analytic \
@ -16,21 +17,16 @@ COMPILE_DIRS = \
Cannon/SIM_cannon_jet \ Cannon/SIM_cannon_jet \
SIM_Ball++_L1 \ SIM_Ball++_L1 \
SIM_satellite \ SIM_satellite \
SIM_sun \ SIM_sun
SIM_target
#SIM_ball_default_data \
#SIM_monte \ #SIM_monte \
#SIM_trickcomm
# This test is temporarily sitting out until fixed.
# SIM_test_varserv
# List out sims we want to run unit tests # List out sims we want to run unit tests
TEST_DIRS = \ TEST_DIRS = \
Ball/SIM_ball_L1 \ Ball/SIM_ball_L1 \
Ball/SIM_ball_L2 \ Ball/SIM_ball_L2 \
Ball/SIM_ball_L3 \ Ball/SIM_ball_L3 \
Ball/SIM_ball_default_data \
Cannon/SIM_amoeba \ Cannon/SIM_amoeba \
Cannon/SIM_cannon_aero \ Cannon/SIM_cannon_aero \
Cannon/SIM_cannon_analytic \ Cannon/SIM_cannon_analytic \
@ -40,15 +36,10 @@ TEST_DIRS = \
Cannon/SIM_cannon_integ \ Cannon/SIM_cannon_integ \
Cannon/SIM_cannon_jet \ Cannon/SIM_cannon_jet \
SIM_Ball++_L1 \ SIM_Ball++_L1 \
SIM_sun \ SIM_sun
SIM_target
#SIM_ball_default_data \
#SIM_monte \ #SIM_monte \
# This test is temporarily sitting out until fixed.
# SIM_test_varserv
EXECUTABLES = $(addsuffix /T_main_${TRICK_HOST_CPU}_test.exe, $(COMPILE_DIRS)) EXECUTABLES = $(addsuffix /T_main_${TRICK_HOST_CPU}_test.exe, $(COMPILE_DIRS))
UNIT_TEST_RESULTS = $(addprefix $(TRICK_HOME)/trick_test/, $(addsuffix .xml, $(TEST_DIRS))) UNIT_TEST_RESULTS = $(addprefix $(TRICK_HOME)/trick_test/, $(addsuffix .xml, $(TEST_DIRS)))