summaryrefslogtreecommitdiffabout
path: root/tests
Unidiff
Diffstat (limited to 'tests') (more/less context) (show whitespace changes)
-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
9wstest 9wstest
10wsbatch 10wsbatch
11pushck 11pushck
12bkupname
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
24## ------------ ## 24## ------------ ##
25 25
26$(srcdir)/package.m4: $(top_srcdir)/configure.ac 26$(srcdir)/package.m4: $(top_srcdir)/configure.ac
27 { \ 27 $(AM_V_GEN){ \
28 echo '# Signature of the current package.'; \ 28 echo '# Signature of the current package.'; \
29 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ 29 echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
30 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ 30 echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
@@ -40,6 +40,10 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
40## ------------ ## 40## ------------ ##
41 41
42TESTSUITE_AT = \ 42TESTSUITE_AT = \
43 backup00.at\
44 backup01.at\
45 backup02.at\
46 backup03.at\
43 check-fail.at\ 47 check-fail.at\
44 check-notify.at\ 48 check-notify.at\
45 check-ok.at\ 49 check-ok.at\
@@ -73,9 +77,11 @@ check-local: atconfig atlocal $(TESTSUITE)
73#installcheck-local: 77#installcheck-local:
74 #$(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin 78 #$(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
75 79
76check_PROGRAMS = wstest wsbatch pushck 80check_PROGRAMS = wstest wsbatch pushck bkupname
77INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/gnu -I../gnu -I$(top_srcdir)/src 81INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/src
78LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a 82LDADD=../grecs/src/libgrecs.a
79 83
80pushck_LDADD=../src/pushd.o 84pushck_LDADD=../src/pushd.o
85bkupname_LDADD=../src/backup.o ../grecs/src/libgrecs.a
86
81 87
diff --git a/tests/backup01.at b/tests/backup01.at
new file mode 100644
index 0000000..7cf4f93
--- a/dev/null
+++ b/tests/backup01.at
@@ -0,0 +1,33 @@
1# This file is part of wydawca testsuite -*- Autotest -*-
2# Copyright (C) 2009, 2010 Sergey Poznyakoff
3#
4# Wydawca is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Wydawca is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP(simple backups)
18AT_KEYWORDS([backup backup01 simple_backups])
19
20AT_CHECK([bkupname -simple a],
21[0],
22[a~
23])
24
25AT_CHECK([
26touch a
27bkupname -simple a
28],
29[0],
30[a~
31])
32
33AT_CLEANUP
diff --git a/tests/backup02.at b/tests/backup02.at
new file mode 100644
index 0000000..b5bcc54
--- a/dev/null
+++ b/tests/backup02.at
@@ -0,0 +1,43 @@
1# This file is part of wydawca testsuite -*- Autotest -*-
2# Copyright (C) 2009, 2010 Sergey Poznyakoff
3#
4# Wydawca is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Wydawca is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP(numbered backups)
18AT_KEYWORDS([backup backup02 numbered_backups])
19
20AT_CHECK([bkupname -numbered a],
21[0],
22[a.~1~
23])
24
25AT_CHECK([
26touch a.~1~
27bkupname -numbered a
28],
29[0],
30[a.~2~
31])
32
33AT_CHECK([
34touch a.~99~
35bkupname -numbered a
36],
37[0],
38[a.~100~
39])
40
41
42
43AT_CLEANUP
diff --git a/tests/backup03.at b/tests/backup03.at
new file mode 100644
index 0000000..947c145
--- a/dev/null
+++ b/tests/backup03.at
@@ -0,0 +1,41 @@
1# This file is part of wydawca testsuite -*- Autotest -*-
2# Copyright (C) 2009, 2010 Sergey Poznyakoff
3#
4# Wydawca is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Wydawca is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP(numbered existing backups)
18AT_KEYWORDS([backup backup03 numbered_existing_backups])
19
20AT_CHECK([bkupname -existing a],
21[0],
22[a~
23])
24
25AT_CHECK([
26touch a.~1~
27bkupname -existing a
28],
29[0],
30[a.~2~
31])
32
33AT_CHECK([
34touch a.~99~
35bkupname -existing a
36],
37[0],
38[a.~100~
39])
40
41AT_CLEANUP
diff --git a/tests/bkupname.c b/tests/bkupname.c
new file mode 100644
index 0000000..6187146
--- a/dev/null
+++ b/tests/bkupname.c
@@ -0,0 +1,79 @@
1/* wordsplit - a word splitter
2 Copyright (C) 2009, 2010 Sergey Poznyakoff
3
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 3 of the License, or (at your
7 option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#include <config.h>
18#include "wydawca.h"
19
20char *progname;
21
22void
23usage (int code)
24{
25 FILE *fp = code ? stderr : stdout;
26
27 fprintf (fp, "usage: %s [-no] [-simple] [-existing] [-numbered] [-suffix=S] FILE\n",
28 progname);
29 exit (code);
30}
31
32int
33main (int argc, char **argv)
34{
35 enum backup_type type = numbered_backups;
36 char *file = NULL;
37 char *backup;
38
39 progname = argv[0];
40 while (--argc)
41 {
42 char *arg = *++argv;
43 if (strcmp (arg, "-no") == 0)
44 type = no_backups;
45 else if (strcmp (arg, "-simple") == 0)
46 type = simple_backups;
47 else if (strcmp (arg, "-existing") == 0)
48 type = numbered_existing_backups;
49 else if (strcmp (arg, "-numbered") == 0)
50 type = numbered_backups;
51 else if (strncmp (arg, "-suffix=", 8) == 0)
52 simple_backup_suffix = arg + 8;
53 else if (arg[0] == '-')
54 usage (2);
55 else
56 {
57 if (argc != 1)
58 usage (2);
59 file = arg;
60 }
61 }
62
63 if (!file)
64 usage (2);
65 backup = find_backup_file_name (file, type);
66 if (!backup)
67 {
68 if (errno)
69 {
70 perror (file);
71 exit (1);
72 }
73 printf ("no backup\n");
74 }
75 else
76 printf ("%s\n", backup);
77 free (backup);
78 exit (0);
79}
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])
24m4_include([version.at]) 24m4_include([version.at])
25m4_include([wordsplit.at]) 25m4_include([wordsplit.at])
26m4_include([pushdir.at]) 26m4_include([pushdir.at])
27m4_include([backup00.at])
28m4_include([backup01.at])
29m4_include([backup02.at])
30m4_include([backup03.at])
27 31
28m4_include([upload-dry.at]) 32m4_include([upload-dry.at])
29m4_include([upload.at]) 33m4_include([upload.at])

Return to:

Send suggestions and report system problems to the System administrator.