0.pre7.107:
[sbcl.git] / tests / filesys.test.sh
1 #!/bin/sh
2
3 # This software is part of the SBCL system. See the README file for
4 # more information.
5 #
6 # While most of SBCL is derived from the CMU CL system, the test
7 # files (like this one) were written from scratch after the fork
8 # from CMU CL.
9
10 # This software is in the public domain and is provided with
11 # absolutely no warranty. See the COPYING and CREDITS files for
12 # more information.
13
14 # Test DIRECTORY and TRUENAME.
15 testdir=`pwd`"/filesys-test-$$"
16 mkdir $testdir
17 echo this is a test > $testdir/test-1.tmp
18 echo this is a test > $testdir/test-2.tmp
19 cd $testdir
20 ln -s test-1.tmp link-1
21 ln -s `pwd`/test-2.tmp link-2
22 ln -s i-do-not-exist link-3
23 ln -s link-4 link-4
24 ln -s link-5 link-6
25 ln -s `pwd`/link-6 link-5
26 expected_truenames=\
27 "'(#p\"$testdir/link-3\"\
28    #p\"$testdir/link-4\"\
29    #p\"$testdir/link-5\"\
30    #p\"$testdir/link-6\"\
31    #p\"$testdir/test-1.tmp\"\
32    #p\"$testdir/test-2.tmp\")"
33 $SBCL <<EOF
34   (in-package :cl-user)
35   (let* ((directory (directory "./*.*"))
36          (truenames (sort directory #'string< :key #'pathname-name)))
37     (format t "~&TRUENAMES=~S~%" truenames)
38     (finish-output)
39     (assert (equal truenames $expected_truenames)))
40   (assert (equal (truename "test-1.tmp") #p"$testdir/test-1.tmp"))
41   (assert (equal (truename "link-1")     #p"$testdir/test-1.tmp"))
42   (assert (equal (truename "link-2")     #p"$testdir/test-2.tmp"))
43   (assert (equal (truename "link-3")     #p"$testdir/link-3"))
44   (assert (equal (truename "link-4")     #p"$testdir/link-4"))
45   (assert (equal (truename "link-5")     #p"$testdir/link-5"))
46   (assert (equal (truename "link-6")     #p"$testdir/link-6"))
47   (sb-ext:quit :unix-status 52)
48 EOF
49 if [ $? != 52 ]; then
50     echo DIRECTORY/TRUENAME test part 1 failed, unexpected SBCL return code=$?
51     exit 1
52 fi
53 cd ..
54 $SBCL <<EOF
55   (in-package :cl-user)
56   (let* ((directory (directory "$testdir/*.*"))
57          (truenames (sort directory #'string< :key #'pathname-name)))
58     (format t "~&TRUENAMES=~S~%" truenames)
59     (finish-output)
60     (assert (equal truenames $expected_truenames)))
61   (assert (equal (truename "$testdir/test-1.tmp") #p"$testdir/test-1.tmp"))
62   (assert (equal (truename "$testdir/link-1")     #p"$testdir/test-1.tmp"))
63   (assert (equal (truename "$testdir/link-2")     #p"$testdir/test-2.tmp"))
64   (assert (equal (truename "$testdir/link-3")     #p"$testdir/link-3"))
65   (assert (equal (truename "$testdir/link-4")     #p"$testdir/link-4"))
66   (assert (equal (truename "$testdir/link-5")     #p"$testdir/link-5"))
67   (assert (equal (truename "$testdir/link-6")     #p"$testdir/link-6"))
68   (sb-ext:quit :unix-status 52)
69 EOF
70 if [ $? != 52 ]; then
71     echo DIRECTORY/TRUENAME test part 2 failed, unexpected SBCL return code=$?
72     exit 1
73 fi
74 rm -r $testdir
75
76 # success convention for script
77 exit 104