On Sun, 2008-12-21 at 17:21 +0100, Jim Meyering wrote:
> Now that I've done the above, it should be easy to make
> that into a test case, since there are already several
> very similar ones (see tests/t*).
> 
> Would you like to do that?

Thanks Jim, that makes it very clear!

Attached is a patch to add a test case. You'll need to chmod 755 the
test file (afaik, you can't set permissions in a patch). I tested this
with my previous patch applied and the test succeeds (without it, it
fails).

~spot
diff -up parted-1.8.8/tests/Makefile.am.sparc-raid-test parted-1.8.8/tests/Makefile.am
--- parted-1.8.8/tests/Makefile.am.sparc-raid-test	2007-07-14 13:31:40.000000000 -0400
+++ parted-1.8.8/tests/Makefile.am	2008-12-21 12:39:51.000000000 -0500
@@ -6,7 +6,8 @@ TESTS = \
   t1500-small-ext2.sh \
   t2000-mkfs.sh \
   t3000-constraints.sh \
-  t3100-resize-ext2-partion.sh
+  t3100-resize-ext2-partion.sh \
+  t4000-sun-raid-type.sh
 
 EXTRA_DIST = \
   $(TESTS) test-lib.sh mkdtemp
diff -up parted-1.8.8/tests/Makefile.in.sparc-raid-test parted-1.8.8/tests/Makefile.in
--- parted-1.8.8/tests/Makefile.in.sparc-raid-test	2007-08-09 14:49:33.000000000 -0400
+++ parted-1.8.8/tests/Makefile.in	2008-12-21 12:41:23.000000000 -0500
@@ -357,7 +357,8 @@ TESTS = \
   t1500-small-ext2.sh \
   t2000-mkfs.sh \
   t3000-constraints.sh \
-  t3100-resize-ext2-partion.sh
+  t3100-resize-ext2-partion.sh \
+  t4000-sun-raid-type.sh
 
 EXTRA_DIST = \
   $(TESTS) test-lib.sh mkdtemp
diff -up /dev/null parted-1.8.8/tests/t4000-sun-raid-type.sh
--- /dev/null	2008-12-19 21:49:53.735009642 -0500
+++ parted-1.8.8/tests/t4000-sun-raid-type.sh	2008-12-21 12:52:58.000000000 -0500
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# Copyright (C) 2008 Tom "spot" Callaway <tcall...@redhat.com>
+# Derived from an example by Jim Meyering <j...@meyering.net>
+
+# 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='RAID support on sun disk type'
+
+. ./init.sh
+
+N=10M
+dev=sun-disk-file
+pwd=`pwd`
+test_expect_success \
+    'create an empty file as a test disk' \
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
+
+test_expect_success \
+    'label the test disk as a sun disk' \
+    'parted -s $dev mklabel sun > out 2>&1'
+test_expect_success 'check for empty output' '$compare out /dev/null'
+
+test_expect_success \
+    'create a single partition' \
+    'parted -s $dev unit s mkpart ext2 0s 50s > out 2>&1'
+test_expect_success 'check for empty output' '$compare out /dev/null'
+
+test_expect_success \
+    'print the partition data in machine readable format' \
+    'parted -m -s $dev unit s p > out 2>&1'
+
+test_expect_success \
+    'check for expected values for the partition' '
+    echo -e "BYT;\n$pwd/$dev:20480s:file:512:512:sun:;\n1:0s:50s:51s:::;" > exp &&
+    $compare out exp'
+
+test_expect_success \
+    'set the raid flag' \
+    'parted -s $dev set 1 raid >out 2>&1'
+test_expect_success 'check for empty output' '$compare out /dev/null'
+
+test_expect_success \
+    'print the partition data in machine readable format again' \
+    'parted -m -s $dev unit s p > out 2>&1'
+
+test_expect_success \
+    'check for expected values (including raid flag) for the partition' '
+    echo -e "BYT;\n$pwd/$dev:20480s:file:512:512:sun:;\n1:0s:50s:51s:::raid;" > exp &&
+    $compare out exp'
+
+test_done
_______________________________________________
bug-parted mailing list
bug-parted@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-parted

Reply via email to