Skip to content

Commit 75ff6e4

Browse files
committed
Add initial github tests
Add running and packaging tests. Fix problems found when adding tests Signed-off-by: Corentin Labbe <[email protected]>
1 parent 0eead3d commit 75ff6e4

File tree

8 files changed

+120
-4
lines changed

8 files changed

+120
-4
lines changed

.github/workflows/tests.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
# yamllint disable rule:line-length
3+
name: tests yasat
4+
5+
on: # yamllint disable-line rule:truthy
6+
push:
7+
pull_request:
8+
9+
jobs:
10+
test-ubuntu:
11+
runs-on: ubuntu-latest
12+
name: test on ubuntu
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: update pkglist
16+
run: sudo apt-get update
17+
- name: install some tested packages
18+
run: sudo apt-get -y install tomcat9
19+
- name: Run tests
20+
run: |
21+
make test
22+
./tests/test.test -d
23+
- name: Run yasat
24+
run: |
25+
./yasat
26+
./yasat -1 ntp
27+
./yasat -1 cups
28+
./yasat -1 classique
29+
ls -l /home/runner/.yasat//yasat.report
30+
test-bashishms:
31+
runs-on: ubuntu-latest
32+
name: Check bashisms
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: update pkglist
36+
run: sudo apt-get update
37+
- name: install checkbashisms
38+
run: sudo apt-get -y install devscripts
39+
- name: Run checkbashisms
40+
run: checkbashisms yasat common plugins/*test
41+
ubuntu-pkg:
42+
runs-on: ubuntu-latest
43+
name: build ubuntu package
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: update pkglist
47+
run: sudo apt-get update
48+
- name: Install packages
49+
run: sudo apt-get -y install devscripts gnupg debhelper-compat
50+
- name: create orig targz
51+
run: cd .. && tar czf yasat_0-1.orig.tar.gz yasat
52+
- name: Run debuild
53+
run: debuild -i -us -uc -b --lintian-opts --profile debian
54+
- name: Run debuild help
55+
run: debuild --help
56+
debian-pkg:
57+
runs-on: ubuntu-latest
58+
name: build debian package
59+
steps:
60+
- uses: actions/checkout@v4
61+
- name: update pkglist
62+
run: sudo apt-get update
63+
- name: Install packages
64+
run: sudo apt-get -y install debootstrap
65+
- name: Create a bookworm
66+
run: sudo debootstrap bookworm /root/bookworm
67+
- name: copy yasat source
68+
run: sudo cp -a ../yasat /root/bookworm/
69+
- name: Install update pkg in chroot
70+
run: sudo chroot /root/bookworm apt-get update
71+
- name: Install update pkg in chroot
72+
run: sudo chroot /root/bookworm apt-get -y install devscripts gnupg debhelper-compat
73+
- name: Generate wrapper
74+
run: |
75+
echo '#!/bin/sh' >> run.sh
76+
echo 'cd /yasat' >> run.sh
77+
echo 'debuild -i -us -uc -b' >> run.sh
78+
chmod 755 run.sh
79+
sudo cp run.sh /root/bookworm/
80+
- name: Run debuild
81+
run: sudo chroot /root/bookworm /run.sh

common

+14
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,20 @@ Is_installed_via_package_manager()
24552455
return 0;
24562456
fi
24572457
if [ "$LIST_PKG" = "emerge" ] ;then
2458+
if [ -z "$CACHE_EMERGE_OK" ];then
2459+
# check if we have can use portage
2460+
emerge --info 2>/dev/null >/dev/null
2461+
if [ $? -ne 0 ];then
2462+
Display --indent 2 --text "Could not work with emerge (cached)" --result EPERM --color RED
2463+
CACHE_EMERGE_OK="ko"
2464+
return 0
2465+
fi
2466+
fi
2467+
if [ "$CACHE_EMERGE_OK" = 'ko' ];then
2468+
Display --indent 2 --text "Could not work with emerge (cached)" --result EPERM --color RED
2469+
return 0
2470+
fi
2471+
CACHE_EMERGE_OK="ok"
24582472
#TODO could be better
24592473
PKGLIST="`equery -C -q l $1`"
24602474
if [ -z "$PKGLIST" ] ;then

debian/compat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5
1+
10

plugins/apache_modules.test

+9-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ fi
6565
check_file "$APACHE_BIN" 2 BINARY
6666

6767
if [ "$LINUX_VERSION" = "Gentoo" ] ;then
68-
. /etc/conf.d/apache2
68+
if [ ! -r /etc/conf.d/apache2 ];then
69+
TESTNAME='YASAT_TEST_APACHE_MODULES_READ_CONFD_APACHE Check if we can use /etc/conf.d/apache2'
70+
Display --indent 2 --text "Cannot read /etc/conf.d/apache2" --result ERROR --color RED
71+
else
72+
. /etc/conf.d/apache2
73+
if [ $? -ne 0 ];then
74+
echo "ERROR: could not read /etc/conf.d/apache2"
75+
fi
76+
fi
6977
APACHE_BIN="$APACHE_BIN $APACHE2_OPTS"
7078
fi
7179

plugins/process.data

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ aisexec=CANBEROOT
2929
/usr/sbin/atd=CANBEROOT
3030
/usr/sbin/monit=CANBEROOT
3131
/sbin/rsyslogd=CANBEROOT
32+
/usr/bin/containerd=CANBEROOT
33+
/usr/libexec/packagekitd=CANBEROOT
34+
/usr/libexec/polkitd=CANBEROOT
35+
/sbin/agetty=CANBEROOT
36+
/usr/bin/podman=CANBEROOT
3237

3338
#ONLYROOT
3439
/sbin/udevd=ONLYROOT

plugins/process.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Title "Check running process"
2626
if [ ! -e "${PLUGINS_REP}/process.data" ]
2727
then
2828
Display --indent 2 --text "process.data" --result NOTFOUND --color RED
29-
return -1;
29+
return 1;
3030
fi
3131

3232
#TODO FreeBSD said ps: Process environment requires procfs(5)

plugins/tomcat.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ do
105105
then
106106
Display --indent 2 --text "Tomcat $TOMCAT_VERSION found at $BASE_TOMCAT" --result FOUND --color GREEN
107107

108-
check_directory_others $BASE_TOMCAT $TMP_RESULT2 4
108+
check_directory_others $BASE_TOMCAT $TMP_RESULT2 4 TODO
109109

110110
fi
111111
if [ "$TOMCAT_MAJOR_VERSION" != "0" -a "$TOMCAT_MINOR_VERSION" != "0" ] ;then

tests/test.test

+8
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ QUIET=0
2525
HIDESR=0
2626
YASAT_ROOT=.
2727
COL_WIDTH="`tput cols`"
28+
# tput could fail
29+
if [ -z "$COL_WIDTH" ];then
30+
COL_WIDTH=79
31+
fi
2832
PRINT_LEVEL=0
2933
ADVICELANG='EN'
3034

35+
if [ "$1" == "-d" ];then
36+
DEBUG=1
37+
fi
38+
3139
. ./common
3240
. ./osdetection
3341

0 commit comments

Comments
 (0)