Skip to content

Commit ceea26e

Browse files
committed
tests: Add LTP
1 parent 5756ad6 commit ceea26e

5 files changed

Lines changed: 117 additions & 0 deletions

File tree

tests/ltp/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ltp.tar.xz
2+
src
3+
install
4+
log

tests/ltp/Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
help:
2+
@echo "ltp test"
3+
@echo "Available targets:"
4+
@echo " download # download required sources"
5+
@echo " prepare # download and install dependencies"
6+
@echo " build # build the tests"
7+
@echo " test # run the syscall test suite"
8+
9+
version = 20220930
10+
tarball = ltp.tar.xz
11+
12+
download: $(tarball)
13+
14+
$(tarball):
15+
wget --no-verbose -O $@.tmp https://github.com/linux-test-project/ltp/releases/download/$(version)/ltp-full-$(version).tar.xz
16+
mv $@.tmp $@
17+
18+
prepare: download
19+
@./install-deps.sh
20+
21+
install: $(tarball)
22+
@./install-deps.sh
23+
+@./build.sh
24+
25+
build: install
26+
27+
test: install
28+
+@./test.sh -f syscalls
29+
30+
clean:
31+
rm -rf src log
32+
sudo rm -rf install
33+
34+
distclean: clean
35+
rm -f $(tarball)
36+
37+
.PHONY: download prepare build test clean distclean help

tests/ltp/build.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
rm -rf src
6+
tar -xf ltp.tar.xz
7+
mv ltp-full-* src
8+
9+
if [[ -n ${MAKEFLAGS:-} ]]; then
10+
# Don't override existing make flags
11+
jflags=
12+
else
13+
jflags="-j $(nproc)"
14+
fi
15+
16+
echo "Sending output to $PWD/log."
17+
rm -f log
18+
19+
{
20+
cd src
21+
22+
set -x
23+
./configure --prefix=$PWD/../install
24+
make $jflags -s
25+
make $jflags -s install
26+
rm -rf src
27+
28+
set +x
29+
echo "success: ltp" >&2
30+
31+
} 2>&1 >> log | tee -a log

tests/ltp/install-deps.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
. /etc/os-release
6+
7+
sudo=""
8+
if [[ $(id -u) != 0 ]]; then
9+
sudo="sudo"
10+
fi
11+
12+
if [[ "$ID" == "fedora" ]]; then
13+
(set -x; $sudo dnf -y install gcc)
14+
elif [[ "$ID_LIKE" == "debian" ]]; then
15+
(set -x; $sudo apt-get -y install gcc)
16+
else
17+
echo "Unsupported distro!" >&2
18+
exit 1
19+
fi

tests/ltp/test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
sudo=""
6+
if [[ $(id -u) != 0 ]]; then
7+
sudo="sudo"
8+
fi
9+
10+
echo "Sending output to $PWD/log."
11+
rm -f log
12+
13+
{
14+
cd install
15+
16+
set -x
17+
$sudo ./runltp $@
18+
19+
set +x
20+
21+
# Make sure logs aren't owned by root
22+
$sudo chown -R $(id -u) output
23+
24+
echo "success: ltp" >&2
25+
26+
} 2>&1 >> log | tee -a log

0 commit comments

Comments
 (0)