File: test1

package info (click to toggle)
switchconf 0.0.17-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: sh: 437; makefile: 128
file content (134 lines) | stat: -rwxr-xr-x 2,692 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash -x
set -e
function gen-conf () {
CONFDIR="$1"
DESTDIR="$2"
METHOD="$3"

    cat >"/etc/switchconf/conf" <<EOF
conf_top_dirs="$CONFDIR"
dest_dir="$DESTDIR"
config_method="$METHOD"
EOF
}

CONFDIR=`mktemp -d /tmp/switchconf-confdir-XXXXXX`
DESTDIR=`mktemp -d /tmp/switchconf-destdir-XXXXXX`
TMPFILE=`mktemp`
rm $TMPFILE && mv /etc/switchconf/conf $TMPFILE || true


# Setup configurations
mkdir -p "$CONFDIR/test1a"
mkdir -p "$CONFDIR/test1b"
echo test1a > "$CONFDIR/test1a/test1" 
echo test1b > "$CONFDIR/test1b/test1"

# Test switch by cp
gen-conf "$CONFDIR" "$DESTDIR" copy
if test -e "$DESTDIR/test1" ; then
    echo "Failed to setup test1"
    exit 1
fi
./switchconf test1a
if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to create file"
    exit 1
fi

if ! grep test1a "$DESTDIR/test1" ; then
    echo "Failed to put the right file in place"
    exit 1
fi

if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to setup test1"
    exit 1
fi
./switchconf test1a
if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to create file"
    exit 1
fi

if ! grep test1a "$DESTDIR/test1" ; then
    echo "Failed to put the right file in place"
    exit 1
fi

# Test switch by softlink
gen-conf "$CONFDIR" "$DESTDIR" softlink
rm -f "$DESTDIR/test1"
if test -e "$DESTDIR/test1" ; then
    echo "Failed to setup test1"
    exit 1
fi
./switchconf test1a
if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to create file"
    exit 1
fi

if ! test -L "$DESTDIR/test1" ; then
    echo "Failed to create link"
    exit 1
fi

if ! grep test1a "$DESTDIR/test1" ; then
    echo "Failed to put the right file in place"
    exit 1
fi

if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to setup test1"
    exit 1
fi
./switchconf test1a
if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to create file"
    exit 1
fi

if ! test -L "$DESTDIR/test1" ; then
    echo "Failed to create link"
    exit 1
fi

if ! grep test1a "$DESTDIR/test1" ; then
    echo "Failed to put the right file in place"
    exit 1
fi

# Test switch by hardlink
gen-conf "$CONFDIR" "$DESTDIR" hardlink
rm -f "$DESTDIR/test1"
if test -e "$DESTDIR/test1" ; then
    echo "Failed to setup test1"
    exit 1
fi
./switchconf test1a
if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to create file"
    exit 1
fi

if ! grep test1a "$DESTDIR/test1" ; then
    echo "Failed to put the right file in place"
    exit 1
fi

if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to setup test1"
    exit 1
fi
./switchconf test1b
if ! test -e "$DESTDIR/test1" ; then
    echo "Failed to create file"
    exit 1
fi

if ! grep test1b "$DESTDIR/test1" ; then
    echo "Failed to put the right file in place"
    exit 1
fi