/[volute]/trunk/projects/vocabularies/check-uris.sh.in
ViewVC logotype

Contents of /trunk/projects/vocabularies/check-uris.sh.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 424 - (show annotations)
Thu May 8 19:17:33 2008 UTC (12 years, 6 months ago) by norman.x.gray
File size: 2125 byte(s)
Add post-installation self-test

1 #! /bin/sh -
2
3 BASEURI=@BASEURI@
4 DISTNAME=@DISTNAME@
5
6 check_uri () {
7 uri=$1
8 header=$2
9 if test -n "$3"; then accept="-H $3"; else accept=""; fi
10 if test -z "$header"; then
11 curl --head $accept $uri 2>/dev/null | sed -n "1s/HTTP[^ ]* *\([0-9]*\).*/status=\1/p"
12 else
13 curl --head $accept $uri 2>/dev/null | sed -n "1s/HTTP[^ ]* *\([0-9]*\).*/status=\1/p
14 s/^$header: *\([^[:space:]]*\).*/$header=\1/p"
15 fi
16 }
17
18 check_status () {
19 # $1 = URL to check
20 # $2 = expected status
21 eval `check_uri $1`
22 if test "$status" = $2; then
23 echo "OK: $1"
24 else
25 echo "Failed: $1 produced status=$status"
26 echo " expected status=$2"
27 allok=false
28 fi
29 }
30
31 check_status_and_location () {
32 # $1 = URL to check
33 # $2 = expected status
34 # $3 = expected location
35 # $4 = extra header for curl
36 eval `check_uri $1 Location $4`
37 if test "$status" = $2 -a "$Location" = $3; then
38 echo "OK: $1 [$4]"
39 else
40 echo "Failed: $1 produced status=$status, Location=$Location"
41 echo " expected status=$2, Location=$3"
42 allok=false
43 fi
44 }
45
46
47 allok=:
48
49 # Check redirections
50
51 check_status_and_location $BASEURI/AAkeys \
52 303 \
53 $BASEURI/$DISTNAME/AAkeys/AAkeys.html
54 check_status_and_location $BASEURI/AAkeys \
55 303 \
56 $BASEURI/$DISTNAME/AAkeys/AAkeys.html \
57 accept:text/html
58 check_status $BASEURI/$DISTNAME/AAkeys/AAkeys.html 200
59
60 check_status_and_location $BASEURI/AAkeys \
61 303 \
62 $BASEURI/$DISTNAME/AAkeys/AAkeys.ttl \
63 accept:text/rdf+n3
64 check_status_and_location $BASEURI/AAkeys \
65 303 \
66 $BASEURI/$DISTNAME/AAkeys/AAkeys.ttl \
67 accept:text/turtle
68 check_status $BASEURI/$DISTNAME/AAkeys/AAkeys.ttl 200
69
70
71 check_status_and_location $BASEURI/AAkeys \
72 303 \
73 $BASEURI/$DISTNAME/AAkeys/AAkeys.rdf \
74 accept:application/rdf+xml
75 check_status $BASEURI/$DISTNAME/AAkeys/AAkeys.rdf 200
76
77 # check location of tarball
78
79 check_status $BASEURI/$DISTNAME.tar.gz 200
80
81 # How'd we get on?
82
83 if $allok; then
84 echo "All tests passed!"
85 exit 0
86 else
87 echo "Some tests failed. Boo!"
88 exit 1
89 fi

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26