diff mbox

[v2] libseccomp: Add new config option to build and install tests

Message ID 1442564371-10498-1-git-send-email-markos.chandras@imgtec.com
State Superseded
Headers show

Commit Message

Markos Chandras Sept. 18, 2015, 8:19 a.m. UTC
Add new config option to allow building and installing the libseccomp
testsuite on the target. It's useful for testing the kernels'
seccomp behavior for the target architecture.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
changes since v1:
- Drop compile hook for tests and use MAKE_OPTS instead
---
 package/libseccomp/Config.in     |  9 +++++++++
 package/libseccomp/libseccomp.mk | 16 ++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Vicente Olivert Riera Sept. 18, 2015, 8:36 a.m. UTC | #1
Dear Markos Chandras,

On 09/18/2015 09:19 AM, Markos Chandras wrote:
> Add new config option to allow building and installing the libseccomp
> testsuite on the target. It's useful for testing the kernels'
> seccomp behavior for the target architecture.
> 
> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Reviewed-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com> Tested-by:
Vicente Olivert Riera <Vincent.Riera@imgtec.com>

Build test for MIPS architecture:

$ file output/target/usr/libseccomp/tests/01-sim-allow
output/target/usr/libseccomp/tests/01-sim-allow: ELF 32-bit MSB
executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses
shared libs), for GNU/Linux 2.6.32, with unknown capability 0x41000000 =
0xf676e75, with unknown capability 0x10000 = 0x70403, stripped

Regards,

Vincent.

> ---
> changes since v1:
> - Drop compile hook for tests and use MAKE_OPTS instead
> ---
>  package/libseccomp/Config.in     |  9 +++++++++
>  package/libseccomp/libseccomp.mk | 16 ++++++++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/package/libseccomp/Config.in b/package/libseccomp/Config.in
> index 4c34c5466592..760a6f321142 100644
> --- a/package/libseccomp/Config.in
> +++ b/package/libseccomp/Config.in
> @@ -15,6 +15,15 @@ config BR2_PACKAGE_LIBSECCOMP
>  
>  	  https://github.com/seccomp/libseccomp
>  
> +config BR2_PACKAGE_LIBSECCOMP_TESTS
> +	bool "Install libseccomp tests"
> +	depends on BR2_PACKAGE_BASH && BR2_PACKAGE_LIBSECCOMP
> +	help
> +	  Build and install the libseccomp testsuite.
> +
> +comment "libseccomp testsuite needs bash as running shell"
> +	depends on !BR2_PACKAGE_BASH && BR2_PACKAGE_LIBSECCOMP
> +
>  comment "libseccomp needs a toolchain w/ headers >= 3.12"
>  	depends on BR2_aarch64 || BR2_mips || BR2_mipsel || BR2_mips64 || \
>  		BR2_mips64el || BR2_i386 || BR2_x86_64
> diff --git a/package/libseccomp/libseccomp.mk b/package/libseccomp/libseccomp.mk
> index a188298006b1..5ebd8c54ac1f 100644
> --- a/package/libseccomp/libseccomp.mk
> +++ b/package/libseccomp/libseccomp.mk
> @@ -17,4 +17,20 @@ define LIBSECCOMP_FIXUP_M4_DIR
>  endef
>  LIBSECCOMP_POST_EXTRACT_HOOKS += LIBSECCOMP_FIXUP_M4_DIR
>  
> +ifeq ($(BR2_PACKAGE_LIBSECCOMP_TESTS),y)
> +
> +LIBSECCOMP_MAKE_OPTS += check-build
> +
> +define LIBSECCOMP_TESTS_INSTALL
> +	mkdir -p $(TARGET_DIR)/usr/libseccomp/{tests,tools} && \
> +	for x in tests tools; do \
> +		find $(@D)/$$x -maxdepth 1 \( -name "*.tests" -o -perm -a=x \) \
> +			-type f -exec cp {} $(TARGET_DIR)/usr/libseccomp/$$x/ \; ; \
> +	done
> +endef
> +
> +LIBSECCOMP_POST_INSTALL_TARGET_HOOKS += LIBSECCOMP_TESTS_INSTALL
> +
> +endif
> +
>  $(eval $(autotools-package))
>
Vicente Olivert Riera Sept. 18, 2015, 8:39 a.m. UTC | #2
Sorry all,

my email client did something weird with my tested-by tag and patchwork
is not detecting it correctly. Now it will.

Tested-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>

Regards,

Vincent.
Thomas Petazzoni Sept. 20, 2015, 12:46 p.m. UTC | #3
Markos,

On Fri, 18 Sep 2015 09:19:31 +0100, Markos Chandras wrote:

