summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-05-29 21:30:40 +0200
committerJim Meyering <jim@meyering.net>2007-05-29 22:25:16 +0200
commita7e4e516d537e914e76094dd76b94caf900f3b2a (patch)
treef18e68d2c23f2b379354247f5725d50fde04b72b /tests
parentf1fbf278ba03388242b7adf5dcba90918bac78c9 (diff)
downloadparted-a7e4e516d537e914e76094dd76b94caf900f3b2a.tar.gz
Avoid a leak.
* parted/parted.c (do_print): Use separate variables for the header and for individual rows. Free each when done. * parted/table.c (table_add_row_from_strlist): Insert a newly allocated copy of each string, so that the caller can free the argument corresponding to the "list" parameter. * tests/t0100-print.sh: New test for this. * tests/Makefile.am (TESTS): Add t0100-print.sh.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rwxr-xr-xtests/t0100-print.sh58
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 27689c9..ecce727 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,6 @@
TESTS = \
t0000-basic.sh \
+ t0100-print.sh \
t1000-mkpartfs.sh \
t1100-busy-label.sh \
t1500-small-ext2.sh \
diff --git a/tests/t0100-print.sh b/tests/t0100-print.sh
new file mode 100755
index 0000000..74c478e
--- /dev/null
+++ b/tests/t0100-print.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+test_description="the most basic 'print' test"
+
+. ./init.sh
+
+dev=loop-file
+
+msdos_magic='\x55\xaa'
+
+test_expect_success \
+ "setup: create the most basic partition table, manually" \
+ '{ dd if=/dev/zero bs=510 count=1; printf "$msdos_magic"; } > $dev'
+
+test_expect_success \
+ 'print the empty table' \
+ 'parted -s $dev print >out 2>&1'
+
+pwd=`pwd`
+
+fail=0
+{
+ cat <<EOF
+Model: (file)
+Disk .../$dev: 512B
+Sector size (logical/physical): 512B/512B
+Partition Table: msdos
+
+Number Start End Size Type File system Flags
+
+EOF
+} > exp || fail=1
+
+test_expect_success \
+ 'prepare actual and expected output' \
+ 'test $fail = 0 &&
+ mv out o2 && sed "s,^Disk .*/$dev:,Disk .../$dev:," o2 > out'
+
+test_expect_success 'check for expected output' '$compare out exp'
+
+test_done