Repository navigation
Create Documentation for running the tests - #785
Conversation
pgrawehr
commented
Oct 9, 2019
- There was no documentation on what needs to be done to successfully run the unit tests.
- The tests should be extended (i.e. to test the pull up resistor settings or the I2C interface)
|
|
||
| Build System.Device.Gpio.dll: | ||
| ``` | ||
| cd src/System.Device.Gpio |
There was a problem hiding this comment.
Instead of this, could you simply tell people to build the whole repo by build.cmd/build.sh from the root? That will install all SDK dependencies needed in order to be able to run the tests.
There was a problem hiding this comment.
This doesn't work for me, at least not on the Pi itself (On Windows, I wouldn't use it either, there I just fire up Visual Studio and run the build).
pi@raspberrypi:~/projects/iot $ ./build.sh
Wiederherstellung in "444.81 ms" für "/home/pi/.nuget/packages/microsoft.dotnet.arcade.sdk/5.0.0-beta.19501.4/tools/Tools.proj" abgeschlossen.
dotnet-install: .NET Core Runtime version 2.1.11 is already installed.
dotnet-install: Adding to current process PATH: `/home/pi/projects/iot/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Installation finished successfully.
Wiederherstellung in "30.04 ms" für "/home/pi/projects/iot/eng/common/internal/Tools.csproj" abgeschlossen.
Wiederherstellung in "7.14 ms" für "/home/pi/projects/iot/samples/force-sensitive-resistor/force-sensitive-resistor.csproj" abgeschlossen.
Wiederherstellung in "381.32 ms" für "/home/pi/projects/iot/src/Iot.Device.Bindings/Iot.Device.Bindings.csproj" abgeschlossen.
Wiederherstellung in "513.39 ms" für "/home/pi/projects/iot/src/System.Device.Gpio/System.Device.Gpio.csproj" abgeschlossen.
<snip many more package restore lines>
Wiederherstellung in "2.6 ms" für "/home/pi/projects/iot/src/System.Device.Gpio/System.Device.Gpio.csproj" abgeschlossen.
/home/pi/.nuget/packages/microsoft.net.compilers.toolset/3.1.0-beta1-19127-06/tasks/netcoreapp2.1/Microsoft.CSharp.Core.targets(58,5): error : Failed to load �/C�D���, error: /home/pi/projects/iot/.dotnet/shared/Microsoft.NETCore.App/2.1.11/libhostpolicy.so: wrong ELF class: ELFCLASS64 [/home/pi/projects/iot/src/System.Device.Gpio/System.Device.Gpio.csproj]
/home/pi/.nuget/packages/microsoft.net.compilers.toolset/3.1.0-beta1-19127-06/tasks/netcoreapp2.1/Microsoft.CSharp.Core.targets(58,5): error : An error occurred while loading required library libhostpolicy.so from [/home/pi/projects/iot/.dotnet/shared/Microsoft.NETCore.App/2.1.11] [/home/pi/projects/iot/src/System.Device.Gpio/System.Device.Gpio.csproj]
/home/pi/.nuget/packages/microsoft.net.compilers.toolset/3.1.0-beta1-19127-06/tasks/netcoreapp2.1/Microsoft.CSharp.Core.targets(58,5): error : Failed to load ���, error: /home/pi/projects/iot/.dotnet/shared/Microsoft.NETCore.App/2.1.11/libhostpolicy.so: wrong ELF class: ELFCLASS64 [/home/pi/projects/iot/src/devices/Units/Units.csproj]
<snip many more similar error messages>
Not sure what's happening here, the Pi4 is running an ordinary Raspbian 32 Bit version. For some reason, the build script tries to link 64 Bit libraries.
build.log
There was a problem hiding this comment.
I think we should provide the publish profiles for the most common build configurations. This simplifies building and deploying directly from with VS. I'd rather put that on a separate PR, though.
There was a problem hiding this comment.
@pgrawehr can you file an issue on that? (if possible can you temporarily switch language to english to make it easier for us to see the errors?)
There was a problem hiding this comment.
Yea, will do. I'll try to get a log in english.
joperezr
left a comment
There was a problem hiding this comment.
Thanks a lot for adding these @pgrawehr it was definitely on our To-Do list so it's great you collaborated 😄. @krwq is working in adding a lot of new tests (PR #758) that would greatly impact these instructions and we should be close to merging once we finish setting up the lab. We can either hold this PR until he does and then update it, or merge before and just have him include the new instructions as part of his PR.
| @@ -0,0 +1,39 @@ | |||
| # How to run tests on the Raspberry Pi | |||
There was a problem hiding this comment.
Overall comment:
- I'm currently in the process of changing these tests and the new version will include diagram what needs to be connected: Upgrade CI setup (SPI/I2C/PWM/BME280 functional tests) #758
- We can merge these but expect I'll modify these to adjust for changes (I might add something to make it easier to run when people have incomplete setup)
There was a problem hiding this comment.
I did this as a preparation for another commit, so I guess this can be merged and used as a starting point.
Since not everybody will have all the hardware to run all the tests (i.e. the ADC converter), selecting tests will be important. Note also that the current input/output tests have no timeout defined, so they will block if the pins are not connected.
There was a problem hiding this comment.
Note also that the current input/output tests have no timeout defined, so they will block if the pins are not connected.
For this we were relying on our testing environment which limits the time a test will be executed, and kill it (and mark it as failed obviously) if it is just hanging.
There was a problem hiding this comment.
Relying on an external process to terminate the tests is not really a good design for errors that you expect to happen, I think. Especially since here it's easy to be fixed, as there are already CancellationTokens in place. I can have a look into that.
There was a problem hiding this comment.
That should be fixed on a separate PR, I think.
| @@ -0,0 +1,37 @@ | |||
| # How to run tests on the Raspberry Pi | |||
There was a problem hiding this comment.
| # How to run tests on the Raspberry Pi | |
| # How to run tests |
I think this is not RPi specific
There was a problem hiding this comment.
Maybe stupid question, but which other platforms are supported? You need hardware with a GPIO header.
There was a problem hiding this comment.
anything ARM32 (v7 I believe) / ARM64. I.e. Hummingboard and there is plenty other but they are not as popular as RPi. This tests might not work with that yet but the plan is they will eventually
| ## SysFsDriver Tests | ||
| You can also run the SysFsDriver Tests (this uses a more generic approach). This driver requires root permissions to run, so you need to `sudo` the command: | ||
| ``` | ||
| sudo dotnet test --filter SysFsDriverTests System.Device.Gpio.sln |
There was a problem hiding this comment.
actually RPi driver also requires root, only libgpiod doesn't (at least that's what I was seeing)
There was a problem hiding this comment.
(I'll add some xunit traits in my PR to make it easier to run without sudo)
There was a problem hiding this comment.
That's weird. After a few retries, it sometimes works without root rights and sometimes I get an exception.
There was a problem hiding this comment.
@krwq: It works without root rights each time except the very first time after bootup. If I run it twice (without sudo) it works, and after that it always works. Any idea?
There was a problem hiding this comment.
@pgrawehr this is good info. It might be a driver bug though but can't tell without investigating deeper
There was a problem hiding this comment.
I agree that this might just be a bug in our side. RPi driver shouldn't need sudo because it uses /dev/gpiomem/ which only exposes the gpio registers so it doesn't require sudo.
There was a problem hiding this comment.
I was also seeing locally it required sudo but I thought this was by design
Co-Authored-By: Mark Cilia Vincenti <[email protected]>
Co-Authored-By: Mark Cilia Vincenti <[email protected]>
|
I guess you squash anyway upon merge, so no need to combine the commits, right? |
|
@pgrawehr yes, we will squash |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
|
||
| ## Building directly on the Pi | ||
| Prerequisites: | ||
| - Installed .NET SDK with the "dotnet" executable in the path |
There was a problem hiding this comment.
NIT: Can we just add a link here to where to get dotnet in order to install it? For example, maybe pointing people here: https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-3.0.100-linux-arm32-binaries
There was a problem hiding this comment.
There was a problem hiding this comment.
Added the link and changed documentation slightly to also include the preferred way of build (even though for now, that doesn't seem to work, see #805)
| Build System.Device.Gpio.dll: | ||
| ``` | ||
| cd src/System.Device.Gpio | ||
| dotnet build System.Device.Gpio.sln |
There was a problem hiding this comment.
I'm not 100% sure that this will always work, It might be that it is working now by chance, but the ideal workflow should be to just call /build.sh, or in the worst case, ./build.sh -restore which would install dotnet for you along with all of the dependencies that we require for building. Anyways, I'm fine with keeping this as is for now and just fix whatever issue you were hitting above when calling ./build.sh and once we do change these instructions.
There was a problem hiding this comment.
I always use dotnet build as well but I first do full build and force using dotnet from the .dotnet directory which got created
There was a problem hiding this comment.
yeah, that is supposed to work as well. But never calling build.sh, and just using a random dotnet cli most likely not work in the future, so I'd be happier if we could use the one that gets restored by our build instead.
There was a problem hiding this comment.
I think you get an error if the correct CLI version is not installed. I personally prefer having the CLI installed globally once instead of into each working copy. Maybe both methods should be described (once they work...)
There was a problem hiding this comment.
@pgrawehr, in order to use the CLI which got created by the build when you also have a global installation you should also set environment variable: export DOTNET_MULTILEVEL_LOOKUP=0 (or set ... on Windows) to use only framework next to the dotnet.exe and not try to search for other frameworks
That doesn't seem to work yet, though. See dotnet#805
|
Thanks @pgrawehr! |