[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Man-db-devel] [PATCH v2] src/tests: Use /tmp for temprorary directories
From: |
Mihail Konev |
Subject: |
[Man-db-devel] [PATCH v2] src/tests: Use /tmp for temprorary directories |
Date: |
Sat, 10 Dec 2016 03:35:54 +0500 |
Reduces disk reads/writes made by 'make check -C src'.
Fall back to ./tmp-* if 'mktemp -d' fails.
---
src/tests/man-1 | 4 ++--
src/tests/man-11 | 4 ++--
src/tests/man-3 | 4 ++--
src/tests/man-4 | 18 +++++++++---------
src/tests/man-5 | 2 +-
src/tests/man-8 | 2 +-
src/tests/man-9 | 6 +++---
src/tests/mandb-7 | 1 -
src/tests/testlib.sh | 16 +++++++++++++---
src/tests/zsoelim-1 | 2 +-
10 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/src/tests/man-1 b/src/tests/man-1
index 8c8d61902997..33b67eca6459 100755
--- a/src/tests/man-1
+++ b/src/tests/man-1
@@ -21,8 +21,8 @@ mkdir -p "$tmpdir/usr/local/man/man1"
ln -s ../../../share/man/man1/md5sum.textutils.1.gz \
"$tmpdir/usr/local/man/man1/md5sum.1.gz"
cat >"$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/man/man1/md5sum.textutils.1.gz
-$(pwd -P)/$tmpdir/usr/share/man/man1/md5sum.1.gz
+$abstmpdir/usr/share/man/man1/md5sum.textutils.1.gz
+$abstmpdir/usr/share/man/man1/md5sum.1.gz
EOF
run $MAN -C "$tmpdir/manpath.config" -aw md5sum >"$tmpdir/1.out"
expect_pass 'symlinks with matching names win' \
diff --git a/src/tests/man-11 b/src/tests/man-11
index ad6bee46137f..a16e41c6b991 100755
--- a/src/tests/man-11
+++ b/src/tests/man-11
@@ -22,7 +22,7 @@ write_page "$page_name" 2
"$tmpdir/usr/share/man/man2/${page_name}.2.gz" \
UTF-8 gz '' "$page_name \- $page_name() syscall manual page"
cat >"$tmpdir/2.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/man/man2/${page_name}.2.gz
+$abstmpdir/usr/share/man/man2/${page_name}.2.gz
EOF
run $MAN -C "$tmpdir/manpath.config" -aw "$page_name".2 >"$tmpdir/2.out"
@@ -35,7 +35,7 @@ expect_pass '"man name.2" is the same as "man 2 name"' \
)
cat >"$tmpdir/2p.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/man/man2/${page_name}.2p.gz
+$abstmpdir/usr/share/man/man2/${page_name}.2p.gz
EOF
run $MAN -C "$tmpdir/manpath.config" -aw "$page_name".2p >"$tmpdir/2p.out"
diff --git a/src/tests/man-3 b/src/tests/man-3
index c4e35619ca6d..d2bac985c08e 100755
--- a/src/tests/man-3
+++ b/src/tests/man-3
@@ -31,8 +31,8 @@ write_page md5sum 3pm
"$tmpdir/usr/share/man/man3/open.3pm.gz" \
write_page md5sum 3p "$tmpdir/usr/share/man/man3p/open.3p.gz" \
UTF-8 gz '' 'open \- section 3p'
cat >"$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/man/man3p/open.3p.gz
-$(pwd -P)/$tmpdir/usr/share/man/man3/open.3pm.gz
+$abstmpdir/usr/share/man/man3p/open.3p.gz
+$abstmpdir/usr/share/man/man3/open.3pm.gz
EOF
run $MAN -C "$tmpdir/manpath.config" -aw 3p open >"$tmpdir/1.out"
expect_pass 'exact section matches win' \
diff --git a/src/tests/man-4 b/src/tests/man-4
index c8c68325b867..a72931105559 100755
--- a/src/tests/man-4
+++ b/src/tests/man-4
@@ -37,7 +37,7 @@ expect_pass 'wildcards: -M option: without wildcards: check
missing man page' \
run $MAN -C "$tmpdir/manpath.config" \
-aw -M "${Mpath}" manx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/man/man1/manx.1.gz
+$abstmpdir/usr/share/man/man1/manx.1.gz
EOF
expect_pass 'wildcards: -M option: without wildcards: check existing man page'
\
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -54,7 +54,7 @@ expect_pass 'wildcards: -M option: with wildcards: check
missing man page' \
run $MAN -C "$tmpdir/manpath.config" \
-aw -M "${Mpath}" manpathx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/prog/a/man/man1/manpathx.1.gz
+$abstmpdir/usr/share/prog/a/man/man1/manpathx.1.gz
EOF
expect_pass 'wildcards: -M option: with wildcards: check existing man page' \
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -64,7 +64,7 @@ Mpath="$tmpdir/usr/share/prog/[ab]/man"
run $MAN -C "$tmpdir/manpath.config" \
-aw -M "${Mpath}" whatisx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/prog/b/man/man1/whatisx.1.gz
+$abstmpdir/usr/share/prog/b/man/man1/whatisx.1.gz
EOF
expect_pass 'wildcards: -M option: with wildcards: check existing man page II'
\
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -86,7 +86,7 @@ expect_pass 'wildcards: MANPATH: without wildcards: check
missing man page' \
run $MAN -C "$tmpdir/manpath.config" \
-aw manx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/man/man1/manx.1.gz
+$abstmpdir/usr/share/man/man1/manx.1.gz
EOF
expect_pass 'wildcards: MANPATH: without wildcards: check existing man page' \
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -104,7 +104,7 @@ expect_pass 'wildcards: MANPATH: with wildcards: check
missing man page' \
run $MAN -C "$tmpdir/manpath.config" \
-aw manpathx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/prog/a/man/man1/manpathx.1.gz
+$abstmpdir/usr/share/prog/a/man/man1/manpathx.1.gz
EOF
expect_pass 'wildcards: MANPATH: with wildcards: check existing man page' \
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -115,7 +115,7 @@ export MANPATH
run $MAN -C "$tmpdir/manpath.config" \
-aw whatisx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/prog/b/man/man1/whatisx.1.gz
+$abstmpdir/usr/share/prog/b/man/man1/whatisx.1.gz
EOF
expect_pass 'wildcards: MANPATH: with wildcards: check existing man page II' \
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -138,7 +138,7 @@ expect_pass 'wildcards: MANDATORY_MANPATH: without
wildcards: check missing man
run $MAN -C "$tmpdir/manpath.config" \
-aw manx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/man/man1/manx.1.gz
+$abstmpdir/usr/share/man/man1/manx.1.gz
EOF
expect_pass 'wildcards: MANDATORY_MANPATH: without wildcards: check existing
man page' \
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -155,7 +155,7 @@ expect_pass 'wildcards: MANDATORY_MANPATH: with wildcards:
check missing man pag
run $MAN -C "$tmpdir/manpath.config" \
-aw manpathx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/prog/a/man/man1/manpathx.1.gz
+$abstmpdir/usr/share/prog/a/man/man1/manpathx.1.gz
EOF
expect_pass 'wildcards: MANDATORY_MANPATH: with wildcards: check existing man
page' \
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
@@ -165,7 +165,7 @@ fake_config "/usr/share/prog/[ab]/man"
run $MAN -C "$tmpdir/manpath.config" \
-aw whatisx > "$tmpdir/1.out"
cat > "$tmpdir/1.exp" <<EOF
-$(pwd -P)/$tmpdir/usr/share/prog/b/man/man1/whatisx.1.gz
+$abstmpdir/usr/share/prog/b/man/man1/whatisx.1.gz
EOF
expect_pass 'wildcards: MANDATORY_MANPATH: with wildcards: check existing man
page II' \
'diff -u "$tmpdir/1.exp" "$tmpdir/1.out"'
diff --git a/src/tests/man-5 b/src/tests/man-5
index 017b69564902..32eddaae7af3 100755
--- a/src/tests/man-5
+++ b/src/tests/man-5
@@ -18,7 +18,7 @@ cat >"$tmpdir/fake-program" <<EOF
exec cat
EOF
chmod +x "$tmpdir/fake-program"
-PATH="$(pwd -P)/$tmpdir:$PATH"
+PATH="$abstmpdir:$PATH"
export PATH
cat >>"$tmpdir/manpath.config" <<EOF
diff --git a/src/tests/man-8 b/src/tests/man-8
index 896a354a6c6f..e994fd2be9e8 100755
--- a/src/tests/man-8
+++ b/src/tests/man-8
@@ -17,7 +17,7 @@ cat >"$tmpdir/fake-program" <<EOF
exec cat
EOF
chmod +x "$tmpdir/fake-program"
-PATH="$(pwd -P)/$tmpdir:$PATH"
+PATH="$abstmpdir:$PATH"
export PATH
cat >>"$tmpdir/manpath.config" <<EOF
diff --git a/src/tests/man-9 b/src/tests/man-9
index 948e2fb99289..4dc03319db9f 100755
--- a/src/tests/man-9
+++ b/src/tests/man-9
@@ -29,12 +29,12 @@ write_page abc 1
"${tmpdir}/usr/share/man/${OVERRIDE}/man1/abc.1" \
if [ -n "$OVERRIDE_DIR" ]; then
cat >"$tmpdir/1.exp" <<EOF
-$(pwd -P)/${tmpdir}/usr/share/man/${OVERRIDE}/man1/abc.1
-$(pwd -P)/${tmpdir}/usr/share/man/man1/abc.1
+$abstmpdir/usr/share/man/${OVERRIDE}/man1/abc.1
+$abstmpdir/usr/share/man/man1/abc.1
EOF
else
cat >"$tmpdir/1.exp" <<EOF
-$(pwd -P)/${tmpdir}/usr/share/man/man1/abc.1
+$abstmpdir/usr/share/man/man1/abc.1
EOF
fi
diff --git a/src/tests/mandb-7 b/src/tests/mandb-7
index fb86156682ea..657c8e07df38 100755
--- a/src/tests/mandb-7
+++ b/src/tests/mandb-7
@@ -12,7 +12,6 @@ fake_config /usr/share/man
mkdir -p "$tmpdir/usr/share/man"
mkdir -p "$tmpdir/usr/dir/man"
mkdir -p "$tmpdir/var/cache/man"
-abstmpdir="$(pwd -P)/$tmpdir"
echo "MANDATORY_MANPATH $abstmpdir/usr/share/man" >
"$tmpdir/manpath.config"
echo "MANDATORY_MANPATH $abstmpdir/usr/dir/man" >>
"$tmpdir/manpath.config"
echo "MANDB_MAP $abstmpdir/usr/share/man $abstmpdir/var/cache/man" >>
"$tmpdir/manpath.config"
diff --git a/src/tests/testlib.sh b/src/tests/testlib.sh
index d8fbc6ca07d3..160466966804 100644
--- a/src/tests/testlib.sh
+++ b/src/tests/testlib.sh
@@ -8,10 +8,20 @@ MAN_TEST_DISABLE_SYSTEM_CONFIG=1
export MAN_TEST_DISABLE_SYSTEM_CONFIG
init () {
- tmpdir="tmp-${0##*/}"
- mkdir -p "$tmpdir" || exit $?
+ # Create a temprorary directory in /tmp or ./ ,
+ # put path to it into $tmpdir and $abstmpdir,
+ # remove it on exit.
+ {
+ tmpdir=$(mktemp -d) &&
+ abstmpdir="$tmpdir" &&
+ test -d "$tmpdir"
+ } || {
+ tmpdir="tmp-${0##*/}"
+ abstmpdir="$(pwd -P)/$tmpdir"
+ mkdir "$tmpdir"
+ } ||
+ exit $?
trap 'rm -rf "$tmpdir"' HUP INT QUIT TERM
- abstmpdir="$(pwd -P)/$tmpdir"
}
run () {
diff --git a/src/tests/zsoelim-1 b/src/tests/zsoelim-1
index 686ad2bf3f7d..55421407ca71 100755
--- a/src/tests/zsoelim-1
+++ b/src/tests/zsoelim-1
@@ -18,7 +18,7 @@ cat >"$tmpdir/fake-program" <<EOF
exec cat
EOF
chmod +x "$tmpdir/fake-program"
-PATH="$(pwd -P)/$tmpdir:$PATH"
+PATH="$abstmpdir:$PATH"
export PATH
cat >>"$tmpdir/manpath.config" <<EOF
--
2.9.2