Skip to content

Commit

Permalink
Image Generator v1 (#8)
Browse files Browse the repository at this point in the history
* Generator Working

* Makefile Update (no valgrind, better flags and gtest caching

* Refractored main program for integration testing, aliased src folder to run from outside tools

* Added address sanitizer to test suite

* Starting Integration testing

* First Integration Test

* Integration Tests Mostly Complete

* Integration Test Done

* Documentation Complete

* Corrected build.yml to use found-test, not lost-test

* Option to disable ASAN for valgrind
  • Loading branch information
nguy8tri authored Feb 26, 2025
1 parent 3863509 commit 1493f27
Show file tree
Hide file tree
Showing 23 changed files with 2,382 additions and 289 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:

- name: Test (Twice)
run: (make test || make test)
- name: Memory Check
run: (make clean) && (make test OMIT_ASAN=true) && ((valgrind ./build/bin/found-test) || (valgrind ./build/bin/found-test))

lint:
runs-on: ubuntu-latest
Expand Down
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ build
.vscode

# Don't include google test stuff
googletest*
googletest*
**.tar.gz
.cache

# Don't include python stuff
**__pycache__
**.pytest_cache

# Don't include personally generated images
**.png
852 changes: 582 additions & 270 deletions Doxyfile

Large diffs are not rendered by default.

37 changes: 25 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SRC_DIR := src
TEST_DIR := test
LIB_DIR := libraries
BUILD_DIR := build
CACHE_DIR := .cache

# Define directory with binaries
BIN_DIR := $(BUILD_DIR)/bin
Expand Down Expand Up @@ -32,6 +33,7 @@ BUILD_DOCUMENTATION_COVERAGE_DIR := $(BUILD_DOCUMENTATION_DIR)/coverage
GTEST := googletest
GTEST_VERSION := release-1.12.1
GTEST_URL := https://github.com/google/$(GTEST)/archive/$(GTEST_VERSION).tar.gz
GTEST_ARTIFACT := $(CACHE_DIR)/$(GTEST_VERSION).tar.gz
GTEST_DIR := $(BUILD_LIBRARY_TEST_DIR)/$(GTEST)-$(GTEST_VERSION)
GTEST_BUILD_DIR := $(GTEST_DIR)/build

Expand Down Expand Up @@ -61,11 +63,15 @@ TEST_LIBS := $(SRC_LIBS) -I. # We need to include SRC_LIBS here for the test sui
LIBS := $(SRC_LIBS)
LIBS_TEST := -I$(GTEST_DIR)/$(GTEST)/include -I$(GTEST_DIR)/googlemock/include -pthread
DEBUG_FLAGS := -ggdb -fno-omit-frame-pointer
COVERAGE_FLAGS := -fprofile-arcs -ftest-coverage
COVERAGE_FLAGS := --coverage
CXXFLAGS := $(CXXFLAGS) -Ilibraries -Idocumentation -Wall -Wextra -Wno-missing-field-initializers -pedantic --std=c++11 $(LIBS)
CXXFLAGS_TEST := $(CXXFLAGS) $(LIBS_TEST)
ifdef OMIT_ASAN
CXXFLAGS_TEST := $(CXXFLAGS) $(LIBS_TEST)
else
CXXFLAGS_TEST := $(CXXFLAGS) $(LIBS_TEST) -fsanitize=address -fomit-frame-pointer
endif
LDFLAGS := # Any dynamic libraries go here
LDFLAGS_TEST := $(LDFLAGS) -L$(GTEST_BUILD_DIR)/lib -lgtest -lgtest_main -lgmock -lgmock_main -pthread -lgcov
LDFLAGS_TEST := $(LDFLAGS) -L$(GTEST_BUILD_DIR)/lib -lgtest -lgtest_main -lgmock -lgmock_main -pthread

# Targets
COMPILE_SETUP_TARGET := compile_setup
Expand All @@ -78,6 +84,7 @@ GOOGLE_STYLECHECK_TEST_TARGET := google_stylecheck_test
PRIVATE_TARGET := private
DOXYGEN_TARGET := doxygen_generate
CLEAN_TARGET := clean
CLEAN_ALL_TARGET := clean_all

# Options configurations
ifdef DEBUG
Expand Down Expand Up @@ -144,32 +151,33 @@ $(TEST_SETUP_TARGET): $(COMPILE_SETUP_TARGET) test_setup_message $(BUILD_LIBRARY
$(BUILD_LIBRARY_TEST_DIR):
mkdir -p $(BUILD_LIBRARY_TEST_DIR)
mkdir -p $(BUILD_DOCUMENTATION_COVERAGE_DIR)
mkdir -p $(CACHE_DIR)
test_setup_message:
$(call PRINT_TARGET_HEADER, $(TEST_SETUP_TARGET))

# The test target
$(TEST_TARGET): $(TEST_SETUP_TARGET) test_message $(TEST_BIN)
$(TEST_BIN): $(GTEST_DIR) $(TEST_OBJS) $(BIN_DIR)
$(CXX) $(CXXFLAGS_TEST) -o $(TEST_BIN) $(TEST_OBJS) $(LIBS) $(LDFLAGS_TEST)
$(CXX) $(CXXFLAGS_TEST) $(COVERAGE_FLAGS) -o $(TEST_BIN) $(TEST_OBJS) $(LIBS) $(LDFLAGS_TEST)
$(BUILD_TEST_DIR)/%.o: $(TEST_DIR)/%.cpp $(GTEST_DIR) $(BUILD_DIR)
mkdir -p $(@D)
$(CXX) $(TEST_LIBS) $(COVERAGE_FLAGS) $(CXXFLAGS_TEST) -c $< -o $@
$(BUILD_TEST_DIR)/%.o: $(SRC_DIR)/%.cpp $(GTEST_DIR) $(BUILD_DIR)
mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(COVERAGE_FLAGS) -c $< -o $@ $(SRC_LIBS)
$(GTEST_DIR): $(BUILD_DIR)
wget $(GTEST_URL)
tar -xzf $(GTEST_VERSION).tar.gz -C $(BUILD_LIBRARY_TEST_DIR)
rm -f $(GTEST_VERSION).tar.gz
$(CXX) $(CXXFLAGS) $(COVERAGE_FLAGS) $(CXXFLAGS_TEST) -c $< -o $@ $(SRC_LIBS)
$(GTEST_DIR): $(BUILD_DIR) $(GTEST_ARTIFACT)
tar -xzf $(GTEST_ARTIFACT) -C $(BUILD_LIBRARY_TEST_DIR)
mkdir -p $(GTEST_BUILD_DIR)
cd $(GTEST_BUILD_DIR) && cmake .. && make
$(GTEST_ARTIFACT):
wget $(GTEST_URL) -P $(CACHE_DIR)
test_message:
$(call PRINT_TARGET_HEADER, $(TEST_TARGET))

# The coverage target
$(COVERAGE_TARGET): $(TEST_SETUP_TARGET) $(TEST_TARGET)
$(call PRINT_TARGET_HEADER, $(COVERAGE_TARGET))
valgrind ./$(TEST_BIN)
./$(TEST_BIN)
gcovr || $(PASS_ON_COVERAGE_FAIL)

# The stylecheck target for tests
Expand All @@ -195,7 +203,12 @@ $(DOXYGEN_TARGET): $(COMPILE_SETUP_TARGET)
chmod +rwx doxygen.sh
./doxygen.sh

# The clean target (not in default target)
# The clean target (not in default target, cleans just the build folder)
$(CLEAN_TARGET):
$(call PRINT_TARGET_HEADER, $(CLEAN_TARGET))
rm -rf build
rm -rf $(BUILD_DIR)

# The clean_all target (cleans the build and cache folders)
$(CLEAN_ALL_TARGET):
$(call PRINT_TARGET_HEADER, $(CLEAN_ALL_TARGET))
rm -rf $(BUILD_DIR) $(CACHE_DIR)
8 changes: 3 additions & 5 deletions src/spatial/attitude-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ Mat3 Mat3::Inverse() const {
/// 3x3 identity matrix
const Mat3 kIdentityMat3 = {1,0,0,
0,1,0,
0,0,1};
0,0,1}; // NOLINT


///////////////////////////////////
Expand All @@ -637,8 +637,7 @@ const Mat3 kIdentityMat3 = {1,0,0,
* @param quat The quaternion to base the attitude off of
*
*/
Attitude::Attitude(const Quaternion &quat)
: quaternion(quat), type(QuaternionType) {}
Attitude::Attitude(const Quaternion &quat) : quaternion(quat), type(QuaternionType) {}

/**
* Constructs an Attitude object from a Direction Cosine Matrix (A
Expand All @@ -647,8 +646,7 @@ Attitude::Attitude(const Quaternion &quat)
* @param matrix The matrix holding the direction cosines
*
*/
Attitude::Attitude(const Mat3 &matrix)
: dcm(matrix), type(DCMType) {}
Attitude::Attitude(const Mat3 &matrix) : dcm(matrix), type(DCMType) {}

/**
* Creates a Direction Cosine Matrix (DCM) off of a Quaternion.
Expand Down
3 changes: 2 additions & 1 deletion test/pipeline/pipeline-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <string>
#include <vector>
#include <memory>

#include "src/pipeline/pipeline.hpp"

Expand Down Expand Up @@ -205,7 +206,7 @@ TEST_F(PipelineTest, TestPipelineBeginningPipelineInPipeline) {
TEST_F(PipelineTest, TestPipelineMiddlePipelineInPipeline) {
INIT_CHAR_TO_DOUBLE_PIPELINE(outerPipeline, stages);

int test_set = 4;
int test_set = 2;

std::unique_ptr<MockStage<char, int>> outerStage1(new MockStage<char, int>());
EXPECT_CALL(*outerStage1, Run(characters[test_set]))
Expand Down
5 changes: 5 additions & 0 deletions tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import sys
from pathlib import Path

# Add this folder temporarily to the system path
sys.path.insert(0, str(Path(__file__).resolve().parents[0]))
4 changes: 4 additions & 0 deletions tools/generator/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import runpy

# Alias to run actual source code
runpy.run_module("generator.src", run_name="__main__", alter_sys=True)
9 changes: 9 additions & 0 deletions tools/generator/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: generator_env
channels:
- conda-forge
- defaults
dependencies:
- python>=3.10 # You can change the Python version if needed
- numpy
- pycairo
- pytest
5 changes: 5 additions & 0 deletions tools/generator/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import sys
from pathlib import Path

# Add the 'src' directory to sys.path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
Loading

0 comments on commit 1493f27

Please sign in to comment.