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

Spidev #2838

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Spidev #2838

merged 2 commits into from
Jan 4, 2024

Conversation

rminnich
Copy link
Member

@rminnich rminnich commented Jan 3, 2024

make spidev a little more informative about what commands are available. Until this change, you had to try to find source to see what to do.

With the error messages as they were, you had to find and read
source to figure out legal usages.

flag.Usage() does not show valid usage; you have to call
fs.FlagUsages() to get that.

We can use the errors.Is in tests, which is nicer.

Use os errors for mock tests, to make errors.Is easier.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
pflag takes it upon itself to spew errors to stdout.
It is hard to get consistent error invocation output
from it, but this is at least better than it was.

The output now looks like this (sidecore is running them on a
visionfive2 board):

ronsexcllentmbp:spidev rminnich$ sidecore vf2 ./spidev
1970/01/01 02:47:24 usage:   -D, --device string   spidev device (default "/dev/spidev0.0")
  -s, --speed uint32    max speed in Hz (default 500000)
 <raw|sfdp>

(this formatting still sucks).

ronsexcllentmbp:spidev rminnich$ sidecore vf2 ./spidev -t
1970/01/01 02:47:27 unknown flag:unknown shorthand flag: 't' in -t

ronsexcllentmbp:spidev rminnich$ sidecore vf2 ./spidev -h
Usage of spidev:
  -D, --device string   spidev device (default "/dev/spidev0.0")
  -s, --speed uint32    max speed in Hz (default 500000)
1970/01/01 02:47:30 usage:<raw|sfdp>

Note this is different than above, because pflag takes it upon
itself to just print things out. We can get more control, at the cost
or more code, but that is for another day.

Most importantly, you at least get some idea what commands there are.
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
@rminnich rminnich requested a review from rjoleary January 3, 2024 23:58
@rminnich rminnich added the Awaiting reviewer Waiting for a reviewer. label Jan 3, 2024
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (40ad4cd) 75.74% compared to head (73dbb2d) 75.74%.

Files Patch % Lines
cmds/fwtools/spidev/spidev_linux.go 75.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2838   +/-   ##
=======================================
  Coverage   75.74%   75.74%           
=======================================
  Files         423      423           
  Lines       42720    42721    +1     
=======================================
+ Hits        32358    32359    +1     
  Misses      10362    10362           
Flag Coverage Δ
.-amd64 67.87% <ø> (ø)
cmds/...-amd64 71.63% <75.00%> (-0.01%) ⬇️
integration/generic-tests/...-amd64 0.00% <ø> (ø)
integration/generic-tests/...-arm 0.00% <ø> (ø)
integration/generic-tests/...-arm64 0.00% <ø> (ø)
integration/gotests/...-amd64 74.01% <ø> (+<0.01%) ⬆️
integration/gotests/...-arm64 74.95% <ø> (ø)
pkg/...-amd64 76.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rminnich rminnich merged commit 3632944 into u-root:main Jan 4, 2024
24 of 25 checks passed
@rminnich rminnich deleted the spidev branch January 6, 2024 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting reviewer Waiting for a reviewer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants