stevieb has asked for the wisdom of the Perl Monks concerning the following question:
For my Raspberry Pi build/test automation regimen, there are two aspects of code that require root permissions, as they will not work with /dev/gpiomem (fwiw, one aspect is Pulse-Width Modulation functionality, the other deals with the Pi's hardware clock registers).
I obviously don't want to have the actual code up and randomly sudo, instead, a note in the docs will specify if these features are used, you'll need to setuid or run your script with sudo.
Likewise, I don't want to run the whole test suite with root, just two files.
I'm thinking something like the following which appears to work well:
use warnings; use strict; use Test::More; if ($> != 0){ system('sudo', 'prove', '-l', $0); exit; } is 1, 1, "ok"; done_testing();
Is this reasonable, or am I overlooking an easier or better way to do this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running specific test files with sudo
by Corion (Patriarch) on Mar 19, 2017 at 16:28 UTC | |
by stevieb (Canon) on Mar 19, 2017 at 17:07 UTC | |
|
Re: Running specific test files with sudo
by haukex (Archbishop) on Mar 19, 2017 at 18:18 UTC | |
by stevieb (Canon) on Mar 19, 2017 at 19:56 UTC |