> +ifeq ($(BR2_PACKAGE_LIBSECCOMP_TESTS),y)
> +
> +LIBSECCOMP_MAKE_OPTS += check-build
> +
> +define LIBSECCOMP_TESTS_INSTALL
> +	mkdir -p $(TARGET_DIR)/usr/libseccomp/{tests,tools} && \
> +	for x in tests tools; do \
> +		find $(@D)/$$x -maxdepth 1 \( -name "*.tests" -o -perm -a=x \) \
> +			-type f -exec cp {} $(TARGET_DIR)/usr/libseccomp/$$x/ \; ; \

This has the effect of installing one .py file for each test even if
Python is not installed on the target. They are pretty small, so maybe
we don't care, but it doesn't look really nice.

Also, this whole thing seems pretty crappy in libseccomp. Why don't
they have simply a --enable-tests option, which will simply do the
right thing?

Thanks,

Thomas
Markos Chandras Sept. 21, 2015, 8:39 a.m. UTC | #4
Hi Thomas,

On 09/20/2015 01:46 PM, Thomas Petazzoni wrote:
> Markos,
> 
> On Fri, 18 Sep 2015 09:19:31 +0100, Markos Chandras wrote:
> 
>> +ifeq ($(BR2_PACKAGE_LIBSECCOMP_TESTS),y)
>> +
>> +LIBSECCOMP_MAKE_OPTS += check-build
>> +
>> +define LIBSECCOMP_TESTS_INSTALL
>> +	mkdir -p $(TARGET_DIR)/usr/libseccomp/{tests,tools} && \
>> +	for x in tests tools; do \
>> +		find $(@D)/$$x -maxdepth 1 \( -name "*.tests" -o -perm -a=x \) \
>> +			-type f -exec cp {} $(TARGET_DIR)/usr/libseccomp/$$x/ \; ; \
> 
> This has the effect of installing one .py file for each test even if
> Python is not installed on the target. They are pretty small, so maybe
> we don't care, but it doesn't look really nice.

Hmm makes sense. I will rework it then.

> 
> Also, this whole thing seems pretty crappy in libseccomp. Why don't
> they have simply a --enable-tests option, which will simply do the
> right thing?

It's probably because this is yet another testsuite and like any other
package testsuite you don't really need it installed. it's supposed to
run as part of package verification during build and installation. but
for cross-builds, it's useful to have it on the target.
diff mbox

Patch

diff --git a/package/libseccomp/Config.in b/package/libseccomp/Config.in
index 4c34c5466592..760a6f321142 100644
--- a/package/libseccomp/Config.in
+++ b/package/libseccomp/Config.in
@@ -15,6 +15,15 @@  config BR2_PACKAGE_LIBSECCOMP
 
 	  https://github.com/seccomp/libseccomp
 
+config BR2_PACKAGE_LIBSECCOMP_TESTS
+	bool "Install libseccomp tests"
+	depends on BR2_PACKAGE_BASH && BR2_PACKAGE_LIBSECCOMP
+	help
+	  Build and install the libseccomp testsuite.
+
+comment "libseccomp testsuite needs bash as running shell"
+	depends on !BR2_PACKAGE_BASH && BR2_PACKAGE_LIBSECCOMP
+
 comment "libseccomp needs a toolchain w/ headers >= 3.12"
 	depends on BR2_aarch64 || BR2_mips || BR2_mipsel || BR2_mips64 || \
 		BR2_mips64el || BR2_i386 || BR2_x86_64
diff --git a/package/libseccomp/libseccomp.mk b/package/libseccomp/libseccomp.mk
index a188298006b1..5ebd8c54ac1f 100644
--- a/package/libseccomp/libseccomp.mk
+++ b/package/libseccomp/libseccomp.mk
@@ -17,4 +17,20 @@  define LIBSECCOMP_FIXUP_M4_DIR
 endef
 LIBSECCOMP_POST_EXTRACT_HOOKS += LIBSECCOMP_FIXUP_M4_DIR
 
+ifeq ($(BR2_PACKAGE_LIBSECCOMP_TESTS),y)
+
+LIBSECCOMP_MAKE_OPTS += check-build
+
+define LIBSECCOMP_TESTS_INSTALL
+	mkdir -p $(TARGET_DIR)/usr/libseccomp/{tests,tools} && \
+	for x in tests tools; do \
+		find $(@D)/$$x -maxdepth 1 \( -name "*.tests" -o -perm -a=x \) \
+			-type f -exec cp {} $(TARGET_DIR)/usr/libseccomp/$$x/ \; ; \
+	done
+endef
+
+LIBSECCOMP_POST_INSTALL_TARGET_HOOKS += LIBSECCOMP_TESTS_INSTALL
+
+endif
+
 $(eval $(autotools-package))