nimbuscontrols/EIPScanner

Docs for Running Tests?

nicktramp opened this issue · 3 comments

Is your feature request related to a problem? Please describe.
It's unclear how to run tests. Should these be run by those submitting PRs (I imagine so)? How can they be run? Adding this info to the documentation would be very helpful.

Describe the solution you'd like
A clear and concise description of how to run existing tests, preferably added to the documentation.

Describe alternatives you've considered
I've created an image from the included Dockerfile, but I'm not sure how to make use of it.

Additional context
Running on Linux. I'm looking to submit a PR for simple changes to the ConnectionManager.cpp (Implicit Messaging) which works for me and I think more people, generally. I'd also like to add my device (a Brooks SLA5800-series Mass Flow Controller) to the "library" (I very much like the idea of having many devices as examples).

Hi, you need GTest and GMock, any version should do.

Configure with -DTEST_ENABLED:BOOL=ON, then from the build folder run the tests with ./test/test_eipscanner.

Let me know if it works.

@JohannesKauffmann It did work, thank you. However, when building the install target of the googletest repo I initially got this error:

CMake Error at googlemock/cmake_install.cmake:46 (file):
  file INSTALL cannot set permissions on "/usr/local/include": Operation not  permitted.
Call Stack (most recent call first):
  cmake_install.cmake:47 (include)

Running as root (via sudo) fixed this. This seems odd to me (why should the library need to change permissions of the directory itself?). Is there a way to utilize GTest & GMock without installing to a system directory? I would think including and building it as a submodule would give greater control over which version is used (if that ever becomes an issue), its location could be known for use by EIPScanner without needing elevated permissions and instructions could be added to the docs that should work for everyone (maybe not Windows?). Is there any interest in going this route? I'll close this issue either way; just curious.

Running as root (via sudo) fixed this. This seems odd to me (why should the library need to change permissions of the directory itself?).

Running the tests does not require make install. After just make, the tests can be ran as outlined above. The make install target installs the library files (.so, header files) into a prefix determined at configure time. For CMake (but a lot of other build systems also) the value of CMAKE_INSTALL_PREFIX just happens to be /usr/local, which is a system directory (that's why you need sudo permissions). But again, installation is not required to build/run the tests.

It is possible to build GTest/GMock yourself and add a few CMake arguments to point EIPScanner to the correct library location, but it's a while ago that I tried this, and I don't remember exactly the details. It does work fine on Windows/Linux however, and these extra arguments are not unique to EIPScanner, but should work for any library that used GTest. By any change the GTest docs even mention them :)

A submodule could indeed be an improvement. Patches welcome, although I'm not sure whether I'll get a change to review these as my work schedule is pretty packed.