Skip to content

Commit

Permalink
CI: Add valgrind check
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Gladkov <legion@kernel.org>
  • Loading branch information
legionus committed Mar 6, 2025
1 parent a6c3751 commit 1e14b84
Show file tree
Hide file tree
Showing 20 changed files with 120 additions and 103 deletions.
67 changes: 2 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ jobs:
CHECK_KEYWORDS: ${{ matrix.check }}
SANDBOX: priviliged
TTY: /dev/tty60
HAVE_VGA: 1
steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: sudo apt-get update -y -qq
- run: sudo apt-get install -y -qq autoconf automake autopoint libtool libtool-bin libpam0g-dev bison flex gettext kbd strace
- run: sudo apt-get install -y -qq autoconf automake autopoint libtool libtool-bin libpam0g-dev bison flex gettext kbd strace valgrind
- run: sudo apt-get install -y -qq gcc clang musl musl-dev musl-tools
- name: "Configure"
run: |
Expand All @@ -122,67 +123,3 @@ jobs:
if-no-files-found: ignore
retention-days: 1

qemu_build_job:
name: "Check on ${{ matrix.arch }}"
strategy:
matrix:
include:
- arch: x86_64
- arch: s390x
- arch: ppc64el
fail-fast: false
runs-on: ubuntu-latest
needs: [ check_commits_job, distcheck_job ]
env:
CI_ARCH: ${{ matrix.arch }}
CI_UBUNTU_VERSION: "24.10"

steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Prepare Node"
run: |
for m in kvm kvm-amd kvm-intel; do sudo modprobe -v "$m" ||:; done
test -c /dev/kvm && sudo chmod -v 666 /dev/kvm ||:
- name: "Install dependencies"
run: |
sudo apt-get update -y -qq
sudo apt-get install -y -qq qemu-system ssh cloud-image-utils
- name: "Prepare cloud image for VM"
run: tests/ci/create-cloud-image.sh

- name: "Start VM"
run: |
tests/ci/start-qemu-vm.sh "$PWD"
while ! tests/ci/vm-ssh.sh ubuntu@localhost /bin/true; do sleep 1; done
- name: "Install dependencies into VM"
run: tests/ci/vm-ssh.sh ubuntu@localhost /opt/tests/ci/qemu-install-dependencies.sh

- name: "Copy sources into VM"
run: |
tests/ci/vm-ssh.sh ubuntu@localhost mkdir /tmp/kbd
tests/ci/vm-scp.sh -r . ubuntu@localhost:/tmp/kbd/
- name: "Build project in the VM"
run: |
rc=0
tests/ci/vm-ssh.sh ubuntu@localhost /opt/tests/ci/qemu-run-build-and-tests.sh ${{ matrix.arch }} || rc=1
tests/ci/vm-scp.sh ubuntu@localhost:artifacts.tar /tmp/${{ matrix.arch }}/ ||:
exit $rc
- name: "Upload artifacts"
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-on-${{ matrix.arch }}-artifacts
path: |
/tmp/${{ matrix.arch }}/qemu.log
/tmp/${{ matrix.arch }}/artifacts.tar
if-no-files-found: ignore
retention-days: 1
17 changes: 2 additions & 15 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,8 @@ ATPACKAGE = $(abs_builddir)/atpackage
TESTSUITE = $(abs_builddir)/testsuite

EXTRA_DIST = \
data \
e2e-clrunimap.at \
e2e-dumpkeys.at \
e2e-getunimap.at \
e2e-kbdinfo.at \
e2e-kbd_mode.at \
e2e-loadkeys.at \
e2e-loadunimap.at \
e2e-psfxtable.at \
e2e-setfont.at \
e2e-setvtrgb.at \
e2e.at \
libkbdfile.at \
libkeymap.at \
testsuite.at \
data \
$(wildcard *.at) \
$(NULL)

CLEANFILES = \
Expand Down
2 changes: 1 addition & 1 deletion tests/ci/qemu-install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ message "system info"

apt_get_install \
autoconf automake autopoint libtool libtool-bin pkg-config \
make bison flex gettext kbd strace libpam0g-dev \
make bison flex gettext kbd strace valgrind libpam0g-dev \
gcc
5 changes: 5 additions & 0 deletions tests/e2e-memcheck-clrunimap.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AT_SETUP([clrunimap])
AT_KEYWORDS([e2e clrunimap memcheck])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
E2E_MEMCHECK(["$abs_top_builddir/src/clrunimap"])
AT_CLEANUP
14 changes: 14 additions & 0 deletions tests/e2e-memcheck-getunimap.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AT_SETUP([getunimap (empty unimap)])
AT_KEYWORDS([e2e getunimap memcheck])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
clrunimap || "$abs_top_builddir/src/clrunimap"
E2E_MEMCHECK(["$abs_top_builddir/src/getunimap"])
AT_CLEANUP

AT_SETUP([getunimap (cp866)])
AT_KEYWORDS([e2e getunimap memcheck])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
clrunimap || "$abs_top_builddir/src/clrunimap"
loadunimap "$abs_srcdir/data/unimaps/cp866.uni"
E2E_MEMCHECK(["$abs_top_builddir/src/getunimap"])
AT_CLEANUP
7 changes: 7 additions & 0 deletions tests/e2e-memcheck-loadkeys.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
AT_SETUP([loadkeys (path/ruwin_cplk-UTF-8.map)])
AT_KEYWORDS([e2e loadkeys memcheck])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
kbd_mode -u -f
"loadkeys" -c -s "$abs_srcdir/data/keymaps/VoidSymbol.map"
E2E_MEMCHECK(["$abs_top_builddir/src/loadkeys" "$abs_srcdir/data/keymaps/i386/qwerty/ruwin_cplk-UTF-8.map"])
AT_CLEANUP
6 changes: 6 additions & 0 deletions tests/e2e-memcheck-setfont.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AT_SETUP([setfont (path/UniCyrExt_8x16.psf)])
AT_KEYWORDS([e2e setfont memcheck])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
AT_SKIP_IF([ test -z "$HAVE_VGA" ])
E2E_CHECK(["$abs_top_builddir/src/setfont" -v "$abs_srcdir/data/consolefonts/UniCyrExt_8x16.psf"])
AT_CLEANUP
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions tests/e2e-strace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh -efu

