Skip to content
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

[CI] Run unit tests #476

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

[CI] Run unit tests #476

wants to merge 6 commits into from

Conversation

FabioBatSilva
Copy link

@FabioBatSilva FabioBatSilva commented Apr 18, 2022

Few things going on here:

  • add github action to runs unit tests on push
  • fix the make file that downloads gtest
  • cleanup some warnings/errors on the existing tests

You can see the pipeline running here:
https://github.com/FabioBatSilva/vesc-bldc/actions/runs/2184912510
FabioBatSilva#1

I believe actions is enable by default..
So it should run after this gets merged unless the configs for the repo have it disabled.
https://docs.github.com/en/[email protected]/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#managing-github-actions-permissions-for-your-repository

see:
https://docs.github.com/en/actions

GoogleTest is packaged in subdirectory.

  ls -lah  downloads/googletest-release-1.11.0/*
    drwxrwxr-x 2 4.0K Jun 11  2021 ci
    drwxrwxr-x 8 4.0K Jun 11  2021 googlemock
    drwxrwxr-x 9 4.0K Jun 11  2021 googletest
    # ....

First download the zip file, then unzip to a tmp dir and finaly move googletest
to tools directory
This will ignore warning in gtest
since it is not compatible with some of the flags beeing enforced

  gtest.cc:1266:43:
  error: implicit conversion from ‘float’ to ‘double’ to match other
  operand of binary expression [-Werror=double-promotion]
   1266 |         costs[l_i + 1][r_i + 1] = replace + 1.00001;
        |                                   ~~~~~~~~^~~~~~~~~
Compile with -O1 to make inline functions compatible with gcc

  utils_math.c:582: undefined reference to `utils_truncate_number'
    error: ld returned 1 exit status
 Unused variable ret causes error :

 unittest.cpp: In member function ‘virtual void Saturate2dVector_ValsOnEdgeOfRange_Test::TestBody()’:
  unittest.cpp:291:9: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
    291 |    bool ret;
        |         ^~~
@@ -18,7 +18,7 @@ CXXFLAGS += -g -Wall -Wextra -Wno-missing-field-initializers -std=c++11
LDFLAGS += -lpthread

# Google Test requires visibility of gtest includes
GTEST_CXXFLAGS := -I$(GTEST_DIR)
GTEST_CXXFLAGS := -isystem $(GTEST_DIR)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will ignore the double-promotion warnings on gtest.

gtest.cc:1266:43:
  error: implicit conversion from ‘float’ to ‘double’ to match other
  operand of binary expression [-Werror=double-promotion]
   1266 |         costs[l_i + 1][r_i + 1] = replace + 1.00001;
``

@@ -296,15 +296,15 @@ TEST_F(Saturate2dVector, ValsOnEdgeOfRange) {
ret = utils_saturate_vector_2d(&inputVal_x, &inputVal_y, inputVal_max);
EXPECT_FLOAT_EQ(1, inputVal_x);
EXPECT_FLOAT_EQ(1, inputVal_y);
/* EXPECT_EQ(false, ret); <-- Do not test, since this is on the edge and we don't need to know if it's explicitly inside or outside*/
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was in place..
There are assertions on all the other tests..

Let me know if there is a reason why we can't assert the results

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FabioBatSilva technically you've combined a few separate changes in one PR?

@@ -7,7 +7,7 @@ EXTRAINCDIRS += $(TOP)/
EXTRAINCDIRS += $(HERE)/


CFLAGS += -O0
CFLAGS += -O1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc/ld doesn't like the inline functions on utils_math.c

  utils_math.c:582: undefined reference to `utils_truncate_number'
    error: ld returned 1 exit status

@rusefillc
Copy link

@vedderb this looks to be an amazing process improvement do you have time to move this forward?

@rusefillc
Copy link

See also #167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants