From ef0ca6aef769afa24b903a707019ac84be5940a8 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 13:06:02 -0700 Subject: [PATCH 01/10] Add first unit test using gtest --- .github/workflows/cmake-workflow.yml | 2 +- CMakeLists.txt | 1 + tests/CMakeLists.txt | 21 +++++++++++++++++++++ tests/utility_tests.cpp | 12 ++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/utility_tests.cpp diff --git a/.github/workflows/cmake-workflow.yml b/.github/workflows/cmake-workflow.yml index 3a9895f3..5bfcc2c8 100644 --- a/.github/workflows/cmake-workflow.yml +++ b/.github/workflows/cmake-workflow.yml @@ -2,7 +2,7 @@ name: CMake workflow on: push: - branches: [ "master" ] + branches: [ "G!-1-unit-tests" ] pull_request: branches: [ "master" ] diff --git a/CMakeLists.txt b/CMakeLists.txt index b0f196e0..048c0ac4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,3 +51,4 @@ add_subdirectory( ${PROJECT_BASE_DIR}/utils ) add_subdirectory( ${PROJECT_BASE_DIR}/common ) add_subdirectory( ${PROJECT_BASE_DIR}/camerad ) add_subdirectory( ${PROJECT_BASE_DIR}/emulator ) +add_subdirectory( ${PROJECT_BASE_DIR}/tests ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..ec78a133 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.12) # Or your preferred minimum version + +set(PROJECT_TESTS_DIR ${PROJECT_BASE_DIR}/tests) + +#add_definitions( -Wall -ansi -O2 -Wno-variadic-macros -std=c++17 -ggdb ) + +# Find the Google Test library +find_package(GTest REQUIRED) +include_directories(${GTEST_INCLUDE_DIRS} + ${PROJECT_BASE_DIR}/utils +) +link_directories( ${PROJECT_BASE_DIR}/lib ) + +# Define your unit test executable +add_executable(run_unit_tests utility_tests.cpp) # List all your unit test source files here + +# Link the Google Test library +target_link_libraries(run_unit_tests + ${GTEST_LIBRARIES} + utilities +) diff --git a/tests/utility_tests.cpp b/tests/utility_tests.cpp new file mode 100644 index 00000000..d08daab9 --- /dev/null +++ b/tests/utility_tests.cpp @@ -0,0 +1,12 @@ +#include "gtest/gtest.h" +#include "../utils/utilities.h" + +TEST(UtilitiesTest, TimeStampFromTest) { + struct timespec timezero{}; + EXPECT_EQ(timestamp_from("GMT", timezero), "1970-01-01T00:00:00.000000"); +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} \ No newline at end of file From cccaf9f0767f3f45c67173029f98e9a42aa30313 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 13:06:38 -0700 Subject: [PATCH 02/10] fixe typo in branch name --- .github/workflows/cmake-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake-workflow.yml b/.github/workflows/cmake-workflow.yml index 5bfcc2c8..0d6faaec 100644 --- a/.github/workflows/cmake-workflow.yml +++ b/.github/workflows/cmake-workflow.yml @@ -2,7 +2,7 @@ name: CMake workflow on: push: - branches: [ "G!-1-unit-tests" ] + branches: [ "GT-1-unit-tests" ] pull_request: branches: [ "master" ] From c0c313316339ab441b2e81db88fdae1fd102aba2 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 13:08:31 -0700 Subject: [PATCH 03/10] install gtest dependencies --- .github/workflows/install-deps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/install-deps.sh b/.github/workflows/install-deps.sh index 0080808b..a8b62e1c 100755 --- a/.github/workflows/install-deps.sh +++ b/.github/workflows/install-deps.sh @@ -1,4 +1,5 @@ sudo apt-get update && sudo apt-get install libccfits-dev && sudo apt-get install libcfitsio-dev && -sudo apt-get install libcurl4-openssl-dev \ No newline at end of file +sudo apt-get install libcurl4-openssl-dev && +sudo apt-get install libgtest-dev \ No newline at end of file From 36b2e9e540e4509c5d9d361d7038972446203483 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 13:15:59 -0700 Subject: [PATCH 04/10] clean up cmake file --- tests/CMakeLists.txt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ec78a133..39bf9403 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,18 +1,11 @@ -cmake_minimum_required(VERSION 3.12) # Or your preferred minimum version +cmake_minimum_required(VERSION 3.12) set(PROJECT_TESTS_DIR ${PROJECT_BASE_DIR}/tests) -#add_definitions( -Wall -ansi -O2 -Wno-variadic-macros -std=c++17 -ggdb ) - # Find the Google Test library find_package(GTest REQUIRED) -include_directories(${GTEST_INCLUDE_DIRS} - ${PROJECT_BASE_DIR}/utils -) -link_directories( ${PROJECT_BASE_DIR}/lib ) -# Define your unit test executable -add_executable(run_unit_tests utility_tests.cpp) # List all your unit test source files here +add_executable(run_unit_tests utility_tests.cpp) # List all unit test source files here # Link the Google Test library target_link_libraries(run_unit_tests From a3ae4f687f5895649f8119092c33d8f9cd5a6318 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 13:18:34 -0700 Subject: [PATCH 05/10] add unit tests to github workflow --- .github/workflows/cmake-workflow.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cmake-workflow.yml b/.github/workflows/cmake-workflow.yml index 0d6faaec..2b763672 100644 --- a/.github/workflows/cmake-workflow.yml +++ b/.github/workflows/cmake-workflow.yml @@ -39,6 +39,11 @@ jobs: cd ${{github.workspace}}/build make + - name: Run Unit Tests + run: | + cd ${{github.workspace}} + bin/run_unit_tests + - name: Start Emulator run: | cd ${{github.workspace}} From 60cc601c3d411bc6b5644e940faa38749e954830 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 13:23:25 -0700 Subject: [PATCH 06/10] clean up --- .github/workflows/cmake-workflow.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmake-workflow.yml b/.github/workflows/cmake-workflow.yml index 2b763672..691e1d9c 100644 --- a/.github/workflows/cmake-workflow.yml +++ b/.github/workflows/cmake-workflow.yml @@ -2,7 +2,7 @@ name: CMake workflow on: push: - branches: [ "GT-1-unit-tests" ] + branches: [ "master" ] pull_request: branches: [ "master" ] @@ -13,7 +13,7 @@ env: DETECTOR_TYPE_HXRG: Hxrg jobs: - Archon: + Archon-build: runs-on: ubuntu-latest steps: @@ -25,7 +25,7 @@ jobs: .github/workflows/install-deps.sh shell: bash - - name: Configure CMake Archon + - name: Configure CMake for Archon Interface run: | cd ${{github.workspace}}/build rm -rf * @@ -33,8 +33,7 @@ jobs: cmake -DINTERFACE_TYPE=${{env.INTERFACE_TYPE_ARCHON}} -DDETECTOR_TYPE=${{env.DETECTOR_TYPE_HXRG}} .. - - name: Build Archon - # Build your program with the given configuration + - name: Build run: | cd ${{github.workspace}}/build make @@ -54,7 +53,7 @@ jobs: cd ${{github.workspace}} bin/camerad Config/demo/demo.cfg --foreground & - - name: Run test commands + - name: Run E2E tests run: | cd ${{github.workspace}} shopt -s expand_aliases @@ -77,7 +76,7 @@ jobs: check $command_printstatus # Comment AstroCam out for now - # build-astrocam: + # AstroCam-build: # runs-on: ubuntu-20.04 # steps: From 765909be3cf3ba8a1db7dbc5cb4d3307fceb014d Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 14:34:55 -0700 Subject: [PATCH 07/10] update README --- README.md | 97 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 0118e122..d6ff4619 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,80 @@ -# camera-interface +# Camera Interface + Camera Detector Controller Interface Software -## Requirements: +## Reporting Issues - - Cmake 3.12 or higher - - cfitsio and CCFits libraries (expected in /usr/local/lib) +If you encounter any problems or have questions about this project, please open an issue on the [GitHub Issues page](https://github.com/CaltechOpticalObservatories/camera-interface/issues). Your feedback helps us improve the project! +## Requirements -| Archon controllers | ARC controllers | -| -----------------------| ----------------| -| g++ 8.1 or higher (and c++17) | g++ 8.3 (and c++17) | -| | ARC API 3.6 and Arc66PCIe driver | +- **CMake** 3.12 or higher +- **cfitsio** and **CCFits** libraries (expected in `/usr/local/lib`) +### Controller Compatibility -## Build instructions: +| Archon Controllers | ARC Controllers | +|------------------------------------|----------------------------------------------| +| `g++ 8.1` or higher (and C++17) | `g++ 8.3` (and C++17) | +| | ARC API 3.6 and Arc66PCIe driver | -- change to the build directory +## Build Instructions -- To start with a clean build, delete the contents of the build - directory, including the subdirectory CMakeFiles/, - but not the `.gitignore file`. For example: +1. **Change to the build directory:** -``` - % cd build - % rm -Rf * -``` + ```bash + $ cd build + ``` -- create the Makefile by running cmake (from the build directory), +2. **Start with a clean build:** Delete the contents of the build directory, including the `CMakeFiles/` subdirectory, but **not** the `.gitignore` file. For example: -| Archon | ARC | -|------------------------------|--------------------------------------------------------| -| `$ cmake -DINSTR=generic ..` | `$ cmake -DINSTR=generic -DINTERFACE_TYPE=AstroCam ..` | + ```bash + $ rm -Rf * + ``` +3. **Create the Makefile by running CMake** (from the build directory): -- compile the sources, + | Archon | ARC | + |------------------------|----------------------------------| + | `$ cmake ..` | `$ cmake -DINTERFACE_TYPE=AstroCam ..` | -``` - $ make -``` +4. **Compile the sources:** - - run the program using one of these forms, + ```bash + $ make + ``` -``` - $ ../bin/camerad - $ ../bin/camerad -f - $ ../bin/camerad -d -f -``` +5. **Run the Camera Server:** - where is an appropriate configuration file. See the example .cfg files - in the Config directory of this distribution. Note that the -f option specifies - a config file and the -d option forces it to run as a daemon, overriding any - DAEMON=no setting in the configuration file. + - **As a foreground process:** - - Note that only when INTERFACE_TYPE is set to Archon will the emulator software - be compiled. + ```bash + $ ../bin/camerad --foreground + ``` ---- + - **As a daemon:** + + ```bash + $ ../bin/camerad -d + ``` + + *Replace `` with an appropriate configuration file. See the example `.cfg` files in the `Config` and `Config/demo` directories.* + +6. **(Optional) Run the Archon Emulator:** -David Hale + ```bash + $ ../bin/emulator + ``` + + *Note: The emulator software will only be compiled when `INTERFACE_TYPE` is set to Archon (default).* + +7. **(Optional) Run Unit Tests:** + + ```bash + $ ../bin/run_unit_tests + ``` + +--- +David Hale + \ No newline at end of file From 5bf9fcde5020a8fd2f544f2dd28702a5d41aac38 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 14:38:01 -0700 Subject: [PATCH 08/10] README cleanup --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d6ff4619..8991a40f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ If you encounter any problems or have questions about this project, please open $ cd build ``` -2. **Start with a clean build:** Delete the contents of the build directory, including the `CMakeFiles/` subdirectory, but **not** the `.gitignore` file. For example: +2. **Start with a clean build:** Delete the contents of the build directory, including the `CMakeFiles/` subdirectory, but **not** the `.gitignore` file. ```bash $ rm -Rf * From f4f44c843a8535b3f1a9c212e4cd9fced5fc345b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 14:45:56 -0700 Subject: [PATCH 09/10] add timezone local test --- tests/utility_tests.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/utility_tests.cpp b/tests/utility_tests.cpp index d08daab9..0f0c7531 100644 --- a/tests/utility_tests.cpp +++ b/tests/utility_tests.cpp @@ -1,11 +1,16 @@ #include "gtest/gtest.h" #include "../utils/utilities.h" -TEST(UtilitiesTest, TimeStampFromTest) { +TEST(UtilitiesTest, TimeStampNotLocalTest) { struct timespec timezero{}; EXPECT_EQ(timestamp_from("GMT", timezero), "1970-01-01T00:00:00.000000"); } +TEST(UtilitiesTest, TimeStampLocalTest) { + struct timespec timezero{}; + EXPECT_EQ(timestamp_from("local", timezero), "1969-12-31T16:00:00.000000"); +} + int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); From b1db1784230f01705f040d606918e9d82d21e238 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 1 Aug 2024 14:51:01 -0700 Subject: [PATCH 10/10] remove local timezone test --- tests/utility_tests.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/utility_tests.cpp b/tests/utility_tests.cpp index 0f0c7531..874a9e58 100644 --- a/tests/utility_tests.cpp +++ b/tests/utility_tests.cpp @@ -6,11 +6,6 @@ TEST(UtilitiesTest, TimeStampNotLocalTest) { EXPECT_EQ(timestamp_from("GMT", timezero), "1970-01-01T00:00:00.000000"); } -TEST(UtilitiesTest, TimeStampLocalTest) { - struct timespec timezero{}; - EXPECT_EQ(timestamp_from("local", timezero), "1969-12-31T16:00:00.000000"); -} - int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();