[PATCH] History rebased against master 1.9.0 on 3Nov2007 [3 of 3]

Matt Davis mattdavis9 at gmail.com
Sun Nov 4 00:51:15 UTC 2007


The following patch adds the history testsuite script.
This script runs 15 tests, such as traversing the history, and then
applying changes to the test disk.

-Matt
---
 tests/Makefile.am      |    3 +-
 tests/t4000-history.sh |  112 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 1 deletions(-)
 create mode 100755 tests/t4000-history.sh

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3a3020e..5eadd96 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,7 +7,8 @@ TESTS = \
   t2000-mkfs.sh \
   t2100-mkswap.sh \
   t3000-constraints.sh \
-  t3100-resize-ext2-partion.sh
+  t3100-resize-ext2-partion.sh \
+  t4000-history.sh
 
 EXTRA_DIST = \
   $(TESTS) test-lib.sh mkdtemp
diff --git a/tests/t4000-history.sh b/tests/t4000-history.sh
new file mode 100755
index 0000000..5caecc1
--- /dev/null
+++ b/tests/t4000-history.sh
@@ -0,0 +1,112 @@
+#!/bin/sh
+# Tests for history functionality
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+
+# 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/>.
+
+test_description='Test history functionality'
+
+. ./init.sh
+
+dev=loop-file
+N=128M
+
+test_expect_success \
+    'create the test file' \
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
+
+# Make sure an empty history does not cause any failures.
+test_expect_success \
+    'run parted -s FILE history' \
+    'parted -s $dev history> out 2>&1'
+test_expect_success 'check for empty output' '$compare out /dev/null'
+
+# Make sure an empty history does not cause any failures.
+test_expect_success \
+    'run parted -s FILE undo' \
+    'parted -s $dev undo > out 2>&1'
+test_expect_success 'check for "could not undo"' \
+                    'grep -e "could not undo" out'
+
+# Make sure an empty history does not cause any failures.
+test_expect_success \
+    'run parted -s FILE redo' \
+    'parted -s $dev redo > out 2>&1'
+test_expect_success 'check for "could not redo"' \
+                    'grep -e "could not redo" out'
+
+# Make sure an empty history does not cause any failures.
+test_expect_success \
+    'run parted -s FILE save' \
+    'parted -s $dev save> out 2>&1'
+test_expect_success 'check for "nothing to save"' \
+                    'grep -e "nothing to save" out'
+
+# Add two items and undo the most recent and apply
+test_expect_success \
+    'label the test disk' \
+    'parted -s $dev \
+        mklabel msdos \
+        mkpartfs primary ext2 1 100 \
+        undo \
+        save > out 2>&1'
+test_expect_success 'check for mklabel success'\
+                    'if [ `cat out | wc -l` -eq 2 ]; \
+                     then let success=1; \
+                     fi; \
+                     if grep -q "mklabelmktable" out; \
+                     then let success=$success+1; \
+                     fi; \
+                     test $success -eq 2'
+
+# Add two items, undo the most recent, redo the most recent, and apply
+test_expect_success \
+    'label and partition the test disk' \
+    'parted -s $dev \
+        mklabel msdos \
+        mkpartfs primary ext2 1 100 \
+        undo \
+        redo \
+        save > out 2>&1'
+test_expect_success 'check for mkpartfs success'\
+                    'if [ `cat out | grep "Success" | wc -l` -eq 3 ]; \
+                     then let success=1; \
+                     fi; \
+                     if grep -n "Success" out | \
+                        grep -q -e "2:.*mkpartfs"; \
+                     then let success=$success+1; \
+                     fi; \
+                     test $success -eq 2'
+
+# Test that history output is functioning
+test_expect_success \
+    'label, partition disk twice, and output history log' \
+    'parted -s $dev \
+        mklabel msdos \
+        mkpartfs primary ext2 1 100 \
+        undo \
+        mkpartfs primary ext2 1 64 \
+        history > out 2>&1'
+test_expect_success 'check history output' \
+                    'if [ `cat out | wc -l` -eq 3 ]; \
+                     then let success=1; \
+                     fi; \
+                     if grep -n "Undone" out | \
+                        grep -n -e "2:.*Undone"; \
+                     then let success=$success+1; \
+                     fi; \
+                     test $success -eq 2'
+                        
+test_done
-- 
1.5.1.5


--5QAgd0e35j3NYeGe--



More information about the parted-devel mailing list