Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial work for e2e tests for hotfire #207

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions projects/HotFire/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#define USE_GPIO 1
#endif

#define GPIO_COUNT 5

#if USE_GPIO == 1
#ifndef USE_WIRING_Pi
#define USE_WIRING_Pi 1
Expand Down
16 changes: 16 additions & 0 deletions src/IO/SensorLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ void SensorLogger::writeHeader(std::ofstream &fileStream, StateData currentState
fileStream << "deltaAngleZ,";
#endif

#if USE_SENSOR_MAX_31865
fileStream << "temperature,";
#endif

// Initialization data
#if USE_LOGGER
fileStream << "loggerInitialized, ";
Expand Down Expand Up @@ -310,6 +314,14 @@ void SensorLogger::writeData(std::ofstream &fileStream, const StateData &current
{
fileStream << output.second << sep;
}
// for (std::pair<std::string, int> output : currentState.gpioState.digitalStateMap)
// {
// fileStream << output.second << sep;
// }
// for (std::pair<std::string, int> output : currentState.gpioState.pwmStateMap)
// {
// fileStream << output.second << sep;
// }
#endif

#if USE_SBG == 1
Expand Down Expand Up @@ -374,6 +386,10 @@ void SensorLogger::writeData(std::ofstream &fileStream, const StateData &current
fileStream << currentState.sbg.deltaAngleZ << sep;
#endif

// #if USE_SENSOR_MAX_31865
// fileStream << currentState.sensorState.temperature << sep;
// #endif

// Initialization data
#if USE_LOGGER
fileStream << currentState.loggerIsInitialized << sep;
Expand Down
20 changes: 20 additions & 0 deletions src/IO/TestingSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@ void TestingSensors::initialize()

// Will keep increasing by one for each read
int count = 0;
std::cout << currentRow.size() << "\n";

currentData.timeStamp = boost::lexical_cast<uint64_t>(currentRow[count++]);

// Ignore the state, that's an output value
count++;

#if USE_GPIO == 1
// these are outputs, skip
count += GPIO_COUNT; //todo: * 2
#endif

std::cout << count << "\n";
std::cout << currentRow[count] << "\n";

#if USE_SBG == 1
// SBG:
currentData.sbg.roll = boost::lexical_cast<float>(currentRow[count++]);
Expand Down Expand Up @@ -106,13 +115,20 @@ void TestingSensors::initialize()

#endif

// #if USE_SENSOR_MAX_31865
// currentData.sensorState.temperature = boost::lexical_cast<float>(currentRow[count++]);
// #endif

std::cout << currentRow[count] << "\n";

// Initialization data
#if USE_LOGGER == 1
currentData.loggerIsInitialized = boost::lexical_cast<bool>(currentRow[count++]);
#endif

#if USE_SOCKET_CLIENT == 1
currentData.clientIsInitialized = boost::lexical_cast<bool>(currentRow[count++]);
currentData.lastActiveClientTimestamp = boost::lexical_cast<uint64_t>(currentRow[count++]);
#endif

#if USE_SBG == 1
Expand All @@ -131,6 +147,10 @@ void TestingSensors::initialize()
currentData.gpioIsInitialized = boost::lexical_cast<bool>(currentRow[count++]);
#endif

#if USE_ARDUINO_PROXY == 1
currentData.arduinoProxyIsInitialized = boost::lexical_cast<bool>(currentRow[count++]);
#endif

data.push(currentData);
}

Expand Down
1 change: 1 addition & 0 deletions tests/hotfire/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output
451 changes: 451 additions & 0 deletions tests/hotfire/input.txt

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions tests/hotfire/output-expected/0.uorocketlog

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions tests/hotfire/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

rm -rf output

mkdir -p output

TEST_PATH=/tests/hotfire/

export TESTING=1
export HOTFIRE_TEST=1
export TARGET_UPDATE_DURATION_NS=0
export LOG_PATH=".${TEST_PATH}output/"
export TESTING_INPUT_FILE=".${TEST_PATH}input.txt"

cd ../../
./build-and-run.sh "${1}" "MainLoop"

cd .${TEST_PATH}

FAIL=0
for file in ./output-expected/*; do
if ! diff "$file" "./output/${file##*/}"; then
FAIL=1
printf "\nError in the following file: ${file##*/}\n\n"
fi
done

if [[ $FAIL = "1" ]]; then
exit 1
fi