Skip to content

Commit

Permalink
Add userspace library testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoArella committed Oct 28, 2021
1 parent aff9e26 commit bee1b25
Show file tree
Hide file tree
Showing 35 changed files with 884 additions and 142 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ jobs:
- name: Build project
run: scripts/linux/build.sh

- name: Run example
- name: Test project
run: scripts/linux/test.sh

- name: Run example
run: scripts/linux/example.sh

qemu-linux-x86_64:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -59,7 +62,7 @@ jobs:
run: scripts/qemu/build.sh ${{ matrix.kernel }}

- name: Run example
run: scripts/qemu/test.sh
run: scripts/qemu/example.sh

release:
needs: [linux-x86_64, qemu-linux-x86_64]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ m4/*
!m4/ac_sphinx.m4
!m4/ac_docs_enable.m4
!m4/ax_pthread.m4
!m4/ax_check_link_flag.m4
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
ACLOCAL_AMFLAGS = -I m4

if BUILD_EXAMPLES
MAYBE_EXAMPLES = examples
MAYBE_EXAMPLES = examples
endif

if BUILD_BENCHMARK
MAYBE_BENCHMARK = benchmark
MAYBE_BENCHMARK = benchmark
endif

if BUILD_DOCS
MAYBE_DOCS = doc
MAYBE_DOCS = doc
endif

SUBDIRS = src/module src/lib src/util $(MAYBE_EXAMPLES) $(MAYBE_BENCHMARK) $(MAYBE_DOCS)
Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,27 @@ A PDF version of the documentation is also available [here](https://github.com/M
- libtool
- pkg-config
- linux-headers
- sphinx <sup>[1](#f1)</sup>
- doxygen <sup>[1](#f1)</sup>
- breathe <sup>[1](#f1)</sup>
- sphinx_rtd_theme <sup>[1](#f1)</sup>
- latex <sup>[2](#f2)</sup>
- check <sup>[1](#f1)</sup>
- sphinx <sup>[2](#f2)</sup>
- doxygen <sup>[2](#f2)</sup>
- breathe <sup>[2](#f2)</sup>
- sphinx_rtd_theme <sup>[2](#f2)</sup>
- latex <sup>[3](#f3)</sup>

<a name="f1">1</a> Optional: needed only to build the documentation
<a name="f1">1</a> Optional: needed only for userspace library tests

<a name="f2">2</a> Optional: needed only to build the pdf documentation
<a name="f2">2</a> Optional: needed only to build the documentation

<a name="f3">3</a> Optional: needed only to build the pdf documentation

### Minimal Build

Build the userspace library and the LKM and install them into the system with:
```
$ ./configure
$ make
$ make install
$ make check
$ sudo make install
$ sudo ldconfig
$ sudo modprobe ums
```
Expand All @@ -65,9 +69,9 @@ The following dependencies are needed in case of development build:
- autoconf
- automake
- git
- cppcheck <sup>[3](#f2)</sup>
- cppcheck <sup>[4](#f4)</sup>

<a name="f3">3</a> Optional: needed only for userspace library static code analysis
<a name="f4">4</a> Optional: needed only for userspace library static code analysis

### Development Build

Expand Down
5 changes: 5 additions & 0 deletions benchmark/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ AC_PROG_CC
LT_PREREQ([2.4])
LT_INIT

AC_PATH_PROG([CPPCHECK], [cppcheck], [true])
AS_IF([test "x$CPPCHECK" = xtrue], [
AC_MSG_WARN(['cppcheck' is recommended for developing this package.])
])

# Use the C language and compiler for the following checks
AC_LANG([C])

Expand Down
30 changes: 18 additions & 12 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ Minimal Requirements
- libtool
- pkg-config
- linux-headers
- sphinx\ [#f1]_
- doxygen\ [#f1]_
- breathe\ [#f1]_
- sphinx_rtd_theme\ [#f1]_
- latex\ [#f2]_
- check\ [#f1]_
- sphinx\ [#f2]_
- doxygen\ [#f2]_
- breathe\ [#f2]_
- sphinx_rtd_theme\ [#f2]_
- latex\ [#f3]_

.. [#f1] Optional: needed only to build the documentation
.. [#f2] Optional: needed only to build the pdf documentation
.. [#f1] Optional: needed only for userspace library tests
.. [#f2] Optional: needed only to build the documentation
.. [#f3] Optional: needed only to build the pdf documentation
Development Requirements
========================
Expand All @@ -29,9 +31,9 @@ The following dependencies are needed in case of development build:
- autoconf
- automake
- git
- cppcheck\ [#f3]_
- cppcheck\ [#f4]_

.. [#f3] Optional: needed only for userspace library static code analysis
.. [#f4] Optional: needed only for userspace library static code analysis
Build
=====
Expand Down Expand Up @@ -103,18 +105,22 @@ Targets
``html`` Build the html documentation
``pdf`` Build the pdf documentation
``install`` Install into the system
``installcheck`` Install tests into the system
``uninstall`` Uninstall from the system
``clean`` Delete all files in the current directory that are
normally created by building the program
``distclean`` Delete all files in the current directory that are
created by configuring or building the program
========================== ====================================================

Install
=======
Minimal installation steps
==========================

.. code::
$ make install
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig
$ sudo modprobe ums
2 changes: 1 addition & 1 deletion doc/userspace/internals/library_lifecycle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ In particular the :c:var:`UMS_FILENO` is declared as

.. literalinclude:: /../src/lib/src/private.h
:language: c
:lines: 18
:lines: 20
:lineno-match:
:dedent:
:caption: src/lib/src/private.h
Expand Down
8 changes: 4 additions & 4 deletions doc/userspace/internals/scheduler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ in particular the :c:func:`enter_ums_scheduling_mode()` begins with:

.. literalinclude:: /../src/lib/src/scheduler.c
:language: c
:lines: 13-21
:lines: 13-27
:lineno-match:
:dedent:
:caption: src/lib/src/scheduler.c
Expand All @@ -24,7 +24,7 @@ where the ``enter_ums_mode`` is defined at

.. literalinclude:: /../src/lib/src/private.h
:language: c
:lines: 20-23
:lines: 22-25
:lineno-match:
:dedent:
:caption: src/lib/src/private.h
Expand All @@ -36,7 +36,7 @@ UMS :c:type:`ums_scheduler_entry_point_t`.

.. literalinclude:: /../src/lib/src/scheduler.c
:language: c
:lines: 23-61
:lines: 29-67
:lineno-match:
:dedent:
:caption: src/lib/src/scheduler.c
Expand All @@ -48,7 +48,7 @@ The execution of a worker thread context is implemented as follows:

.. literalinclude:: /../src/lib/src/scheduler.c
:language: c
:lines: 66-69
:lines: 72-75
:lineno-match:
:dedent:
:caption: src/lib/src/scheduler.c
4 changes: 2 additions & 2 deletions doc/userspace/internals/worker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The function is implemented as follows:

.. literalinclude:: /../src/lib/src/worker.c
:language: c
:lines: 53-70
:lines: 53-75
:lineno-match:
:dedent:
:caption: src/lib/src/worker.c
Expand Down Expand Up @@ -56,7 +56,7 @@ The yielding of a UMS worker thread is implemented as follows:

.. literalinclude:: /../src/lib/src/worker.c
:language: c
:lines: 72-75
:lines: 77-80
:lineno-match:
:dedent:
:caption: src/lib/src/worker.c
53 changes: 53 additions & 0 deletions m4/ax_check_link_flag.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the linker or gives an error.
# (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_LINK_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <[email protected]>
# Copyright (c) 2011 Maarten Bosmans <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 6

AC_DEFUN([AX_CHECK_LINK_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
ax_check_save_flags=$LDFLAGS
LDFLAGS="$LDFLAGS $4 $1"
AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
LDFLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_LINK_FLAGS
6 changes: 6 additions & 0 deletions qemu/configs/qemu_x86_64_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ BR2_ROOTFS_OVERLAY="../rootfs_overlay"
# OpenSSH
BR2_PACKAGE_OPENSSH=y
# check
BR2_PACKAGE_CHECK=y
# pkg-config
BR2_PACKAGE_PKGCONF=y
BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y
EOF
1 change: 1 addition & 0 deletions scripts/build/build-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ rm $SDK_NAME.tar.gz
sed -i "/alias configure=/d" $SDK_NAME/environment-setup
sed -i "/export \"KERNELDIR=/c\export \"KERNELDIR=\$(dirname \$(dirname \$SDK_PATH))/linux-$KERNEL_VERSION\"" \
$SDK_NAME/environment-setup
echo "export \"PKG_CONFIG_SYSROOT_DIR=\$SDK_NAME\"" >> $SDK_NAME/environment-setup
rm start-qemu.sh

cd $WORKDIR && mkdir -p $OUTPUT_DIR
Expand Down
1 change: 0 additions & 1 deletion scripts/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ cd $BUILDDIR
$BASEDIR/configure CFLAGS="-ggdb3" --enable-examples

make -j $(nproc) V=1
make -j $(nproc) V=1 check
Loading

0 comments on commit bee1b25

Please sign in to comment.