Bug 12598 - ptest: run as user
Summary: ptest: run as user
Status: RESOLVED OBSOLETE
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.5
Hardware: x86 Multiple
: Medium+ enhancement
Target Milestone: 4.99
Assignee: yeoh ee peng
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks: 12230
  Show dependency tree
 
Reported: 2018-03-12 14:58 UTC by Juro Bystricky
Modified: 2019-06-11 08:48 UTC (History)
8 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juro Bystricky 2018-03-12 14:58:56 UTC
Running ptest is more-less equivalent to "make check" testing a cross-compiled package on a target platform instead of the build platform. Packages are normally built is user environment, so it make sense to run ptests as user as well.  (I believe we run the "official" tests in root environment instead of a user)
It stands to reason, the results may vary depending on whether we run ptest as a user or a root. Some tests when ran as root can be quite destructive.
Currently this is not defined well, so some (possibly enforced) guidelines should be established, i.e. always run as a user (run-ptest can check for this on a need to bases),  and use "sudo" when need to (there may be some packeges that must be tested as root). 
This would probably require to create a user account as a part of the test image ("tester").
Comment 1 Ross Burton 2018-03-15 08:07:03 UTC
Should be easy enough to make the ptest-runner package create a user for ptest execution, the other step would be to make the ptest test case change user first.
Comment 2 Srikanth 2018-11-15 03:30:05 UTC
I added the user in the sudoer list in /etc/sudoers and
modify the run-ptest script by adding sudo where ever it requires. 
and run the ptest-runner with sudo, i haven't see the permission denied error.

My question we need to add the user as sudo in the Image?
Comment 3 Srikanth 2018-11-21 03:22:16 UTC
Successfully created the user and add the user in the sudoers list. 
blew are my changes
In the file local.conf
add the below line

INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "useradd -s /bin/sh -P 'superuser' superuser; \
                       usermod  -aG sudo superuser;"

run the ptest as user if it requires sudo run the ptest as sudo
eg: 
run as user:  $ ptest-runner acl
run as sudo:  $ sudo ptest-runner acl

before running the ptest we need to export the sbin path

$export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
Comment 4 Richard Purdie 2019-06-11 08:48:11 UTC
We're now running tests which need a non-root user as specific test users and have established this as our mechanism for handling this (see glib-2.0).