Skip to content

Commit

Permalink
Fix #706, Add location to push CTF scripts and plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dmknutsen committed May 20, 2020
1 parent 95f34d2 commit 7fb2f32
Show file tree
Hide file tree
Showing 16 changed files with 2,754 additions and 0 deletions.
45 changes: 45 additions & 0 deletions ctf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### CFS Test Framework

This repository contains the scripts and plugins used to validate the cFE flight software.


### Getting Started

To get started, clone the CTF repository:

Steps TBD - CTF has not yet been open source released

Note that the CTF repository must be cloned at the same directory level as the cFS repository.


### CTF Prerequisites

CTF has been developed and tested on Linux (CentOS 6 and 7) and requires Python 3.x. CTF_UI requires an insulation of NodeJS/NPM.


### Setup CTF enviroment

To setup ctf environment execute "source setup\_ctf\_env.sh"

If the Anaconda environment is corrupted, the environment can be reinstalled by executing "source setup\_ctf\_env.sh -u"


### Starting the editor

./start_editor.sh


### Running a test script

execute ./run_CTF_script followed by the name of the associated test script contained in the /scripts directory

Example:
./run_CTF_script.sh InvalidCommandCounter_cFE_1285.json

Note that if no test script is passed into run_CTF_script.sh, it will execute all of the test scripts contained within /scripts






6 changes: 6 additions & 0 deletions ctf/ReqValWorkspace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pluginDir": "../../../cfs_gw/tools/ctf/plugins/info/",
"projectDir": "./scripts",
"ccddAppsDir": "../../../cfs_gw/ccdd/json/",
"pythonScript": "../../../cfs_gw/tools/ctf/ctf"
}
166 changes: 166 additions & 0 deletions ctf/ReqValidation_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
#################################
# CTF Core Configuration
#################################

[core]

# Global verification command timeout
# Unit: Seconds if using generic system time manager)

telem_verify_timeout = 15.0

# How often to run verification commands until pass/timeout
# Unit: Seconds if using generic system time manager)
telem_verify_poll_period = 0.5


# Reset plugins between scripts? This is useful if
# scripts assume a fresh state of CFS/Trick_CFS
# If set to false, plugins will not shutdown/re-initialize
# between scripts
reset_plugins_between_scripts = true

# End test on fail?
end_test_on_fail = false

# Disabled plugins (directory name of plugin). Comma-seperated
disabled_plugins =

#################################
# CTF logging
#################################

[logging]

# Output directory for CTF scripts
results_output_dir = ../../../cFS/cfe/ctf/CTF_Results
temp_script_output_dir = ../../../cFS/cfe/ctf/script_outputs

# Filename for CTF Log
ctf_log_file = CTF_Log_File.log

# Generate a json version of the regression_results_summary (true)
# in addition to the text file version
json_results = True

# What level of logging?
# ERROR : only show error logs - very minimal output
# INFO : only show info, warning, error, and critical logs
# DEBUG: show all logs!
log_level = DEBUG

#################################
# ccsds options
#################################
[ccsds]

# Name of the CCSDS Manager to be used by CTF for obtaining CCSDS Message Info
# Note - CTF will search for CCSDS managers under plugins/cfs/ccsds. Ensure that
# the reader class is defined there.
# By default, CTF uses the CCDDExportReader which parses JSON output from the
# provided CCDD scripts under tools/
#
# Other readers can be implemented to handle specific types of CCSDS exports
# such as CSV, XTCE, etc... The custom readers should make use of the interface
# defined in the CCSDSInterface file.

# Filename of custom export reader (without extension)
CCSDS_reader_script_path = ../../../cfs_gw/tools/ctf/plugins/cfs/ccsds/ccdd_export_reader.py
# Classname of custom export reader
CCSDS_reader_class = CCDDExportReader
# Header Info Included in CCSDS Exports?
CCSDS_header_info_included = false

# Module name of CCSDS data types
CCSDS_module = plugins.cfs.ccsds.ccsds_6_7


#################################
# Base settings for cfs
#################################

[cfs]
# cfs protocol setting either:
# local (local host)
# ssh (ssh to host)
# sp0 (sp0 host)
cfs_protocol = local

# Build the CFS project?
build_cfs = true

# Build directory for the CFS project
cfs_build_dir = ../../../cfs_gw

# Build command to run
cfs_build_cmd = make; make install

# Run directory for the CFS project
cfs_run_dir = ../../../cfs_gw/build/exe/lx2

# Executable to run within the cfs_run_dir
cfs_exe = core-lx2

# Include CFS UDP port in arg (-p portNum)?
cfs_port_arg = False

# Additional arguments
cfs_run_args =

# Start CFS on CFS Plugin Initialization or when the StartCfs instruction is sent?
start_cfs_on_init = false

# CCSDS Data Directory
CCSDS_data_dir = ../../../cfs_gw/ccdd/json

# What endianess is the target machine
endianess_of_target = little

# Output directory for CFS EVS
evs_log_file = evs_event_msgs.log

# Run in debug mode using GDB?
cfs_debug = false

# Run in a seperate terminal window as CTF?
cfs_run_in_xterm = True

#ip address of the target system
ip = 127.0.0.1

#CI commanding port
cmd_udp_port = 5010

# Set tlm_udp_port to 0 if you want the os to
# choose the port.
# If you want to manually set tlm_udp_port than set it equal to
# the port you want to use
tlm_udp_port = 5011

