use pytest for cpp tests (#29833)

* add pytest-cpp package (#29828)

* add pytest-cpp package

* disable for now

* use in ci

* use pytest cpp

* use my branch

* add missing tests

* that doesn't make sense

* it was merged upstream

* replace TEST_RLOG_URL with a publicly accessible url

* PR Cleanup

* assert instead

* update poetry lock

* add comment about  pytest-cpp

---------

Co-authored-by: Justin Newberry <jnewberry0502@gmail.com>
Co-authored-by: Justin Newberry <justin@comma.ai>
Co-authored-by: deanlee <deanlee3@gmail.com>
old-commit-hash: 2c1dfc2f34
test-msgs
Adeeb Shihadeh 2 years ago committed by GitHub
parent 5bac1f771c
commit 1f8459d285
  1. 9
      .github/workflows/selfdrive_tests.yaml
  2. 4
      poetry.lock
  3. 7
      pyproject.toml
  4. 2
      system/loggerd/tests/test_logger.cc
  5. 1
      system/proclogd/tests/test_proclog.cc
  6. 3
      tools/cabana/tests/test_cabana.cc

@ -263,18 +263,11 @@ jobs:
timeout-minutes: 40 timeout-minutes: 40
run: | run: |
${{ env.RUN }} "export SKIP_LONG_TESTS=1 && \ ${{ env.RUN }} "export SKIP_LONG_TESTS=1 && \
$PYTEST -n auto --dist=loadscope --timeout 30 && \ $PYTEST -n auto --dist=loadscope --timeout 30 -o cpp_files=test_* && \
selfdrive/locationd/test/_test_locationd_lib.py && \ selfdrive/locationd/test/_test_locationd_lib.py && \
./system/ubloxd/tests/test_glonass_runner && \
./selfdrive/ui/tests/create_test_translations.sh && \ ./selfdrive/ui/tests/create_test_translations.sh && \
QT_QPA_PLATFORM=offscreen ./selfdrive/ui/tests/test_translations && \ QT_QPA_PLATFORM=offscreen ./selfdrive/ui/tests/test_translations && \
./selfdrive/ui/tests/test_translations.py && \ ./selfdrive/ui/tests/test_translations.py && \
./common/tests/test_common && \
./selfdrive/boardd/tests/test_boardd_usbprotocol && \
./system/loggerd/tests/test_logger &&\
./system/proclogd/tests/test_proclog && \
./tools/replay/tests/test_replay && \
./tools/cabana/tests/test_cabana && \
./system/camerad/test/ae_gray_test && \ ./system/camerad/test/ae_gray_test && \
./selfdrive/test/process_replay/test_fuzzy.py" ./selfdrive/test/process_replay/test_fuzzy.py"
- name: "Upload coverage to Codecov" - name: "Upload coverage to Codecov"

4
poetry.lock generated

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:67782a76e85d8c34a5788be14f8c89dcab1db5dfacf2a1d7ba249655a1adffcb oid sha256:4c0f51084dfff5d6966e1e4a55e0bf6ab8933725ccaef366eed4debaccc61edc
size 438592 size 437544

@ -1,6 +1,7 @@
[tool.pytest.ini_options] [tool.pytest.ini_options]
minversion = "6.0" minversion = "6.0"
addopts = "--ignore=openpilot/ --ignore=cereal/ --ignore=opendbc/ --ignore=panda/ --ignore=rednose_repo/ --ignore=tinygrad_repo/ --ignore=laika_repo/ -Werror --strict-config --strict-markers --durations=10" addopts = "--ignore=openpilot/ --ignore=cereal/ --ignore=opendbc/ --ignore=panda/ --ignore=rednose_repo/ --ignore=tinygrad_repo/ --ignore=laika_repo/ -Werror --strict-config --strict-markers --durations=10"
#cpp_files = "test_*" # uncomment when agnos has pytest-cpp and remove from CI
python_files = "test_*.py" python_files = "test_*.py"
#timeout = "30" # you get this long by default #timeout = "30" # you get this long by default
markers = [ markers = [
@ -18,9 +19,12 @@ testpaths = [
"selfdrive/test/longitudinal_maneuvers", "selfdrive/test/longitudinal_maneuvers",
"system/hardware/tici", "system/hardware/tici",
"system/loggerd", "system/loggerd",
"system/proclogd",
"system/tests", "system/tests",
"system/ubloxd", "system/ubloxd",
"tools/lib/tests" "tools/lib/tests",
"tools/replay",
"tools/cabana"
] ]
[tool.mypy] [tool.mypy]
@ -142,6 +146,7 @@ pygame = "*"
pyprof2calltree = "*" pyprof2calltree = "*"
pytest = "*" pytest = "*"
pytest-cov = "*" pytest-cov = "*"
pytest-cpp = "*"
pytest-subtests = "*" pytest-subtests = "*"
pytest-xdist = "*" pytest-xdist = "*"
pytest-timeout = "*" pytest-timeout = "*"

@ -97,7 +97,7 @@ TEST_CASE("logger") {
auto logging_thread = [&]() -> void { auto logging_thread = [&]() -> void {
LoggerHandle *lh = logger_get_handle(&logger); LoggerHandle *lh = logger_get_handle(&logger);
REQUIRE(lh != nullptr); assert(lh != nullptr);
int segment = main_segment; int segment = main_segment;
int delayed_cnt = 0; int delayed_cnt = 0;
while (!do_exit) { while (!do_exit) {

@ -140,7 +140,6 @@ TEST_CASE("buildProcLogerMessage") {
REQUIRE(p.getName() == "test_proclog"); REQUIRE(p.getName() == "test_proclog");
REQUIRE(p.getState() == 'R'); REQUIRE(p.getState() == 'R');
REQUIRE_THAT(p.getExe().cStr(), Catch::Matchers::Contains("test_proclog")); REQUIRE_THAT(p.getExe().cStr(), Catch::Matchers::Contains("test_proclog"));
REQUIRE(p.getCmdline().size() == 1);
REQUIRE_THAT(p.getCmdline()[0], Catch::Matchers::Contains("test_proclog")); REQUIRE_THAT(p.getCmdline()[0], Catch::Matchers::Contains("test_proclog"));
} else { } else {
std::string cmd_path = "/proc/" + std::to_string(p.getPid()) + "/cmdline"; std::string cmd_path = "/proc/" + std::to_string(p.getPid()) + "/cmdline";

@ -6,8 +6,7 @@
#include "tools/cabana/dbc/dbcmanager.h" #include "tools/cabana/dbc/dbcmanager.h"
#include "tools/cabana/streams/abstractstream.h" #include "tools/cabana/streams/abstractstream.h"
// demo route, first segment const std::string TEST_RLOG_URL = "https://commadataci.blob.core.windows.net/openpilotci/0c94aa1e1296d7c6/2021-05-05--19-48-37/0/rlog.bz2";
const std::string TEST_RLOG_URL = "https://commadata2.blob.core.windows.net/commadata2/a2a0ccea32023010/2023-07-27--13-01-19/0/rlog.bz2";
TEST_CASE("DBCFile::generateDBC") { TEST_CASE("DBCFile::generateDBC") {
QString fn = QString("%1/%2.dbc").arg(OPENDBC_FILE_PATH, "tesla_can"); QString fn = QString("%1/%2.dbc").arg(OPENDBC_FILE_PATH, "tesla_can");

Loading…
Cancel
Save