-
Notifications
You must be signed in to change notification settings - Fork 3
[RSDK-11808] - Add unit tests #35
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
Changes from all commits
ca12582
f7bbbb1
5070d48
aaa5d4d
964c0c0
ab9d598
e4475fa
7c6161f
f352060
f97445f
f7b72de
3b21cde
917938c
a7ab8d9
5998fee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Unit Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - '*' | ||
| paths-ignore: | ||
| - 'README.md' | ||
| - 'docs/**' | ||
| pull_request: | ||
| branches: | ||
| - '*' | ||
| paths-ignore: | ||
| - 'README.md' | ||
| - 'docs/**' | ||
|
|
||
| jobs: | ||
| unit-test: | ||
| name: Unit Tests | ||
| runs-on: buildjet-2vcpu-ubuntu-2204-arm | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - container: ghcr.io/viam-modules/csi-camera/viam-cpp-base-jetson:0.0.6 | ||
| TARGET: jetson | ||
|
|
||
| container: | ||
| image: ${{ matrix.container }} | ||
| options: --platform linux/arm64 | ||
|
|
||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set environment variables | ||
| run: | | ||
| echo "TARGET=${{ matrix.TARGET }}" >> $GITHUB_ENV | ||
| echo "META_PATH=${{ matrix.META_PATH }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Install module dependencies | ||
| run: make dep | ||
|
|
||
| - name: Build viam-csi binary | ||
| run: make build | ||
|
|
||
| - name: Run unit tests | ||
| run: | | ||
| export VIAM_CSI_DEVICE=${{ matrix.TARGET }} | ||
| export VIAM_CSI_TEST_MODE=1 | ||
| ctest --test-dir build --rerun-failed --output-on-failure -VV |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ etc/appimage-build | |
| **/.DS_Store | ||
| gha-creds-*.json | ||
| .vscode | ||
| *Testing | ||
| *squashfs-root* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ dep: | |
| apt-get update && \ | ||
| if [ "$(TARGET)" = "jetson" ]; then \ | ||
| apt-get -y install libgtest-dev && \ | ||
| apt-get install -y gstreamer1.0-tools && \ | ||
| apt-get install -y gstreamer1.0-tools gstreamer1.0-plugins-good && \ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need this to run test piepline on Ubuntu |
||
| apt-get install -y libgstreamer1.0-dev \ | ||
| libgstreamer-plugins-base1.0-dev \ | ||
| libgstreamer-plugins-good1.0-dev \ | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,28 @@ | ||
| #include <gtest/gtest.h> | ||
| #include <cstdlib> | ||
| #include <viam/sdk/common/instance.hpp> | ||
| #include <viam/sdk/common/proto_convert.hpp> | ||
| #include <viam/sdk/components/camera.hpp> | ||
|
|
||
| #include "../constraints.h" | ||
| #include "../csi_camera.cpp" | ||
| #include "../utils.cpp" | ||
| #include "../../constraints.h" | ||
| #include "../../csi_camera.cpp" | ||
| #include "../../utils.cpp" | ||
|
|
||
| using namespace viam::sdk; | ||
|
|
||
| // One-time runtime bootstrap to initialize Viam SDK Instance and GStreamer | ||
| static void ensure_runtime() { | ||
| static bool inited = false; | ||
| if (inited) | ||
| return; | ||
| static Instance inst; | ||
| gst_init(nullptr, nullptr); | ||
| inited = true; | ||
| } | ||
|
|
||
| // Test that the camera can be created with default values | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a follow up, it would be great to be able to inject pictures and make sure to receive them. |
||
| TEST(CSICamera, CreateDefault) { | ||
| gst_init(nullptr, nullptr); | ||
| ensure_runtime(); | ||
|
|
||
| ProtoStruct attrs = std::unordered_map<std::string, ProtoValue>(); | ||
|
|
||
|
|
@@ -26,7 +38,7 @@ TEST(CSICamera, CreateDefault) { | |
|
|
||
| // Test that the camera can be created with custom values | ||
| TEST(CSICamera, CreateCustom) { | ||
| gst_init(nullptr, nullptr); | ||
| ensure_runtime(); | ||
|
|
||
| ProtoStruct attrs = std::unordered_map<std::string, ProtoValue>(); | ||
| attrs.insert(std::make_pair("width_px", ProtoValue(640))); | ||
|
|
@@ -59,8 +71,6 @@ TEST(CSICamera, StartStopPipeline) { | |
|
|
||
| camera.stop_pipeline(); | ||
|
|
||
| pipeline = camera.get_pipeline(); | ||
| appsink = camera.get_appsink(); | ||
| EXPECT_EQ(GST_STATE(pipeline), GST_STATE_NULL); | ||
| EXPECT_EQ(GST_STATE(appsink), GST_STATE_NULL); | ||
| EXPECT_EQ(camera.get_pipeline(), nullptr); | ||
| EXPECT_EQ(camera.get_appsink(), nullptr); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small fix here for integration test triggers