Commit f09429fd authored by Gabriel Krisman Bertazi's avatar Gabriel Krisman Bertazi
Browse files

testsuite: Execute tests relative to temporary directory



Instead of hardcoding /tmp/ci use the result of $(mktemp -d)
Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.co.uk>
parent 8f24b67b
#
# Copyright 2018 Collabora.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
# Author: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
package require fileutil
set test_mnt [::fileutil::maketempdir]
......@@ -61,12 +61,15 @@ proc run_test_program {prog progargs} {
}
proc run_ci_test_program {prog progargs} {
global libcasefold_path
global libcasefold_path test_mnt
set orig_ld_preload "[getenv LD_PRELOAD]"
set orig_cimountpoints "[getenv CIMOUNTPOINTS]"
setenv LD_PRELOAD "$libcasefold_path:$orig_ld_preload"
setenv CI_MOUNTPOINTS "$test_mnt"
set result [run_test_program $prog $progargs]
setenv LD_PRELOAD "$orig_ld_preload"
setenv CI_MOUNTPOINTS "$orig_cimountpoints"
return $result
}
......
......@@ -24,22 +24,23 @@ set timeout 3
set test_file "basic.exp"
proc basic_ls_test {} {
prepare_test "touch" "/tmp/ci/abc123"
global test_mnt
prepare_test "touch" "$test_mnt/abc123"
run_ci "Exact name lookup" \
"ls" "/tmp/ci/abc123" "/tmp/ci/abc123\n"
"ls" "$test_mnt/abc123" "$test_mnt/abc123\n"
run_cs "CS Non-existant file" \
"ls" "/tmp/ci/ABC123" "*No such file or directory*"
"ls" "$test_mnt/ABC123" "*No such file or directory*"
run_ci "Inexact name lookup" \
"ls" "/tmp/ci/ABC123" "/tmp/ci/ABC123\n"
"ls" "$test_mnt/ABC123" "$test_mnt/ABC123\n"
run_ci "Inexact name lookup of inexistant file" \
"ls" "/tmp/ci/ABC132" "*No such file or directory*"
"ls" "$test_mnt/ABC132" "*No such file or directory*"
prepare_test "rm" "/tmp/ci/abc123"
prepare_test "rm" "$test_mnt/abc123"
}
basic_ls_test
......
......@@ -25,153 +25,146 @@ set test_file "simpleprograms.exp"
set basedir "$objdir/libcasefold.simpleprograms"
proc chdir {} {
global basedir
global test_mnt basedir
set chdir "$basedir/chdir"
prepare_test "mkdir" "/tmp/ci/chdir-dest"
prepare_test "mkdir" "/tmp/ci/chdir-dest/indir"
prepare_test "touch" "/tmp/ci/chdir-dest/chdir-invalid-dest"
prepare_test "mkdir" "$test_mnt/chdir-dest"
prepare_test "mkdir" "$test_mnt/chdir-dest/indir"
prepare_test "touch" "$test_mnt/chdir-dest/chdir-invalid-dest"
run_cs "chdir sanity check" \
"$chdir" "/tmp/ci/chdir-dest" "*Test Complete*"
"$chdir" "$test_mnt/chdir-dest" "*Test Complete*"
run_ci "chdir insensitive test" \
"$chdir" "/tmp/ci/chdir-DEST" "*Test Complete*"
"$chdir" "$test_mnt/chdir-DEST" "*Test Complete*"
run_ci "chdir with one ci depper level" \
"$chdir" "/tmp/ci/chdir-dest/INDIR" "*Test Complete*"
"$chdir" "$test_mnt/chdir-dest/INDIR" "*Test Complete*"
run_ci "chdir with two ci depper level" \
"$chdir" "/tmp/ci/chdir-DEST/INDIR" "*Test Complete*"
"$chdir" "$test_mnt/chdir-DEST/INDIR" "*Test Complete*"
run_ci "chdir with two ci depper level and a .. at end" \
"$chdir" "/tmp/ci/chdir-DEST/INDIR/.." "*Test Complete*"
"$chdir" "$test_mnt/chdir-DEST/INDIR/.." "*Test Complete*"
run_ci "chdir with two ci depper level and a .. at middle" \
"$chdir" "/tmp/ci/chdir-DEST/../chdir-DeST/indir" \
"$chdir" "$test_mnt/chdir-DEST/../chdir-DeST/indir" \
"*Test Complete*"
run_ci "chdir with two ci depper level and a . at middle" \
"$chdir" "/tmp/ci/chdir-DEST/../chdir-DeST/./indir" \
"$chdir" "$test_mnt/chdir-DEST/../chdir-DeST/./indir" \
"*Test Complete*"
run_ci "chdir with two ci depper level and a . at end" \
"$chdir" "/tmp/ci/chdir-DEST/../chdir-DeST/./indir/." \
"$chdir" "$test_mnt/chdir-DEST/../chdir-DeST/./indir/." \
"*Test Complete*"
run_ci_on_dir "chdir on relative path" "/tmp/ci" \
run_ci_on_dir "chdir on relative path" "$test_mnt" \
"$chdir" "chdir-DEST" "*Test Complete*"
run_ci_on_dir "chdir on relative path" "/tmp/ci" \
run_ci_on_dir "chdir on relative path" "$test_mnt" \
"$chdir" "chdir-DEST" "*Test Complete*"
run_ci_on_dir "chdir on relative path plus ." "/tmp/ci" \
run_ci_on_dir "chdir on relative path plus ." "$test_mnt" \
"$chdir" "chdir-DEST/." "*Test Complete*"
run_ci_on_dir "chdir on relative path plus .." "/tmp/ci" \
run_ci_on_dir "chdir on relative path plus .." "$test_mnt" \
"$chdir" "chdir-DEST/.." "*Test Complete*"
run_ci_on_dir "chdir on relative cs path starting with ." \
"/tmp/ci/chdir-dest" "$chdir" "." \
"$test_mnt/chdir-dest" "$chdir" "." \
"*Test Complete*"
run_ci_on_dir "chdir on relative cs path starting with .." \
"/tmp/ci/chdir-dest" "$chdir" "../chdir-deSt" \
"$test_mnt/chdir-dest" "$chdir" "../chdir-deSt" \
"*Test Complete*"
run_ci "chdir to file must fail" \
"$chdir" "/tmp/ci/chdir-DEST/chdir-InVaLiD-dest" \
"$chdir" "$test_mnt/chdir-DEST/chdir-InVaLiD-dest" \
"*Error: Not a directory*"
prepare_test "rm" "/tmp/ci/chdir-dest/chdir-invalid-dest"
prepare_test "rmdir" "/tmp/ci/chdir-dest/indir"
prepare_test "rmdir" "/tmp/ci/chdir-dest"
prepare_test "rm" "$test_mnt/chdir-dest/chdir-invalid-dest"
prepare_test "rmdir" "$test_mnt/chdir-dest/indir"
prepare_test "rmdir" "$test_mnt/chdir-dest"
}
proc lstat {} {
global basedir
global basedir test_mnt
set lstat "$basedir/lstat"
prepare_test "mkdir" "/tmp/ci/lstat-dest"
prepare_test "touch" "/tmp/ci/lstat-file1"
prepare_test "touch" "/tmp/ci/lstat-dest/lstat-file2"
prepare_test "mkdir" "$test_mnt/lstat-dest"
prepare_test "touch" "$test_mnt/lstat-file1"
prepare_test "touch" "$test_mnt/lstat-dest/lstat-file2"
run_cs "lstat sanity check on directory" \
"$lstat" "/tmp/ci/lstat-dest" "*Test Complete*"
"$lstat" "$test_mnt/lstat-dest" "*Test Complete*"
run_ci "lstat insensitive test on dir" \
"$lstat" "/tmp/ci/lstat-DEST" "*Test Complete*"
"$lstat" "$test_mnt/lstat-DEST" "*Test Complete*"
run_ci "lstat insensitive test on file" \
"$lstat" "/tmp/ci/lstat-FILE1" "*Test Complete*"
"$lstat" "$test_mnt/lstat-FILE1" "*Test Complete*"
run_ci "lstat insensitive test on inner file " \
"$lstat" "/tmp/ci/lstat-dEsT/lstat-FILE2" "*Test Complete*"
"$lstat" "$test_mnt/lstat-dEsT/lstat-FILE2" "*Test Complete*"
run_ci "lstat insensitive test with .. inner file " \
"$lstat" "/tmp/ci/lstat-dEsT/../lstat-FILE1" "*Test Complete*"
"$lstat" "$test_mnt/lstat-dEsT/../lstat-FILE1" "*Test Complete*"
run_ci "lstat insensitive test with . inner file " \
"$lstat" "/tmp/ci/lstat-dEsT/.././lstat-FILE1" "*Test Complete*"
"$lstat" "$test_mnt/lstat-dEsT/.././lstat-FILE1" "*Test Complete*"
run_ci "lstat insensitive test with . at the end " \
"$lstat" "/tmp/ci/lstat-dEsT/.././" "*Test Complete*"
"$lstat" "$test_mnt/lstat-dEsT/.././" "*Test Complete*"
run_ci_on_dir "lstat relative to CI mountpoint" \
"/tmp/ci" "$lstat" "lstat-DeST" "*Test Complete*"
run_ci_on_dir "CI lstat relative to CS mountpoint" \
"/tmp/" "$lstat" "ci/lstat-DeST" "*Test Complete*"
"$test_mnt" "$lstat" "lstat-DeST" "*Test Complete*"
run_ci_on_dir "CI lstat relative on file with .." \
"/tmp/" "$lstat" "ci/lstat-DeST/../lstat-FILe1" \
"$test_mnt" "$lstat" "lstat-DeST/../lstat-FILe1" \
"*Test Complete*"
prepare_test "rm" "/tmp/ci/lstat-dest/lstat-file2"
prepare_test "rmdir" "/tmp/ci/lstat-dest"
prepare_test "rm" "/tmp/ci/lstat-file1"
prepare_test "rm" "$test_mnt/lstat-dest/lstat-file2"
prepare_test "rmdir" "$test_mnt/lstat-dest"
prepare_test "rm" "$test_mnt/lstat-file1"
}
proc unlink {} {
global basedir
global basedir test_mnt
set unlink "$basedir/unlink"
prepare_test "mkdir" "/tmp/ci/basic-unlink"
prepare_test "mkdir" "$test_mnt/basic-unlink"
run_ci "dynamic unlink test" \
"$unlink" "/tmp/ci/basic-unlink" "*Test Complete*"
"$unlink" "$test_mnt/basic-unlink" "*Test Complete*"
prepare_test "rm" "/tmp/ci/basic-unlink/ABC123"
prepare_test "rmdir" "/tmp/ci/basic-unlink"
prepare_test "rm" "$test_mnt/basic-unlink/ABC123"
prepare_test "rmdir" "$test_mnt/basic-unlink"
}
proc fstatat {} {
global basedir
global basedir test_mnt
set fstatat "$basedir/fstatat"
prepare_test "mkdir" "/tmp/ci/fstatat"
prepare_test "touch" "/tmp/ci/fstatat/fstatat-AAAAA"
prepare_test "touch" "/tmp/ci/fstatat-AAAAA"
prepare_test "mkdir" "$test_mnt/fstatat"
prepare_test "touch" "$test_mnt/fstatat/fstatat-AAAAA"
prepare_test "touch" "$test_mnt/fstatat-AAAAA"
run_ci "CI fstatat with real dfd" \
"$fstatat" "/tmp/ci/fstATat/ fstatat-AAAaa" "*Test Complete*"
"$fstatat" "$test_mnt/fstATat/ fstatat-AAAaa" "*Test Complete*"
run_ci "CI fstatat with real dfd after .." \
"$fstatat" "/tmp/ci/fstaTAT/../ fstatat-AAAaa" "*Test Complete*"
"$fstatat" "$test_mnt/fstaTAT/../ fstatat-AAAaa" "*Test Complete*"
run_ci_on_dir "fstatat relative to CI mountpoint" \
"/tmp/ci" "$fstatat" "./ fstatat-AAAAA" "*Test Complete*"
run_ci_on_dir "CI fstatat relative to CS mountpoint" \
"/tmp/" "$fstatat" "ci/ fstatat-AaaaA" "*Test Complete*"
"$test_mnt" "$fstatat" "./ fstatat-AAAAA" "*Test Complete*"
run_ci_on_dir "CI fstatat relative on file with .." \
"/tmp/" "$fstatat" "ci/fstatat/../fstatat/ fstatat-AaAaa" \
"$test_mnt" "$fstatat" "fstatat/../fstatat/ fstatat-AaAaa" \
"*Test Complete*"
prepare_test "rm" "/tmp/ci/fstatat/fstatat-AAAAA"
prepare_test "rm" "/tmp/ci/fstatat-AAAAA"
prepare_test "rmdir" "/tmp/ci/fstatat"
prepare_test "rm" "$test_mnt/fstatat/fstatat-AAAAA"
prepare_test "rm" "$test_mnt/fstatat-AAAAA"
prepare_test "rmdir" "$test_mnt/fstatat"
}
chdir
lstat
......
......@@ -26,9 +26,9 @@ set test_file "stress.exp"
set basedir "$objdir/libcasefold.stress"
proc pathwalkci {} {
global basedir
global basedir test_mnt
set pathwalkci "$basedir/pathwalkci"
set pathwalkci_dir "/tmp/ci/pathwalkci"
set pathwalkci_dir "$test_mnt/pathwalkci"
prepare_test "mkdir" "$pathwalkci_dir"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment