Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ jobs:
apt-get -q update
apt --yes upgrade
# Install stuff needed to check out the linuxcnc repo and turn it into a debian source package and run tests.
apt-get --yes --no-install-recommends install curl git lsb-release python3 devscripts sudo adduser xauth
apt-get --yes --no-install-recommends install curl git lsb-release python3 devscripts adduser xauth
- name: Checkout repository
uses: actions/checkout@v6
with:
Expand Down Expand Up @@ -360,8 +360,6 @@ jobs:
run: |
set -x
adduser --disabled-password --gecos "" testrunner
passwd -d testrunner
adduser testrunner sudo
chmod 0777 $(find tests/ -type d) # make test dirs world-writable for the testrunner
su -c "./scripts/runtests -p -d ./tests" testrunner
- name: Verify no untracked or modified files after test
Expand Down
11 changes: 4 additions & 7 deletions docs/src/code/writing-tests.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ The _runtests_ script accepts the following arguments, see the output from `scri
-s stop after any failed test.
-p print stderr and result files.
-c Remove temporary files from an earlier test run.
-u Only run tests that require normal user access.
-v Show stdout and stderr (normally it's hidden).
-d Enable crash dumps: print a gdb backtrace of the core when a test crashes.
----

== Writing tests
Expand Down Expand Up @@ -69,12 +69,9 @@ checkresult::
If both `expected` and `checkresult` exist, only `checkresult` is consulted to validate the test output.

skip::
If this file exist, the test is skipped and not executed at all.

control::
This file can be used to flag specific needs in the test.
At the moment, the use of _sudo_ can be flagged, and tests requiring sudo can be skipped when using `runtests -u`.
To flag such requirements, add a line with `Restrictions: sudo` to this file.
If this file exists and is not executable, the test is skipped and not executed at all.
If it is executable, it is run first and the test is skipped when it exits non-zero.
Tests never use _sudo_: a test that builds or installs a component with `halcompile` needs the build tree, so its `skip` file is `[ -z "$SYSTEM_BUILD" ]`, which skips it when testing installed packages.

musthave::
This file can contain a list of prerequisites from config.h (one per line). If it's not met, the test will be skipped.
Expand Down
17 changes: 1 addition & 16 deletions scripts/runtests.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ else
export LIBDIR=@EMC2_HOME@/lib
export LINUXCNC_EMCSH=@WISH@
export REALTIME=@REALTIME@
export SUDO=sudo
fi
export PYTHON_CPPFLAGS="@PYTHON_CPPFLAGS@"
export PYTHON_EXTRA_LIBS="@PYTHON_EXTRA_LIBS@"
Expand Down Expand Up @@ -236,14 +235,6 @@ run_tests () {
continue
fi
fi
if $NOSUDO && [ -e "$testdir/control" ] && \
grep Restrictions: "$testdir/control" | grep -q sudo; then
if ! [ -x "$testdir/skip" ] || ! "$testdir/skip"; then
echo "Skipping sudo test: $testdir" 1>&2
SKIP=$((SKIP + 1))
continue
fi
fi
NUM=$((NUM + 1))
TEST_DIR=$(readlink -f "$testdir")
export TEST_DIR
Expand Down Expand Up @@ -338,10 +329,6 @@ Usage:
$P -c tests
Remove temporary files from an earlier test run.

$P -u
Only run tests that require normal user access. Skip tests
requiring root or sudo.

$P -v
Show stdout and stderr (normally it's hidden).

Expand All @@ -354,14 +341,12 @@ EOF

CLEAN_ONLY=0
NOCLEAN=0
NOSUDO=false
STOP=0
PRINT=0
while getopts cnuvsphd opt; do
while getopts cnvsphd opt; do
case "$opt" in
c) CLEAN_ONLY=1 ;;
n) NOCLEAN=1 ;;
u) NOSUDO=true ;;
v) VERBOSE=1 ;;
s) STOP=1 ;;
p) PRINT=1 ;;
Expand Down
17 changes: 6 additions & 11 deletions tests/README
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ can be run by executing (from the top emc2 directory)
A subset of the tests can also be run:
scripts/runtests tests/xyz tests/a*

To only run the tests that do not require root or sudo access, use the
-u option:

scripts/runtests -u tests

The directories named on the commandline are searched recursively for
'test.hal' or 'test.sh' files, and a directory with such a file is
assumed to contain a regression test or a functional test.
Expand Down Expand Up @@ -100,10 +95,10 @@ and see if it indicates success.
The test passes if the command "checkresult actual" returns a shell
success value (exit code 0). Otherwise, the test fails.

Tests requiring root or sudo access are flagged by creating a file
named control in the test directory, with the 'sudo' flag in the
Restrictions field:

Restrictions: sudo
Tests never use root or sudo. A test directory may hold an executable
file named skip; the test is skipped when it exits non-zero. A test
that builds or installs a component with halcompile needs the build
tree, so it skips when testing installed packages:

Other restrictions might be added in the future
#!/bin/sh
[ -z "$SYSTEM_BUILD" ]
1 change: 0 additions & 1 deletion tests/halcompile/personalities_mod/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/halcompile/personalities_mod/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
6 changes: 3 additions & 3 deletions tests/halcompile/personalities_mod/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
set -e

${SUDO} halcompile --personalities=2 --install lincurve_test.comp
${SUDO} halcompile --personalities=2 --install logic_test.comp
${SUDO} halcompile --personalities=2 --install bitslice_test.comp
halcompile --personalities=2 --install lincurve_test.comp
halcompile --personalities=2 --install logic_test.comp
halcompile --personalities=2 --install bitslice_test.comp

# This tells us the expected filename extension ${MODULE_EXT} of realtime
# modules.
Expand Down
1 change: 0 additions & 1 deletion tests/halcompile/relative-header-user/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/halcompile/userspace-count-names/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
2 changes: 1 addition & 1 deletion tests/halcompile/userspace-count-names/test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

${SUDO} halcompile --install userspace_count_names.comp
halcompile --install userspace_count_names.comp

INSTALLED_FILE="${EMC2_HOME}/bin/userspace_count_names"
if [[ ! -f "${INSTALLED_FILE}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion tests/kins-frames/test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

${SUDO} halcompile --install framecheck.c >/dev/null
halcompile --install framecheck.c >/dev/null

# One hal file per module: they all define the same entry points, so
# only one can be loaded at a time.
Expand Down
2 changes: 1 addition & 1 deletion tests/kins-jacobian/test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

${SUDO} halcompile --install jaccheck.c >/dev/null
halcompile --install jaccheck.c >/dev/null

# One hal file per module: they all define the same entry points, so
# only one can be loaded at a time. A run that leaves the sweep at its
Expand Down
1 change: 0 additions & 1 deletion tests/module-loading/rtapi-app-main-fails/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/module-loading/rtapi-app-main-fails/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
2 changes: 1 addition & 1 deletion tests/module-loading/rtapi-app-main-fails/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
${SUDO} halcompile --install rtapi_app_main_fails.comp
halcompile --install rtapi_app_main_fails.comp
halrun -v setup.hal
RETVAL=$?

Expand Down
1 change: 0 additions & 1 deletion tests/realtime-math/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/realtime-math/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
2 changes: 1 addition & 1 deletion tests/realtime-math/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
set -xe
${SUDO} halcompile --install rtmath.comp
halcompile --install rtmath.comp
halrun dotest.hal
1 change: 0 additions & 1 deletion tests/rtapi-shmem/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/rtapi-shmem/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
2 changes: 1 addition & 1 deletion tests/rtapi-shmem/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh

${SUDO} halcompile --install test_shmem_rtcomp.comp
halcompile --install test_shmem_rtcomp.comp

halrun -V setup.hal
1 change: 0 additions & 1 deletion tests/symbols.0/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/symbols.0/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
4 changes: 2 additions & 2 deletions tests/symbols.0/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -xe
${SUDO} halcompile --install test_define.comp
${SUDO} halcompile --install test_use.comp
halcompile --install test_define.comp
halcompile --install test_use.comp
! halrun dotest.hal
1 change: 0 additions & 1 deletion tests/symbols.1/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/symbols.1/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
4 changes: 2 additions & 2 deletions tests/symbols.1/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -e
${SUDO} halcompile --install test_define1.comp
${SUDO} halcompile --install test_use1.comp
halcompile --install test_define1.comp
halcompile --install test_use1.comp
halrun dotest.hal
1 change: 0 additions & 1 deletion tests/uspace/spawnv-root/control

This file was deleted.

4 changes: 4 additions & 0 deletions tests/uspace/spawnv-root/skip
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
# Installs a component with halcompile, which needs a writable build
# tree. Skip when testing installed packages.
[ -z "$SYSTEM_BUILD" ]
2 changes: 1 addition & 1 deletion tests/uspace/spawnv-root/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ if [ "$RTPREFIX" != uspace ]; then
exit 0
fi

${SUDO} halcompile --install test_uspace_spawnv.c
halcompile --install test_uspace_spawnv.c
halrun test_uspace_spawnv.hal
Loading