mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
Added old trickify test
This commit is contained in:
parent
8afa83a60e
commit
973a473c0e
4
test/SIM_trickified/RUN_test/unit_test.py
Normal file
4
test/SIM_trickified/RUN_test/unit_test.py
Normal file
@ -0,0 +1,4 @@
|
||||
sandbox.foo.i = 5
|
||||
assert sandbox.foo.i == 5
|
||||
foo = trick.Foo()
|
||||
trick.stop(10)
|
21
test/SIM_trickified/S_define
Normal file
21
test/SIM_trickified/S_define
Normal file
@ -0,0 +1,21 @@
|
||||
#include "sim_objects/default_trick_sys.sm"
|
||||
##include "Foo.hh"
|
||||
##include "Bar.hh"
|
||||
##include "Baz.hh"
|
||||
|
||||
class Sandbox : public Trick::SimObject {
|
||||
|
||||
public:
|
||||
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
Baz baz;
|
||||
|
||||
Sandbox() {
|
||||
(1, "scheduled") foo.foo();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Sandbox sandbox;
|
2
test/SIM_trickified/S_overrides.mk
Normal file
2
test/SIM_trickified/S_overrides.mk
Normal file
@ -0,0 +1,2 @@
|
||||
include trickified_project/trickified/myproject.mk
|
||||
TRICK_CXXFLAGS += -I$(CURDIR)/models
|
9
test/SIM_trickified/models/Baz.hh
Normal file
9
test/SIM_trickified/models/Baz.hh
Normal file
@ -0,0 +1,9 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
class Baz {
|
||||
|
||||
public:
|
||||
int i;
|
||||
int j;
|
||||
|
||||
};
|
17
test/SIM_trickified/trickified_project/include/Bar.hh
Normal file
17
test/SIM_trickified/trickified_project/include/Bar.hh
Normal file
@ -0,0 +1,17 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include "trick/Event.hh"
|
||||
|
||||
/**
|
||||
* Induce an `%import sim_services` statement in this class's Python module by inheriting from a
|
||||
* Trick class. This allows us to test if `sys.path` contains the correct path to `sim_services.py`
|
||||
* (and other modules generated during a sim build) for Trickified projects.
|
||||
*/
|
||||
class Bar : public Trick::Event {
|
||||
|
||||
int process(long long) {return 0;}
|
||||
void add() {}
|
||||
void remove() {}
|
||||
void restart() {}
|
||||
|
||||
};
|
15
test/SIM_trickified/trickified_project/include/Foo.hh
Normal file
15
test/SIM_trickified/trickified_project/include/Foo.hh
Normal file
@ -0,0 +1,15 @@
|
||||
// @trick_parse{everything}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class Foo {
|
||||
|
||||
public:
|
||||
|
||||
int i;
|
||||
|
||||
void foo() {
|
||||
std::cout << i++ << '\n';
|
||||
}
|
||||
|
||||
};
|
4
test/SIM_trickified/trickified_project/trickified/.gitignore
vendored
Normal file
4
test/SIM_trickified/trickified_project/trickified/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
build
|
||||
python
|
||||
trick
|
||||
*.o
|
11
test/SIM_trickified/trickified_project/trickified/Makefile
Normal file
11
test/SIM_trickified/trickified_project/trickified/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
PROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
|
||||
TRICK_HOME := $(abspath $(PROJECT_HOME)/../../..)
|
||||
|
||||
export TRICKIFY_OBJECT_NAME := trickified_myproject.o
|
||||
export TRICKIFY_CXX_FLAGS := -I$(PROJECT_HOME)/include -I$(TRICK_HOME)/include
|
||||
|
||||
all:
|
||||
@$(MAKE) -s -f $(TRICK_HOME)/share/trick/makefiles/trickify.mk
|
||||
|
||||
clean:
|
||||
@rm -rf build python trick $(TRICKIFY_OBJECT_NAME)
|
@ -0,0 +1,38 @@
|
||||
# We know this file's position relative to the root directory of the project,
|
||||
# and MAKEFILE_LIST will give us the full path to this file no matter where the
|
||||
# user has installed this project.
|
||||
export MYPROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)
|
||||
|
||||
# Specify include paths for your headers.
|
||||
MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include
|
||||
|
||||
# Users may set different flags for C and C++, so you should really modify both
|
||||
# to be safe.
|
||||
TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
|
||||
|
||||
MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/trickified_myproject.o
|
||||
|
||||
# Tell Trick the headers and source at this location are part of a
|
||||
# Trickified project
|
||||
TRICK_EXT_LIB_DIRS += :$(MYPROJECT_HOME)
|
||||
|
||||
# Tell Trick where to find the Python modules generated by SWIG
|
||||
TRICK_PYTHON_PATH += :$(MYPROJECT_HOME)/trickified/python
|
||||
|
||||
# Tell SWIG where to find py_*.i files
|
||||
TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified
|
||||
|
||||
# Link in the Trickified object
|
||||
TRICK_LDFLAGS += $(MYPROJECT_TRICK)
|
||||
|
||||
# Append a prerequisite to the $(SWIG_SRC) target. This will build the
|
||||
# Trickified library along with the sim if it does not already exist. Using
|
||||
# $(SWIG_SRC) ensures that all Trickified .i files are created before SWIG is
|
||||
# run on any simulation .i files, which may %import them. Note that this does
|
||||
# NOT cause the Trickified library to be rebuilt if it already exists, even if
|
||||
# the Trickified source code has changed.
|
||||
$(SWIG_SRC): $(MYPROJECT_TRICK)
|
||||
|
||||
$(MYPROJECT_TRICK):
|
||||
@$(MAKE) -s -C $(MYPROJECT_HOME)/trickified
|
@ -114,6 +114,13 @@ SIM_threads:
|
||||
runs:
|
||||
RUN_test/unit_test.py:
|
||||
returns: 0
|
||||
SIM_trickified:
|
||||
path: test/SIM_trickified
|
||||
build_args: "-t"
|
||||
binary: "T_main_{cpu}_test.exe"
|
||||
runs:
|
||||
RUN_test/unit_test.py:
|
||||
returns: 0
|
||||
SIM_trickified_object:
|
||||
path: test/SIM_trickified_object
|
||||
build_args: "-t"
|
||||
|
Loading…
Reference in New Issue
Block a user