[PATCH] History patch 3 of 3

Matt Davis mattdavis9 at gmail.com
Thu Feb 7 05:33:00 UTC 2008


The following changes apply to testing the history system.

    tests/t4000-history.sh
    Performs 15 tests against the history modifications

    tests/Makefile.am
    Adds the t4000-history.sh test set
---
 tests/t4000-history.sh |  112 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 112 insertions(+), 0 deletions(-)
 create mode 100755 tests/t4000-history.sh

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


--ibTvN161/egqYuK8--



More information about the parted-devel mailing list