cwd="$(readlink -ev "${0%/*}")"

rc=0
strace -o syscalls.raw -s 1073741823 -e abbrev=none -e trace=/open.*,/ioctl \
-- "$@" \
1>stdout \
2>stderr || rc=$?

"$cwd/syscall-filter.sed" < syscalls.raw > syscalls ||:

exit $rc
File renamed without changes.
12 changes: 10 additions & 2 deletions tests/e2e-getunimap.at → tests/e2e-syscalls-getunimap.at
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
AT_SETUP([getunimap (empty unimap)])
AT_KEYWORDS([e2e getunimap])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
clrunimap
clrunimap || "$abs_top_builddir/src/clrunimap"
E2E_CHECK(["$abs_top_builddir/src/getunimap"])
E2E_COMPARE_SYSCALLS([cat $abs_srcdir/data/e2e/getunimap-test01.calls])
AT_CLEANUP

AT_SETUP([getunimap (cp866)])
AT_KEYWORDS([e2e getunimap])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
clrunimap
clrunimap || "$abs_top_builddir/src/clrunimap"
loadunimap "$abs_srcdir/data/unimaps/cp866.uni"
E2E_CHECK(["$abs_top_builddir/src/getunimap"])
E2E_COMPARE_SYSCALLS([cat $abs_srcdir/data/e2e/getunimap-test02.calls], [clrunimap], [clrunimap])
AT_CLEANUP

AT_SETUP([getunimap (cp866)])
AT_KEYWORDS([e2e getunimap])
AT_SKIP_IF([ test "$SANDBOX" != "priviliged" ])
clrunimap || "$abs_top_builddir/src/clrunimap"
loadunimap "$abs_srcdir/data/unimaps/cp866.uni"
E2E_MEMCHECK(["$abs_top_builddir/src/getunimap"])
AT_CLEANUP
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions tests/e2e-valgrind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh -efu

tool="$1"
shift

case "$tool" in
memcheck)
valgrind_args="--leak-check=full --leak-resolution=high --show-leak-kinds=all"
;;
*)
echo >&1 "$0: unknown valgrind tool: $tool"
exit 1
;;
esac

rc=0
valgrind --tool="$tool" $valgrind_args --error-exitcode=1 -- "$@" \
1>stdout.valgrind \
2>stderr.valgrind || rc=$?

if [ $rc -eq 0 ]; then
rm -f -- stdout.valgrind stderr.valgrind
exit 0
fi

mv -f -- stdout.valgrind stdout
mv -f -- stderr.valgrind stderr

exit $rc
51 changes: 31 additions & 20 deletions tests/e2e.at
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
m4_define([E2E_RUN_PIPE],[[
rc=0;
$1 | libtool --mode=execute -- \
strace -o syscalls.raw -s 1073741823 -e abbrev=none -e trace=/open.*,/ioctl -- $2 1>stdout 2>stderr || rc=$?;
"$abs_srcdir/syscall-filter.sed" < syscalls.raw > syscalls ||:;
exit $rc;
$1 | libtool --mode=execute -- "$abs_srcdir"/e2e-strace.sh $2 || exit $?;
]])

m4_define([E2E_RUN],[[
rc=0;
libtool --mode=execute -- \
strace -o syscalls.raw -s 1073741823 -e abbrev=none -e trace=/open.*,/ioctl -- $1 1>stdout 2>stderr || rc=$?;
"$abs_srcdir/syscall-filter.sed" < syscalls.raw > syscalls ||:
exit $rc;
libtool --mode=execute -- "$abs_srcdir"/e2e-strace.sh $1 || exit $?
]])

m4_define([E2E_RUN_MEMCHECK],[[
libtool --mode=execute -- "$abs_srcdir"/e2e-valgrind.sh memcheck $1 || exit $?
]])

m4_define([E2E_MEMCHECK],[
AT_CHECK([E2E_RUN_MEMCHECK([$1])], [0], [], [], [$2], [$3])
])

m4_define([E2E_CHECK_PIPE],[
AT_CHECK([E2E_RUN_PIPE([$1], [$2])], [0], [], [], [$3], [$4])
])
Expand All @@ -38,13 +38,24 @@ m4_define([E2E_COMPARE_STDERR], [E2E_COMPARE_CONTENT([$1], [stderr])])

AT_BANNER([e2e tests])

m4_include([e2e-clrunimap.at])
m4_include([e2e-getunimap.at])
m4_include([e2e-kbd_mode.at])
m4_include([e2e-kbdinfo.at])
m4_include([e2e-loadkeys.at])
m4_include([e2e-dumpkeys.at])
m4_include([e2e-loadunimap.at])
m4_include([e2e-psfxtable.at])
m4_include([e2e-setfont.at])
m4_include([e2e-setvtrgb.at])
m4_include([e2e-syscalls-clrunimap.at])
m4_include([e2e-syscalls-getunimap.at])
m4_include([e2e-syscalls-kbd_mode.at])
m4_include([e2e-syscalls-kbdinfo.at])
m4_include([e2e-syscalls-loadkeys.at])
m4_include([e2e-syscalls-loadunimap.at])
m4_include([e2e-syscalls-setfont.at])
m4_include([e2e-syscalls-setvtrgb.at])

AT_BANNER([e2e misc])

m4_include([e2e-misc-psfxtable.at])
m4_include([e2e-misc-dumpkeys.at])

AT_BANNER([e2e memcheck])

m4_include([e2e-memcheck-clrunimap.at])
m4_include([e2e-memcheck-clrunimap.at])
m4_include([e2e-memcheck-getunimap.at])
m4_include([e2e-memcheck-loadkeys.at])
m4_include([e2e-memcheck-setfont.at])

0 comments on commit 1e14b84

Please sign in to comment.