diff --git a/.github/workflows/cmake-workflow.yml b/.github/workflows/cmake-workflow.yml index 3a9895f3..691e1d9c 100644 --- a/.github/workflows/cmake-workflow.yml +++ b/.github/workflows/cmake-workflow.yml @@ -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,12 +33,16 @@ 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 + - name: Run Unit Tests + run: | + cd ${{github.workspace}} + bin/run_unit_tests + - name: Start Emulator run: | cd ${{github.workspace}} @@ -49,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 @@ -72,7 +76,7 @@ jobs: check $command_printstatus # Comment AstroCam out for now - # build-astrocam: + # AstroCam-build: # runs-on: ubuntu-20.04 # steps: 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 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/README.md b/README.md index 0118e122..8991a40f 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. -| 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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..39bf9403 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.12) + +set(PROJECT_TESTS_DIR ${PROJECT_BASE_DIR}/tests) + +# Find the Google Test library +find_package(GTest REQUIRED) + +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 + ${GTEST_LIBRARIES} + utilities +) diff --git a/tests/utility_tests.cpp b/tests/utility_tests.cpp new file mode 100644 index 00000000..874a9e58 --- /dev/null +++ b/tests/utility_tests.cpp @@ -0,0 +1,12 @@ +#include "gtest/gtest.h" +#include "../utils/utilities.h" + +TEST(UtilitiesTest, TimeStampNotLocalTest) { + 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