From fa76518970ce5beb1f4b5be500c5eed63680c455 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 18 Feb 2022 00:54:20 +0100 Subject: [PATCH] CI: add a test kernel extension to mockpkg --- .github/workflows/CI.yml | 10 ++++---- .gitignore | 2 ++ dev/ci.sh | 12 ++++++++++ tst/mockpkg/.gitignore | 3 +++ tst/mockpkg/Makefile.gappkg | 1 + tst/mockpkg/Makefile.in | 9 +++++++ tst/mockpkg/PackageInfo.g | 1 + tst/mockpkg/configure | 34 ++++++++++++++++++++++++++ tst/mockpkg/init.g | 4 ++++ tst/mockpkg/src/mockpkg.c | 48 +++++++++++++++++++++++++++++++++++++ tst/mockpkg/tst/kext.tst | 11 +++++++++ 11 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 tst/mockpkg/.gitignore create mode 120000 tst/mockpkg/Makefile.gappkg create mode 100644 tst/mockpkg/Makefile.in create mode 100755 tst/mockpkg/configure create mode 100644 tst/mockpkg/src/mockpkg.c create mode 100644 tst/mockpkg/tst/kext.tst diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0d2d163c88e..75dd1e0758d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -55,7 +55,7 @@ jobs: "testmanuals", # test error reporting and compiling as well as libgap - "testexpect testspecial test-compile testlibgap testkernel", + "testexpect testmockpkg testspecial test-compile testlibgap testkernel", # compile packages and run GAP tests # don't use --enable-debug to prevent the tests from taking too long @@ -98,7 +98,7 @@ jobs: # this job also tests GAP without readline - os: macos-latest shell: bash - test-suites: "testinstall" + test-suites: "testmockpkg testinstall" extra: "BOOTSTRAP_MINIMAL=yes" # run bugfix regression tests @@ -123,7 +123,7 @@ jobs: # tests using valgrind, as it is too slow. - os: ubuntu-18.04 shell: bash - test-suites: "testbuildsys testinstall" + test-suites: "testbuildsys testmockpkg testinstall" extra: "NO_COVERAGE=1 ABI=64 BUILDDIR=out-of-tree CONFIGFLAGS=\"--enable-valgrind\"" packages: "valgrind" @@ -132,7 +132,7 @@ jobs: # elsewhere in this file for an explanation). - os: ubuntu-18.04 shell: bash - test-suites: "testbuildsys testinstall" + test-suites: "testbuildsys testmockpkg testinstall" extra: "NO_COVERAGE=1 ABI=32 BUILDDIR=out-of-tree CONFIGFLAGS=\"\"" # test Julia integration @@ -147,7 +147,7 @@ jobs: # -o igncr: Accept windows line endings # {0} : Pass any extra arguments from CI shell: C:\cygwin64\bin\bash.exe --login -o igncr '{0}' - test-suites: "testinstall" + test-suites: "testmockpkg testinstall" # TODO: add back big endian test (we had s390x on Travis) # TODO: add back test with an older GCC, e.g. 4.7 diff --git a/.gitignore b/.gitignore index 493c37e1e19..18242da9f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -100,6 +100,8 @@ doc/gapmacrodoc.idx /tst/testkernel/dstruct /tst/testkernel/*.out +/tst/mockpkg/pkg + # emacs backup and lock files *~ \#*\# diff --git a/dev/ci.sh b/dev/ci.sh index c09407b05a0..34fb183d3e4 100755 --- a/dev/ci.sh +++ b/dev/ci.sh @@ -225,6 +225,18 @@ GAPInput make testkernel ;; + testmockpkg) + # test building a package kernel extension + cd "$SRCDIR/tst/mockpkg" + ./configure "$BUILDDIR" + make + # trick to make it easy to load the package in GAP + ln -s . pkg + # try to load the kernel extension + cd "$BUILDDIR" + $GAP -A --cover -l "$SRCDIR/tst/mockpkg;" $COVDIR/testmockpkg.coverage "$SRCDIR/tst/mockpkg/tst/testall.g" + ;; + testexpect) INPUTRC=/tmp/inputrc expect -c "spawn $GAP -A -b --cover $COVDIR/${TEST_SUITE}.coverage" $SRCDIR/dev/gaptest.expect ;; diff --git a/tst/mockpkg/.gitignore b/tst/mockpkg/.gitignore new file mode 100644 index 00000000000..2473409949f --- /dev/null +++ b/tst/mockpkg/.gitignore @@ -0,0 +1,3 @@ +/Makefile +/bin +/gen diff --git a/tst/mockpkg/Makefile.gappkg b/tst/mockpkg/Makefile.gappkg new file mode 120000 index 00000000000..580ab2c038b --- /dev/null +++ b/tst/mockpkg/Makefile.gappkg @@ -0,0 +1 @@ +../../etc/Makefile.gappkg \ No newline at end of file diff --git a/tst/mockpkg/Makefile.in b/tst/mockpkg/Makefile.in new file mode 100644 index 00000000000..cd5aa0acc12 --- /dev/null +++ b/tst/mockpkg/Makefile.in @@ -0,0 +1,9 @@ +# +# Makefile rules for the mockpkg package +# +KEXT_NAME = mockpkg +KEXT_SOURCES = src/mockpkg.c + +# include shared GAP package build system +GAPPATH = @GAPPATH@ +include Makefile.gappkg diff --git a/tst/mockpkg/PackageInfo.g b/tst/mockpkg/PackageInfo.g index 597ab574c36..b27d1ded0ea 100644 --- a/tst/mockpkg/PackageInfo.g +++ b/tst/mockpkg/PackageInfo.g @@ -88,6 +88,7 @@ Dependencies := rec( AvailabilityTest := function() Print("oops, should not print here\n"); + #return IsKernelExtensionAvailable("mockpkg"); return true; end, diff --git a/tst/mockpkg/configure b/tst/mockpkg/configure new file mode 100755 index 00000000000..ffb444de434 --- /dev/null +++ b/tst/mockpkg/configure @@ -0,0 +1,34 @@ +#!/bin/sh +# usage: configure gappath +# this script creates a `Makefile' from `Makefile.in' + +set -e + +GAPPATH=../.. +while test "$#" -ge 1 ; do + option="$1" ; shift + case "$option" in + --with-gaproot=*) GAPPATH=${option#--with-gaproot=}; ;; + -*) echo "ERROR: unsupported argument $option" ; exit 1;; + *) GAPPATH="$option" ;; + esac +done + +if test ! -r "$GAPPATH/sysinfo.gap" ; then + echo + echo "No file $GAPPATH/sysinfo.gap found." + echo + echo "Usage: ./configure [GAPPATH]" + echo " where GAPPATH is a path to your GAP installation" + echo " (The default for GAPPATH is \"../..\")" + echo + echo "Either your GAPPATH is incorrect or the GAP it is pointing to" + echo "is not properly compiled (do \"./configure && make\" there first)." + echo + echo "Aborting... No Makefile is generated." + echo + exit 1 +fi + +echo "Using settings from $GAPPATH/sysinfo.gap" +sed -e "s;@GAPPATH@;$GAPPATH;g" Makefile.in > Makefile diff --git a/tst/mockpkg/init.g b/tst/mockpkg/init.g index 8a26bad258f..0c97b5c8909 100644 --- a/tst/mockpkg/init.g +++ b/tst/mockpkg/init.g @@ -4,4 +4,8 @@ # Reading the declaration part of the package. # +#if not LoadKernelExtension("mockpkg") then +# Error("could not load 'mockpkg' kernel extension") +#fi; + ReadPackage( "mockpkg", "gap/mockpkg.gd"); diff --git a/tst/mockpkg/src/mockpkg.c b/tst/mockpkg/src/mockpkg.c new file mode 100644 index 00000000000..b8e33eb8eb2 --- /dev/null +++ b/tst/mockpkg/src/mockpkg.c @@ -0,0 +1,48 @@ +#include // GAP headers + +Obj FuncTestCommand(Obj self) +{ + return True; +} + +// Table of functions to export +static StructGVarFunc GVarFuncs[] = { + GVAR_FUNC(TestCommand, 0, ""), + { 0 } +}; + +/**************************************************************************** +** +*F InitKernel( ) . . . . . . . . initialise kernel data structures +*/ +static Int InitKernel(StructInitInfo * module) +{ + InitHdlrFuncsFromTable(GVarFuncs); + return 0; +} + +/**************************************************************************** +** +*F InitLibrary( ) . . . . . . . initialise library data structures +*/ +static Int InitLibrary(StructInitInfo * module) +{ + InitGVarFuncsFromTable(GVarFuncs); + return 0; +} + +/**************************************************************************** +** +*F Init__Dynamic() . . . . . . . . . . . . . . . . . table of init functions +*/ +static StructInitInfo module = { + .type = MODULE_DYNAMIC, + .name = "mockpkg", + .initKernel = InitKernel, + .initLibrary = InitLibrary, +}; + +StructInitInfo * Init__Dynamic(void) +{ + return &module; +} diff --git a/tst/mockpkg/tst/kext.tst b/tst/mockpkg/tst/kext.tst new file mode 100644 index 00000000000..16d0988e2a9 --- /dev/null +++ b/tst/mockpkg/tst/kext.tst @@ -0,0 +1,11 @@ +# +# Try to load its kernel extension +# +gap> LoadPackage("mockpkg"); +true +gap> IsKernelExtensionAvailable("mockpkg"); +true +gap> LoadKernelExtension("mockpkg"); +true +gap> TestCommand(); +true