summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2019-01-12 09:41:44 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2019-01-12 10:24:47 +0200
commitaa0684ce9018a796549ce8a9245cc14307962eae (patch)
tree71469eb384fd293b3593dbf5950b5f4169d5db85
parent85c005ee1345c342f707f3c55317daf6cb050603 (diff)
downloadtar-aa0684ce9018a796549ce8a9245cc14307962eae.tar.gz
Fix the use of --checkpoint without explicit --checkpoint-action
* src/checkpoint.c (checkpoint_finish_compile): Set default action, if necessary. * tests/checkpoint/defaults.at: New testcase. * tests/checkpoint/dot-compat.at: New testcase. * tests/checkpoint/dot-int.at: New testcase. * tests/checkpoint/dot.at: New testcase. * tests/checkpoint/interval.at: New testcase. * tests/Makefile.am: Add new testcases. * tests/testsuite.at Include new testcases.
-rw-r--r--.gitignore2
-rw-r--r--src/checkpoint.c18
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/checkpoint/defaults.at25
-rw-r--r--tests/checkpoint/dot-compat.at23
-rw-r--r--tests/checkpoint/dot-int.at24
-rw-r--r--tests/checkpoint/dot.at24
-rw-r--r--tests/checkpoint/interval.at29
-rw-r--r--tests/testsuite.at19
9 files changed, 161 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 58c637cb..8d0880ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
.deps
.emacs*
.libs
+.gdbinit
ABOUT-NLS
ChangeLog
INSTALL
@@ -28,3 +29,4 @@ libtool
m4
rmt
stamp-h1
+TAGS
diff --git a/src/checkpoint.c b/src/checkpoint.c
index 89a88864..18fc9203 100644
--- a/src/checkpoint.c
+++ b/src/checkpoint.c
@@ -149,18 +149,20 @@ checkpoint_compile_action (const char *str)
void
checkpoint_finish_compile (void)
{
+ if (checkpoint_state == CHKP_INIT
+ && checkpoint_option
+ && !checkpoint_action)
+ {
+ /* Provide a historical default */
+ checkpoint_compile_action ("echo");
+ }
+
if (checkpoint_state == CHKP_COMPILE)
{
sigprocmask (SIG_BLOCK, &sigs, NULL);
- if (checkpoint_option)
- {
- if (!checkpoint_action)
- /* Provide a historical default */
- checkpoint_compile_action ("echo");
- }
- else if (checkpoint_action)
- /* Otherwise, set default checkpoint rate */
+ if (!checkpoint_option)
+ /* set default checkpoint rate */
checkpoint_option = DEFAULT_CHECKPOINT;
checkpoint_state = CHKP_RUN;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4750acb7..25ac1bf0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,11 @@ TESTSUITE_AT = \
compress-gzip.at\
compress-lzip.at\
compress-lzop.at\
+ checkpoint/defaults.at\
+ checkpoint/interval.at\
+ checkpoint/dot.at\
+ checkpoint/dot-compat.at\
+ checkpoint/dot-int.at\
delete01.at\
delete02.at\
delete03.at\
diff --git a/tests/checkpoint/defaults.at b/tests/checkpoint/defaults.at
new file mode 100644
index 00000000..d89d1e15
--- /dev/null
+++ b/tests/checkpoint/defaults.at
@@ -0,0 +1,25 @@
+# This file is part of GNU tar test suite. -*- Autotest -*-
+# Copyright 2019 Free Software Foundation, Inc.
+#
+# GNU tar 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.
+#
+# GNU tar 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/>.
+AT_SETUP([checkpoint defaults])
+AT_KEYWORDS([checkpoint checkpoint/defaults])
+CPT_CHECK([
+tar --checkpoint -c -f ../a.tar .
+],
+[0],
+[],
+[tar: Write checkpoint 10
+])
+AT_CLEANUP
diff --git a/tests/checkpoint/dot-compat.at b/tests/checkpoint/dot-compat.at
new file mode 100644
index 00000000..0e9c2f34
--- /dev/null
+++ b/tests/checkpoint/dot-compat.at
@@ -0,0 +1,23 @@
+# This file is part of GNU tar test suite. -*- Autotest -*-
+# Copyright 2019 Free Software Foundation, Inc.
+#
+# GNU tar 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.
+#
+# GNU tar 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/>.
+AT_SETUP([dot action (compatibility syntax)])
+AT_KEYWORDS([checkpoint checkpoint/dot-compat])
+CPT_CHECK([
+tar --checkpoint=.2 -c -f ../a.tar .
+],
+[],
+[.....])
+AT_CLEANUP
diff --git a/tests/checkpoint/dot-int.at b/tests/checkpoint/dot-int.at
new file mode 100644
index 00000000..8fba21e5
--- /dev/null
+++ b/tests/checkpoint/dot-int.at
@@ -0,0 +1,24 @@
+# This file is part of GNU tar test suite. -*- Autotest -*-
+# Copyright 2019 Free Software Foundation, Inc.
+#
+# GNU tar 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.
+#
+# GNU tar 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/>.
+AT_SETUP([dot action and interval])
+AT_KEYWORDS([checkpoint checkpoint/dot-int])
+CPT_CHECK([
+tar --checkpoint-action=dot --checkpoint=2 -c -f ../a.tar .
+],
+[],
+[.....])
+AT_CLEANUP
+
diff --git a/tests/checkpoint/dot.at b/tests/checkpoint/dot.at
new file mode 100644
index 00000000..f940823a
--- /dev/null
+++ b/tests/checkpoint/dot.at
@@ -0,0 +1,24 @@
+# This file is part of GNU tar test suite. -*- Autotest -*-
+# Copyright 2019 Free Software Foundation, Inc.
+#
+# GNU tar 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.
+#
+# GNU tar 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/>.
+AT_SETUP([dot action])
+AT_KEYWORDS([checkpoint checkpoint/dot])
+CPT_CHECK([
+tar --checkpoint-action=dot -c -f ../a.tar .
+],
+[],
+[.])
+AT_CLEANUP
+
diff --git a/tests/checkpoint/interval.at b/tests/checkpoint/interval.at
new file mode 100644
index 00000000..b5d3f98f
--- /dev/null
+++ b/tests/checkpoint/interval.at
@@ -0,0 +1,29 @@
+# This file is part of GNU tar test suite. -*- Autotest -*-
+# Copyright 2019 Free Software Foundation, Inc.
+#
+# GNU tar 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.
+#
+# GNU tar 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/>.
+AT_SETUP([checkpoint interval])
+AT_KEYWORDS([checkpoint checkpoint/interval])
+CPT_CHECK([
+tar --checkpoint=2 -c -f ../a.tar .
+],
+[0],
+[],
+[tar: Write checkpoint 2
+tar: Write checkpoint 4
+tar: Write checkpoint 6
+tar: Write checkpoint 8
+tar: Write checkpoint 10
+])
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index f751bcf1..ddaf4e11 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -204,6 +204,7 @@ m4_include([version.at])
m4_include([pipe.at])
+AT_BANNER([Options])
m4_include([options.at])
m4_include([options02.at])
m4_include([options03.at])
@@ -216,6 +217,24 @@ m4_include([opcomp04.at])
m4_include([opcomp05.at])
m4_include([opcomp06.at])
+AT_BANNER([Checkpoints])
+m4_pushdef([CPT_CHECK],
+[AT_CHECK([
+mkdir t
+cd t
+for i in 0 1 2 3 4 5 6 7 8 9
+do
+ genfile --length 10240 --file $i
+done
+$1
+],m4_shift($@))])
+m4_include([checkpoint/defaults.at])
+m4_include([checkpoint/interval.at])
+m4_include([checkpoint/dot.at])
+m4_include([checkpoint/dot-compat.at])
+m4_include([checkpoint/dot-int.at])
+m4_popdef([CPT_CHECK])
+
AT_BANNER([Compression])
m4_include([compress-gzip.at])
m4_include([compress-bzip2.at])