Skip to content

Create Documentation for running the tests - #785

Merged
krwq merged 6 commits into
dotnet:masterfrom
pgrawehr:TestingDoc
Oct 17, 2019
Merged

krwq merged 6 commits into
dotnet:masterfrom
pgrawehr:TestingDoc

Conversation

@pgrawehr

@pgrawehr pgrawehr commented Oct 9, 2019

Copy link
Copy Markdown
Contributor
  • 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)

@dnfclas

dnfclas commented Oct 9, 2019 •

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.


Build System.Device.Gpio.dll:
```
cd src/System.Device.Gpio

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@pgrawehr pgrawehr Oct 10, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea, will do. I'll try to get a log in english.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@krwq : I've created #805 for this. An english log has been added there.

Comment thread src/System.Device.Gpio.Tests/README.md Resolved
Comment thread src/System.Device.Gpio.Tests/README.md Resolved
Comment thread src/System.Device.Gpio.Tests/README.md Resolved

@joperezr joperezr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread src/System.Device.Gpio.Tests/README.md Outdated
@@ -0,0 +1,39 @@
# How to run tests on the Raspberry Pi

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That should be fixed on a separate PR, I think.

Comment thread src/System.Device.Gpio.Tests/README.md Outdated
@@ -0,0 +1,37 @@
# How to run tests on the Raspberry Pi

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# How to run tests on the Raspberry Pi
# How to run tests

I think this is not RPi specific

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe stupid question, but which other platforms are supported? You need hardware with a GPIO header.

@krwq krwq Oct 15, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread src/System.Device.Gpio.Tests/README.md Resolved
Comment thread src/System.Device.Gpio.Tests/README.md Resolved
Comment thread src/System.Device.Gpio.Tests/README.md Resolved
## 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

actually RPi driver also requires root, only libgpiod doesn't (at least that's what I was seeing)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(I'll add some xunit traits in my PR to make it easier to run without sudo)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's weird. After a few retries, it sometimes works without root rights and sometimes I get an exception.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pgrawehr this is good info. It might be a driver bug though but can't tell without investigating deeper

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was also seeing locally it required sudo but I thought this was by design

Comment thread src/System.Device.Gpio.Tests/README.md Resolved
Comment thread src/System.Device.Gpio.Tests/README.md Resolved
pgrawehr and others added 2 commits October 15, 2019 12:43
@pgrawehr

Copy link
Copy Markdown
Contributor Author

I guess you squash anyway upon merge, so no need to combine the commits, right?

@krwq

krwq commented Oct 15, 2019 •

Copy link
Copy Markdown
Member

@pgrawehr yes, we will squash

@krwq

krwq commented Oct 15, 2019

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread src/System.Device.Gpio.Tests/README.md Outdated

## Building directly on the Pi
Prerequisites:
- Installed .NET SDK with the "dotnet" executable in the path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I always use dotnet build as well but I first do full build and force using dotnet from the .dotnet directory which got created

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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...)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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
@krwq
krwq merged commit f33176b into dotnet:master Oct 17, 2019
@krwq

krwq commented Oct 17, 2019

Copy link
Copy Markdown
Member

Thanks @pgrawehr!

@pgrawehr
pgrawehr deleted the TestingDoc branch October 27, 2019 12:21
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants