Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 402581 - [Future EAPI] Add pkg_test() and a FEATURES=run-test
Summary: [Future EAPI] Add pkg_test() and a FEATURES=run-test
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: PMS/EAPI (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Package Manager Specification
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: future-eapi
  Show dependency tree
 
Reported: 2012-02-07 19:18 UTC by Diego Elio Pettenò (RETIRED)
Modified: 2025-02-13 10:42 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Elio Pettenò (RETIRED) gentoo-dev 2012-02-07 19:18:46 UTC
Following the talk about the continuous integration testing in CentOS, I started to consider that we could go a step further in testing the software in Gentoo, for environments such as the tinderbox, by running one further step beside the src_test() function.

While src_test() is executed within the scope of the build process, we could make use of a pkg_test() that is executed with the package installed. This is not intended as a general-usage testing framework (src_test() would be used for that still) but for actual integration, which means it needs to be able to start and stop services on the system, configure them and so on so forth, even incurring in the risk of breaking the system it is being run on.

Things needed:

 - a pkg_test() function;
 - a separate feature to set it up (as I said it might be destructive so it's _much_ better to avoid letting it to be used for general availability);
 - a separate USE flag (I'd rather not abuse the test USE flag at runtime) for the dependencies required to run pkg_test code.

Things nice to have:

 - a way to deal with services requiring network, to avoid collide with system services that _might_ be required for the continuous integration jobs, or for Portage: we can either decide to get everything open on a separate, loopback IP address (such as 127.255.255.254 as I'm using for dev-ruby/mongoid), or we could run them in their own network namespace, so they have lo just for themselves;

As an example, MySQL and Ruby both have extensive testsuites that can only be ran against the installed copy of the package, and not the one just built: being able to test this stuff would be pretty amazing for us.
Comment 1 APN-Pucky 2022-10-30 10:05:51 UTC
I recently came across a similar feature in EasyBuild called sanity-check:
https://docs.easybuild.io/en/latest/Writing_easyconfig_files.html#sanity-check

It is especially convenient for packages which provide (unreliable) python extensions:

sanity_check_commands = ["python -c 'import pythonextension'"]
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-26 12:18:29 UTC
See also https://public-inbox.gentoo.org/gentoo-dev/87ttftr9ay.fsf@gentoo.org/ regarding installed tests.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-26 12:18:54 UTC
I wonder if we could trial this with an eclass that users would opt-in to testing for w/ pkg_postinst.
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-08-27 05:46:48 UTC
preinst may be preferable.  That would enable us to abort if tests fail, right?
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-27 10:11:45 UTC
(In reply to Michał Górny from comment #4)
> preinst may be preferable.  That would enable us to abort if tests fail,
> right?

I was thinking postinst, in case software really requires to use the installed instance (think DESTDIR vs PREFIX).

BUT the two examples I'm thinking of today (the kernel selftests, dtrace) don't have that requirement AFAIK as they support running in the source tree, just are too expensive / ... / to run in sandbox.

So, it'd work for me to do the experiment with preinst, I think.
Comment 6 Florian Schmaus gentoo-dev 2024-09-01 09:35:49 UTC
(In reply to Michał Górny from comment #4)
> preinst may be preferable.  That would enable us to abort if tests fail,
> right?

I've just discovered a regression in our texlive packages where 'tlmgr' doesn't work any more. It would be great if we had a pkg_test() phase where we could rudimentary test for tlmgr's functionality (in this particular case, that the Perl INC paths are correct). However, 'tlmgr' requires the TexLive Package Database (tlpdb) to be initialized, which we dynamically create, for reasons, in pkg_postinst(). Therefore, to be useful for this use-case, pkg_test() should be run *after* pkg_postinst().