# Do you want to use TO or DIAG. Needs to be the exact name of the class to be used
# tlm_app_choice = DiagApi
tlm_app_choice = ToApi

# What CCSDS version
ccsds_ver = 2

# Depth of the EVS_EVENT_MSGID list
evs_tlm_list_depth = 500

# Decimal representation of EVS EVENT MSG MID to collect cfe EVS messages
# Hex: 0x0206 (SET1_CFE_EVS_LONG_EVENT_MSG_MID)
evs_event_msg_mid = 8198

#################################
#
#################################
[ssh]

# Command timeout for the execution plugin
command_timeout = 60

# Print stdout while command is running?
print_stdout = False

# Log stdout when command complete?
log_stdout = True
73 changes: 73 additions & 0 deletions ctf/activate_ctf_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

export INSTALL_DIR=`pwd`
export ANACONDA_VERSION='anaconda3'

platform='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$unamestr" == 'Darwin' ]]; then
platform='darwin'
else
platform='windows'
fi

# See if conda is already setup on this system
if which conda; then
if conda env list | grep pythonEnv3; then
echo 'activate!'
if [[ "$platform" == "windows" ]]; then
source $INSTALL_DIR/$ANACONDA_VERSION/Scripts/activate pythonEnv3
else
source $INSTALL_DIR/$ANACONDA_VERSION/bin/activate pythonEnv3
fi
else
if [[ "$platform" == 'darwin' ]]; then
$INSTALL_DIR/$ANACONDA_VERSION/bin/conda env create -n pythonEnv3 -f=$INSTALL_DIR/pythonEnvironmentMac3.yml
elif [[ "$platform" == 'linux' ]]; then
if [[ "$unamemstr" == 'i686' ]]; then
$INSTALL_DIR/$ANACONDA_VERSION/bin/conda env create -n pythonEnv3 -f=$TOOLS_DIR/pythonEnvironmentLinuxX86.yml
else
$INSTALL_DIR/$ANACONDA_VERSION/bin/conda env create -n pythonEnv3 -f=$TOOLS_DIR/pythonEnvironmentLinux3.yml
fi
else
$INSTALL_DIR/$ANACONDA_VERSION/Scripts/conda env create -n pythonEnv3 -f=$INSTALL_DIR/pythonEnvironmentWindows3.yml
fi
if [[ "$platform" == "windows" ]]; then
source $INSTALL_DIR/$ANACONDA_VERSION/Scripts/activate pythonEnv3
else
source $INSTALL_DIR/$ANACONDA_VERSION/bin/activate pythonEnv3
fi
fi
# If not in system, check if it's installed already
elif [ -d "$INSTALL_DIR/$ANACONDA_VERSION" ]; then
# Install anaconda
if [ ! -d "$INSTALL_DIR/$ANACONDA_VERSION/envs/pythonEnv" ]; then
if [[ "$platform" == 'darwin' ]]; then
$INSTALL_DIR/$ANACONDA_VERSION/bin/conda env create -n pythonEnv -f=$INSTALL_DIR/pythonEnvironmentMac3.yml
elif [[ "$platform" == 'linux' ]]; then
if [[ "$unamemstr" == 'i686' ]]; then
$INSTALL_DIR/$ANACONDA_VERSION/bin/conda env create -n pythonEnv3 -f=$TOOLS_DIR/pythonEnvironmentLinuxX86.yml
else
$INSTALL_DIR/$ANACONDA_VERSION/bin/conda env create -n pythonEnv3 -f=$TOOLS_DIR/pythonEnvironmentLinux3.yml
fi
else
$INSTALL_DIR/$ANACONDA_VERSION/Scripts/conda env create -n pythonEnv -f=$INSTALL_DIR/pythonEnvironmentWindows3.yml
fi
fi
if [[ "$platform" == "windows" ]]; then
source $INSTALL_DIR/$ANACONDA_VERSION/Scripts/activate pythonEnv3
else
source $INSTALL_DIR/$ANACONDA_VERSION/bin/activate pythonEnv3
fi

# If not installed on the system, install it in the home directory
else
echo 'Anaconda not installed'
fi

cd $INSTALL_DIR

alias ctf="$INSTALL_DIR/ctf"
alias ctf_editor="(cd $INSTALL_DIR/tools/ctf_ui && npm start)"
24 changes: 24 additions & 0 deletions ctf/installPlugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import shutil

pluginsInfo = os.listdir('./plugins/info')
for file_name in pluginsInfo:
full_file_name = os.path.join('./plugins/info', file_name)
if os.path.isfile(full_file_name):
shutil.copy(full_file_name, "../../../cfs_gw/tools/ctf/plugins/info")

pluginsCfs = os.listdir("./plugins/cfs")
for file_name in pluginsCfs:
full_file_name = os.path.join('./plugins/cfs', file_name)
if os.path.isfile(full_file_name):
shutil.copy(full_file_name, "../../../cfs_gw/tools/ctf/plugins/cfs")

plugins = os.listdir("./plugins")
for file in plugins:
full_file_name = os.path.join('./plugins', file)
if full_file_name != os.path.join('./plugins',"cfs") and full_file_name != os.path.join('./plugins',"info"):
newFileName = os.path.join('../../../cfs_gw/tools/ctf/plugins', file)
if os. path. isdir(newFileName):
shutil.rmtree(newFileName)
shutil.copytree(full_file_name, newFileName)
print(os.path.join('./plugins', file))
Loading

0 comments on commit 7fb2f32

Please sign in to comment.