Commit 49ba2cf8 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[master] Merge branch 'trac963'

parents 42364002 a7254a23
......@@ -1015,6 +1015,9 @@ AC_CONFIG_FILES([Makefile
src/bin/cfgmgr/plugins/Makefile
src/bin/cfgmgr/plugins/tests/Makefile
src/bin/cfgmgr/tests/Makefile
src/bin/dbutil/Makefile
src/bin/dbutil/tests/Makefile
src/bin/dbutil/tests/testdata/Makefile
src/bin/host/Makefile
src/bin/loadzone/Makefile
src/bin/loadzone/tests/correct/Makefile
......@@ -1028,8 +1031,8 @@ AC_CONFIG_FILES([Makefile
src/bin/ddns/tests/Makefile
src/bin/dhcp6/Makefile
src/bin/dhcp6/tests/Makefile
src/bin/dhcp4/Makefile
src/bin/dhcp4/tests/Makefile
src/bin/dhcp4/Makefile
src/bin/dhcp4/tests/Makefile
src/bin/resolver/Makefile
src/bin/resolver/tests/Makefile
src/bin/sockcreator/Makefile
......@@ -1143,6 +1146,9 @@ AC_OUTPUT([doc/version.ent
src/bin/cmdctl/run_b10-cmdctl.sh
src/bin/cmdctl/tests/cmdctl_test
src/bin/cmdctl/cmdctl.spec.pre
src/bin/dbutil/dbutil.py
src/bin/dbutil/run_dbutil.sh
src/bin/dbutil/tests/dbutil_test.sh
src/bin/ddns/ddns.py
src/bin/xfrin/tests/xfrin_test
src/bin/xfrin/xfrin.py
......@@ -1226,6 +1232,8 @@ AC_OUTPUT([doc/version.ent
chmod +x src/bin/zonemgr/run_b10-zonemgr.sh
chmod +x src/bin/bind10/run_bind10.sh
chmod +x src/bin/cmdctl/tests/cmdctl_test
chmod +x src/bin/dbutil/run_dbutil.sh
chmod +x src/bin/dbutil/tests/dbutil_test.sh
chmod +x src/bin/xfrin/tests/xfrin_test
chmod +x src/bin/xfrout/tests/xfrout_test
chmod +x src/bin/zonemgr/tests/zonemgr_test
......
SUBDIRS = bind10 bindctl cfgmgr ddns loadzone msgq host cmdctl auth xfrin \
xfrout usermgr zonemgr stats tests resolver sockcreator dhcp4 dhcp6
xfrout usermgr zonemgr stats tests resolver sockcreator dhcp4 dhcp6 dbutil
check-recursive: all-recursive
SUBDIRS = . tests
bin_SCRIPTS = b10-dbutil
man_MANS = b10-dbutil.8
nodist_pylogmessage_PYTHON = $(PYTHON_LOGMSGPKG_DIR)/work/dbutil_messages.py
pylogmessagedir = $(pyexecdir)/isc/log_messages/
EXTRA_DIST = $(man_MANS) b10-dbutil.xml dbutil_messages.mes
noinst_SCRIPTS = run_dbutil.sh
CLEANFILES = b10-dbutil b10-dbutil.pyc
CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/dbutil_messages.py
CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/dbutil_messages.pyc
if ENABLE_MAN
b10-dbutil.8: b10-dbutil.xml
xsltproc --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/b10-dbutil.xml
endif
# Define rule to build logging source files from message file
$(PYTHON_LOGMSGPKG_DIR)/work/dbutil_messages.py : dbutil_messages.mes
$(top_builddir)/src/lib/log/compiler/message \
-d $(PYTHON_LOGMSGPKG_DIR)/work -p $(srcdir)/dbutil_messages.mes
b10-dbutil: dbutil.py $(PYTHON_LOGMSGPKG_DIR)/work/dbutil_messages.py
$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" \
-e "s|@@SYSCONFDIR@@|@sysconfdir@|" \
-e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" dbutil.py >$@
chmod a+x $@
CLEANDIRS = __pycache__
clean-local:
rm -rf $(CLEANDIRS)
'\" t
.\" Title: b10-dbutil
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: March 20, 2012
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
.TH "B10\-DBUTIL" "8" "March 20, 2012" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
b10-dbutil \- Zone Database Maintenance Utility
.SH "SYNOPSIS"
.HP \w'\fBb10\-dbutil\ \-\-check\fR\ 'u
\fBb10\-dbutil \-\-check\fR [\-\-verbose] [\-\-quiet] [\fIdbfile\fR]
.HP \w'\fBb10\-dbutil\ \-\-upgrade\fR\ 'u
\fBb10\-dbutil \-\-upgrade\fR [\-\-noconfirm] [\-\-verbose] [\-\-quiet] [\fIdbfile\fR]
.SH "DESCRIPTION"
.PP
The
\fBb10\-dbutil\fR
utility is a general administration utility for SQL databases\&. (Currently only SQLite is supported by BIND 10\&.) It can report the current verion of the schema, and upgrade an existing database to the latest version of the schema\&.
.PP
\fBb10\-dbutil\fR
operates in one of two modes, check mode or upgrade mode\&.
.PP
In check mode (\fBb10\-dbutil \-\-check\fR), the utility reads the version of the database schema from the database and prints it\&. It will tell you whether the schema is at the latest version supported by BIND 10\&. Exit status is 0 if the schema is at the correct version, 1 if the schema is at an older version, 2 if the schema is at a version not yet supported by this version of b10\-dbutil\&. Any higher value indicates an error during command\-line parsing or execution\&.
.PP
When the upgrade function is selected (\fBb10\-dbutil \-\-upgrade\fR), the utility takes a copy of the database, then upgrades it to the latest version of the schema\&. The contents of the database remain intact\&. (The backup file is a file in the same directory as the database file\&. It has the same name, with "\&.backup" appended to it\&. If a file of that name already exists, the file will have the suffix "\&.backup\-1"\&. If that exists, the file will be suffixed "\&.backup\-2", and so on)\&. Exit status is 0 if the upgrade is either succesful or aborted by the user, and non\-zero if there is an error\&.
.PP
When upgrading the database, it is
\fIstrongly\fR
recommended that BIND 10 not be running while the upgrade is in progress\&.
.SH "ARGUMENTS"
.PP
The arguments are as follows:
.PP
\fB\-\-check\fR
.RS 4
Selects the version check function, which reports the current version of the database\&. This is incompatible with the \-\-upgrade option\&.
.RE
.PP
\fB\-\-noconfirm\fR
.RS 4
Only valid with \-\-upgrade, this disables the prompt\&. Normally the utility will print a warning that an upgrade is about to take place and request that you type "Yes" to continue\&. If this switch is given on the command line, no prompt will be issued: the utility will just perform the upgrade\&.
.RE
.PP
\fB\-\-upgrade\fR
.RS 4
Selects the upgrade function, which upgrades the database to the latest version of the schema\&. This is incompatible with the \-\-upgrade option\&.
.sp
The upgrade function will upgrade a BIND 10 database \- no matter how old the schema \- preserving all data\&. A backup file is created before the upgrade (with the same name as the database, but with "\&.backup" suffixed to it)\&. If the upgrade fails, this file can be copied back to restore the original database\&.
.RE
.PP
\fB\-\-verbose\fR
.RS 4
Enable verbose mode\&. Each SQL command issued by the utility will be printed to stderr before it is executed\&.
.RE
.PP
\fB\-\-quiet\fR
.RS 4
Enable quiet mode\&. No output is printed, except errors during command\-line argument parsing, or the user confirmation dialog\&.
.RE
.PP
\fB\fIdbfile\fR\fR
.RS 4
Name of the database file to check of upgrade\&.
.RE
.SH "COPYRIGHT"
.br
Copyright \(co 2012 Internet Systems Consortium, Inc. ("ISC")
.br
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]>
<!--
- Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
-->
<refentry>
<refentryinfo>
<date>March 20, 2012</date>
</refentryinfo>
<refmeta>
<refentrytitle>b10-dbutil</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo>BIND10</refmiscinfo>
</refmeta>
<refnamediv>
<refname>b10-dbutil</refname>
<refpurpose>Zone Database Maintenance Utility</refpurpose>
</refnamediv>
<docinfo>
<copyright>
<year>2012</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
<refsynopsisdiv>
<cmdsynopsis>
<command>b10-dbutil --check</command>
<arg>--verbose</arg>
<arg>--quiet</arg>
<arg><replaceable choice='req'>dbfile</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>b10-dbutil --upgrade</command>
<arg>--noconfirm</arg>
<arg>--verbose</arg>
<arg>--quiet</arg>
<arg><replaceable choice='req'>dbfile</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>
The <command>b10-dbutil</command> utility is a general administration
utility for SQL databases. (Currently only SQLite is supported by
BIND 10.) It can report the current verion of the schema, and upgrade
an existing database to the latest version of the schema.
</para>
<para>
<command>b10-dbutil</command> operates in one of two modes, check mode
or upgrade mode.
</para>
<para>
In check mode (<command>b10-dbutil --check</command>), the
utility reads the version of the database schema from the database
and prints it. It will tell you whether the schema is at the latest
version supported by BIND 10. Exit status is 0 if the schema is at
the correct version, 1 if the schema is at an older version, 2 if
the schema is at a version not yet supported by this version of
b10-dbutil. Any higher value indicates an error during command-line
parsing or execution.
</para>
<para>
When the upgrade function is selected
(<command>b10-dbutil --upgrade</command>), the
utility takes a copy of the database, then upgrades it to the latest
version of the schema. The contents of the database remain intact.
(The backup file is a file in the same directory as the database
file. It has the same name, with ".backup" appended to it. If a
file of that name already exists, the file will have the suffix
".backup-1". If that exists, the file will be suffixed ".backup-2",
and so on). Exit status is 0 if the upgrade is either succesful or
aborted by the user, and non-zero if there is an error.
</para>
<para>
When upgrading the database, it is <emphasis>strongly</emphasis>
recommended that BIND 10 not be running while the upgrade is in
progress.
</para>
</refsect1>
<refsect1>
<title>ARGUMENTS</title>
<para>The arguments are as follows:</para>
<variablelist>
<varlistentry>
<term>
<option>--check</option>
</term>
<listitem>
<para>Selects the version check function, which reports the
current version of the database. This is incompatible
with the --upgrade option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--noconfirm</option>
</term>
<listitem>
<para>Only valid with --upgrade, this disables the prompt.
Normally the utility will print a warning that an upgrade is
about to take place and request that you type "Yes" to continue.
If this switch is given on the command line, no prompt will
be issued: the utility will just perform the upgrade.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--upgrade</option>
</term>
<listitem>
<para>Selects the upgrade function, which upgrades the database
to the latest version of the schema. This is incompatible
with the --upgrade option.
</para>
<para>
The upgrade function will upgrade a BIND 10 database - no matter how
old the schema - preserving all data. A backup file is created
before the upgrade (with the same name as the database, but with
".backup" suffixed to it). If the upgrade fails, this file can
be copied back to restore the original database.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--verbose</option>
</term>
<listitem>
<para>Enable verbose mode. Each SQL command issued by the
utility will be printed to stderr before it is executed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--quiet</option>
</term>
<listitem>
<para>Enable quiet mode. No output is printed, except errors during
command-line argument parsing, or the user confirmation dialog.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option><replaceable choice='req'>dbfile</replaceable></option>
</term>
<listitem>
<para>
Name of the database file to check of upgrade.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
This diff is collapsed.
# Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# No namespace declaration - these constants go in the global namespace
# of the ddns messages python module.
# When you add a message to this file, it is a good idea to run
# <topsrcdir>/tools/reorder_message_file.py to make sure the
# messages are in the correct order.
% DBUTIL_BACKUP created backup of %1 in %2
A backup for the given database file was created. Same of original file and
backup are given in the output message.
% DBUTIL_CHECK_ERROR unable to check database version: %1
There was an error while trying to check the current version of the database
schema. The error is shown in the message.
% DBUTIL_CHECK_NOCONFIRM --noconfirm is not compatible with --check
b10-dbutil was called with --check and --noconfirm. --noconfirm only has
meaning with --upgrade, so this is considered an error.
% DBUTIL_CHECK_OK this is the latest version of the database schema. No upgrade is required
The database schema version has been checked, and is up to date.
No action is required.
% DBUTIL_CHECK_UPGRADE_NEEDED re-run this program with the --upgrade switch to upgrade
The database schema version is not up to date, and an update is required.
Please run the dbutil tool again, with the --upgrade argument.
% DBUTIL_COMMAND_NONE must select one of --check or --upgrade
b10-dbutil was called with neither --check nor --upgrade. One action must be
provided.
% DBUTIL_COMMAND_UPGRADE_CHECK --upgrade is not compatible with --check
b10-dbutil was called with both the commands --upgrade and --check. Only one
action can be performed at a time.
% DBUTIL_DATABASE_MAY_BE_CORRUPT database file %1 may be corrupt, restore it from backup (%2)
The upgrade failed while it was in progress; the database may now be in an
inconsistent state, and it is advised to restore it from the backup that was
created when b10-dbutil started.
% DBUTIL_EXECUTE Executing SQL statement: %1
Debug message; the given SQL statement is executed
% DBUTIL_FILE Database file: %1
The database file that is being checked.
% DBUTIL_NO_FILE must supply name of the database file to upgrade
b10-dbutil was called without a database file. Currently, it cannot find this
file on its own, and it must be provided.
% DBUTIL_STATEMENT_ERROR failed to execute %1: %2
The given database statement failed to execute. The error is shown in the
message.
% DBUTIL_TOO_MANY_ARGUMENTS too many arguments to the command, maximum of one expected
There were too many command-line arguments to b10-dbutil
% DBUTIL_UPGRADE_CANCELED upgrade canceled; database has not been changed
The user aborted the upgrade, and b10-dbutil will now exit.
% DBUTIL_UPGRADE_DBUTIL please get the latest version of b10-dbutil and re-run
A database schema was found that was newer than this version of dbutil, which
is apparently out of date and should be upgraded itself.
% DBUTIL_UPGRADE_FAILED upgrade failed: %1
While the upgrade was in progress, an unexpected error occurred. The error
is shown in the message.
% DBUTIL_UPGRADE_NOT_ATTEMPTED database upgrade was not attempted
Due to the earlier failure, the database schema upgrade was not attempted,
and b10-dbutil will now exit.
% DBUTIL_UPGRADE_NOT_NEEDED database already at latest version, no upgrade necessary
b10-dbutil was told to upgrade the database schema, but it is already at the
latest version.
% DBUTIL_UPGRADE_NOT_POSSIBLE database at a later version than this utility can support
b10-dbutil was told to upgrade the database schema, but it is at a higher
version than this tool currently supports. Please update b10-dbutil and try
again.
% DBUTIL_UPGRADE_PREPARATION_FAILED upgrade preparation failed: %1
An unexpected error occurred while b10-dbutil was preparing to upgrade the
database schema. The error is shown in the message
% DBUTIL_UPGRADE_SUCCESFUL database upgrade successfully completed
The database schema update was completed successfully.
% DBUTIL_UPGRADING upgrading database from %1 to %2
An upgrade is in progress, the versions of the current upgrade action are shown.
% DBUTIL_VERSION_CURRENT database version %1
The current version of the database schema.
% DBUTIL_VERSION_HIGH database is at a later version (%1) than this program can cope with (%2)
The database schema is at a higher version than b10-dbutil knows about.
% DBUTIL_VERSION_LOW database version %1, latest version is %2.
The database schema is not up to date, the current version and the latest
version are in the message.
#! /bin/sh
# Copyright (C) 2010 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
PYTHON_EXEC=${PYTHON_EXEC:-@PYTHON@}
export PYTHON_EXEC
DBUTIL_PATH=@abs_top_builddir@/src/bin/dbutil
PYTHONPATH=@abs_top_srcdir@/src/bin:@abs_top_builddir@/src/lib/python/isc/log_messages:@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/bin:@abs_top_srcdir@/src/lib/python
export PYTHONPATH
# If necessary (rare cases), explicitly specify paths to dynamic libraries
# required by loadable python modules.
SET_ENV_LIBRARY_PATH=@SET_ENV_LIBRARY_PATH@
if test $SET_ENV_LIBRARY_PATH = yes; then
@ENV_LIBRARY_PATH@=@abs_top_builddir@/src/lib/dns/.libs:@abs_top_builddir@/src/lib/dns/python/.libs:@abs_top_builddir@/src/lib/cryptolink/.libs:@abs_top_builddir@/src/lib/cc/.libs:@abs_top_builddir@/src/lib/config/.libs:@abs_top_builddir@/src/lib/log/.libs:@abs_top_builddir@/src/lib/util/.libs:@abs_top_builddir@/src/lib/util/io/.libs:@abs_top_builddir@/src/lib/exceptions/.libs:@abs_top_builddir@/src/lib/datasrc/.libs:$@ENV_LIBRARY_PATH@
export @ENV_LIBRARY_PATH@
fi
B10_FROM_SOURCE=@abs_top_srcdir@
export B10_FROM_SOURCE
BIND10_MSGQ_SOCKET_FILE=@abs_top_builddir@/msgq_socket
export BIND10_MSGQ_SOCKET_FILE
exec ${PYTHON_EXEC} -O ${DBUTIL_PATH}/b10-dbutil "$@"
SUBDIRS = . testdata
# Tests of the update script.
check-local:
$(SHELL) $(abs_builddir)/dbutil_test.sh
#!/bin/sh
# Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# Checks that the logger will limit the output of messages less severe than
# the severity/debug setting.
testname="Database Upgrade Test"
echo $testname
failcount=0
tempfile=@abs_builddir@/dbutil_test_tempfile_$$
backupfile=${tempfile}.backup
testdata=@abs_srcdir@/testdata
verfile=@abs_builddir@/dbutil_test_verfile_$$
# @brief Record a success
succeed() {
echo "--- PASS"
}
# @brief Record a fail
#
# @param $1 Optional additional reason to output
fail() {
if [ "$1" != "" ]
then
echo "ERROR: $1"
fi
echo "*** FAIL"
failcount=`expr $failcount + 1`
}
# @brief Record a pass if the argument is zero
#
# @param $1 Value to test
passzero() {
if [ $1 -eq 0 ]; then
succeed
else
fail
fi
}
# @brief Record a fail if the argument is non-zero
#
# @param $1 Value to test
failzero() {
if [ $1 -ne 0 ]; then
succeed
else
fail
fi
}
# @brief Copy File
#
# Executes a "cp" operation followed by a "chmod" to make the target writeable.
#
# @param $1 Source file
# @param $2 Target file
copy_file () {
cp $1 $2
chmod a+w $2
}
# @brief Check backup file
#
# Record a failure if the backup file does not exist or if it is different
# to the data file. (N.B. No success is recorded if they are the same.)
#
# @param $1 Source database file
# @param $2 Backup file
check_backup() {
if [ ! -e $1 ]
then
fail "database file $1 not found"
elif [ ! -e $2 ]
then