aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/backup01.at33
-rw-r--r--tests/backup02.at43
-rw-r--r--tests/backup03.at41
-rw-r--r--tests/bkupname.c79
-rw-r--r--tests/testsuite.at4
7 files changed, 211 insertions, 4 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 7c8bd6b..1df6b71 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -9,3 +9,4 @@ dest
wstest
wsbatch
pushck
+bkupname
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b174fcd..cc52dbf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,7 +24,7 @@ SUBDIRS = etc
## ------------ ##
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
- { \
+ $(AM_V_GEN){ \
echo '# Signature of the current package.'; \
echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
@@ -40,6 +40,10 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
## ------------ ##
TESTSUITE_AT = \
+ backup00.at\
+ backup01.at\
+ backup02.at\
+ backup03.at\
check-fail.at\
check-notify.at\
check-ok.at\
@@ -73,9 +77,11 @@ check-local: atconfig atlocal $(TESTSUITE)
#installcheck-local:
# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
-check_PROGRAMS = wstest wsbatch pushck
-INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/gnu -I../gnu -I$(top_srcdir)/src
-LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a
+check_PROGRAMS = wstest wsbatch pushck bkupname
+INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/src
+LDADD=../grecs/src/libgrecs.a
pushck_LDADD=../src/pushd.o
+bkupname_LDADD=../src/backup.o ../grecs/src/libgrecs.a
+
diff --git a/tests/backup01.at b/tests/backup01.at
new file mode 100644
index 0000000..7cf4f93
--- /dev/null
+++ b/tests/backup01.at
@@ -0,0 +1,33 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# Copyright (C) 2009, 2010 Sergey Poznyakoff
+#
+# Wydawca is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Wydawca is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP(simple backups)
+AT_KEYWORDS([backup backup01 simple_backups])
+
+AT_CHECK([bkupname -simple a],
+[0],
+[a~
+])
+
+AT_CHECK([
+touch a
+bkupname -simple a
+],
+[0],
+[a~
+])
+
+AT_CLEANUP
diff --git a/tests/backup02.at b/tests/backup02.at
new file mode 100644
index 0000000..b5bcc54
--- /dev/null
+++ b/tests/backup02.at
@@ -0,0 +1,43 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# Copyright (C) 2009, 2010 Sergey Poznyakoff
+#
+# Wydawca is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Wydawca is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP(numbered backups)
+AT_KEYWORDS([backup backup02 numbered_backups])
+
+AT_CHECK([bkupname -numbered a],
+[0],
+[a.~1~
+])
+
+AT_CHECK([
+touch a.~1~
+bkupname -numbered a
+],
+[0],
+[a.~2~
+])
+
+AT_CHECK([
+touch a.~99~
+bkupname -numbered a
+],
+[0],
+[a.~100~
+])
+
+
+
+AT_CLEANUP
diff --git a/tests/backup03.at b/tests/backup03.at
new file mode 100644
index 0000000..947c145
--- /dev/null
+++ b/tests/backup03.at
@@ -0,0 +1,41 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# Copyright (C) 2009, 2010 Sergey Poznyakoff
+#
+# Wydawca is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Wydawca is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP(numbered existing backups)
+AT_KEYWORDS([backup backup03 numbered_existing_backups])
+
+AT_CHECK([bkupname -existing a],
+[0],
+[a~
+])
+
+AT_CHECK([
+touch a.~1~
+bkupname -existing a
+],
+[0],
+[a.~2~
+])
+
+AT_CHECK([
+touch a.~99~
+bkupname -existing a
+],
+[0],
+[a.~100~
+])
+
+AT_CLEANUP
diff --git a/tests/bkupname.c b/tests/bkupname.c
new file mode 100644
index 0000000..6187146
--- /dev/null
+++ b/tests/bkupname.c
@@ -0,0 +1,79 @@
+/* wordsplit - a word splitter
+ Copyright (C) 2009, 2010 Sergey Poznyakoff
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include "wydawca.h"
+
+char *progname;
+
+void
+usage (int code)
+{
+ FILE *fp = code ? stderr : stdout;
+
+ fprintf (fp, "usage: %s [-no] [-simple] [-existing] [-numbered] [-suffix=S] FILE\n",
+ progname);
+ exit (code);
+}
+
+int
+main (int argc, char **argv)
+{
+ enum backup_type type = numbered_backups;
+ char *file = NULL;
+ char *backup;
+
+ progname = argv[0];
+ while (--argc)
+ {
+ char *arg = *++argv;
+ if (strcmp (arg, "-no") == 0)
+ type = no_backups;
+ else if (strcmp (arg, "-simple") == 0)
+ type = simple_backups;
+ else if (strcmp (arg, "-existing") == 0)
+ type = numbered_existing_backups;
+ else if (strcmp (arg, "-numbered") == 0)
+ type = numbered_backups;
+ else if (strncmp (arg, "-suffix=", 8) == 0)
+ simple_backup_suffix = arg + 8;
+ else if (arg[0] == '-')
+ usage (2);
+ else
+ {
+ if (argc != 1)
+ usage (2);
+ file = arg;
+ }
+ }
+
+ if (!file)
+ usage (2);
+ backup = find_backup_file_name (file, type);
+ if (!backup)
+ {
+ if (errno)
+ {
+ perror (file);
+ exit (1);
+ }
+ printf ("no backup\n");
+ }
+ else
+ printf ("%s\n", backup);
+ free (backup);
+ exit (0);
+}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 240ab5d..2318762 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -24,6 +24,10 @@ AT_TESTED([wydawca])
m4_include([version.at])
m4_include([wordsplit.at])
m4_include([pushdir.at])
+m4_include([backup00.at])
+m4_include([backup01.at])
+m4_include([backup02.at])
+m4_include([backup03.at])
m4_include([upload-dry.at])
m4_include([upload.at])

Return to:

Send suggestions and report system problems to the System administrator.