source: LMDZ6/branches/Amaury_dev/tools/fcm/t/fcm-recover-svn-repos/00-basic.t @ 5095

Last change on this file since 5095 was 5095, checked in by abarral, 4 months ago

Revert cosp*/ from the trunk, as it's external code
Add missing bits from FCM2 source

  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/bash
2#-------------------------------------------------------------------------------
3# Copyright (C) 2006-2021 British Crown (Met Office) & Contributors.
4#
5# This file is part of FCM, tools for managing and building source code.
6#
7# FCM is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# FCM is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with FCM. If not, see <http://www.gnu.org/licenses/>.
19#-------------------------------------------------------------------------------
20# Basic tests for "fcm-recover-svn-repos".
21#-------------------------------------------------------------------------------
22. $(dirname $0)/test_header
23#-------------------------------------------------------------------------------
24if ! which svnadmin 1>/dev/null 2>/dev/null; then
25    skip_all 'svnadmin not available'
26fi
27tests 26
28#-------------------------------------------------------------------------------
29set -e
30mkdir -p etc srv/svn var/svn/{backups,cache,dumps}
31# Configuration
32export FCM_CONF_PATH="$PWD/etc"
33cat >etc/admin.cfg <<__CONF__
34svn_backup_dir=$PWD/var/svn/backups
35svn_dump_dir=$PWD/var/svn/dumps
36svn_group=
37svn_live_dir=$PWD/srv/svn
38__CONF__
39# Create some repositories and populate them
40# Repository 1
41svnadmin create srv/svn/bar
42svn co -q file://$PWD/srv/svn/bar
43echo 'Barley drink.' >bar/barley
44svn add -q bar/*
45svn ci -q -m'test 1' bar
46svnadmin hotcopy srv/svn/bar var/svn/backups/bar
47tar -C var/svn/backups -czf $PWD/var/svn/backups/bar.tgz bar
48svnadmin dump srv/svn/bar -r 1 --incremental --deltas -q \
49        | gzip >var/svn/dumps/bar-1.gz
50# Repository 2
51svnadmin create srv/svn/foo
52svn co -q file://$PWD/srv/svn/foo
53echo 'Number of football players = 0' >foo/football
54echo 'Food is yummy.' >foo/food
55svn add -q foo/*
56svn ci -q -m'test 1' foo
57svnadmin hotcopy srv/svn/foo var/svn/backups/foo
58tar -C var/svn/backups -czf $PWD/var/svn/backups/foo.tgz foo
59rm -fr var/svn/backups/foo
60echo 'Fool is a clown.' >foo/fool
61svn add -q foo/fool
62svn ci -q -m'test 2' foo
63for I in {1..11}; do
64    echo "Number of football players = $I" >foo/football
65    svn ci -q -m"incr football player" foo
66done
67for I in {1..13}; do
68    svnadmin dump srv/svn/foo -r $I --incremental --deltas -q \
69        | gzip >var/svn/dumps/foo-$I.gz
70done
71rm -fr bar foo
72set +e
73#-------------------------------------------------------------------------------
74TEST_KEY="$TEST_KEY_BASE-live-exists"
75run_fail "$TEST_KEY" "$FCM_HOME/sbin/fcm-recover-svn-repos"
76file_cmp "$TEST_KEY.out" "$TEST_KEY.out" </dev/null
77file_cmp "$TEST_KEY.err" "$TEST_KEY.err" <<__ERR__
78$PWD/srv/svn/bar: live repository exists.
79__ERR__
80#-------------------------------------------------------------------------------
81TEST_KEY="$TEST_KEY_BASE"
82mv srv/svn/{bar,foo} var/svn/cache
83run_pass "$TEST_KEY" "$FCM_HOME/sbin/fcm-recover-svn-repos"
84# Check revisions
85for NAME in bar foo; do
86    svnlook youngest var/svn/cache/$NAME >"$TEST_KEY-youngest-$NAME.exp"
87    svnlook youngest srv/svn/$NAME >"$TEST_KEY-youngest-$NAME"
88    file_cmp "$TEST_KEY-youngest-$NAME" \
89        "$TEST_KEY-youngest-$NAME" "$TEST_KEY-youngest-$NAME.exp"
90    for I in $(seq 1 $(<"$TEST_KEY-youngest-$NAME.exp")); do
91        svnlook changed -r $I var/svn/cache/$NAME \
92            >"$TEST_KEY-changed-$NAME-$I.exp"
93        svnlook changed -r $I srv/svn/$NAME >"$TEST_KEY-changed-$NAME-$I"
94        file_cmp "$TEST_KEY-changed-$NAME-$I" \
95            "$TEST_KEY-changed-$NAME-$I" "$TEST_KEY-changed-$NAME-$I.exp"
96    done
97    svn export -q file://$PWD/var/svn/cache/$NAME $NAME.orig
98    svn export -q file://$PWD/srv/svn/$NAME $NAME
99    FILES_ORIG=$(cd $NAME.orig; find -type f)
100    FILES=$(cd $NAME; find -type f)
101    run_pass "$TEST_KEY-$NAME-n-files" \
102        test $(wc -l <<<"$FILES_ORIG") -eq $(wc -l <<<"$FILES")
103    for FILE in $FILES_ORIG; do
104        file_cmp "$TEST_KEY-cmp-$NAME-$FILE" "$NAME.orig/$FILE" "$NAME/$FILE"
105    done
106done
107#-------------------------------------------------------------------------------
108exit
Note: See TracBrowser for help on using the repository browser.