Whamcloud - gitweb
Add a regression test suite for the blkid library
authorTheodore Ts'o <tytso@mit.edu>
Sat, 10 Sep 2005 19:55:14 +0000 (15:55 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 10 Sep 2005 19:55:14 +0000 (15:55 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
37 files changed:
lib/blkid/Makefile.in
lib/blkid/probe.c
lib/blkid/test_probe.in [new file with mode: 0644]
lib/blkid/tests/cramfs.img.bz2 [new file with mode: 0644]
lib/blkid/tests/cramfs.results [new file with mode: 0644]
lib/blkid/tests/ext2.img.bz2 [new file with mode: 0644]
lib/blkid/tests/ext2.results [new file with mode: 0644]
lib/blkid/tests/ext3.img.bz2 [new file with mode: 0644]
lib/blkid/tests/ext3.results [new file with mode: 0644]
lib/blkid/tests/fat.img.bz2 [new file with mode: 0644]
lib/blkid/tests/fat.results [new file with mode: 0644]
lib/blkid/tests/fat32_label_64MB.img.bz2 [new file with mode: 0644]
lib/blkid/tests/fat32_label_64MB.results [new file with mode: 0644]
lib/blkid/tests/iso.img.bz2 [new file with mode: 0644]
lib/blkid/tests/iso.results [new file with mode: 0644]
lib/blkid/tests/jbd.img.bz2 [new file with mode: 0644]
lib/blkid/tests/jbd.results [new file with mode: 0644]
lib/blkid/tests/jfs.img.bz2 [new file with mode: 0644]
lib/blkid/tests/jfs.results [new file with mode: 0644]
lib/blkid/tests/minix.img.bz2 [new file with mode: 0644]
lib/blkid/tests/minix.results [new file with mode: 0644]
lib/blkid/tests/ocfs2.img.bz2 [new file with mode: 0644]
lib/blkid/tests/ocfs2.results [new file with mode: 0644]
lib/blkid/tests/reiser3.img.bz2 [new file with mode: 0644]
lib/blkid/tests/reiser3.results [new file with mode: 0644]
lib/blkid/tests/reiser4.img.bz2 [new file with mode: 0644]
lib/blkid/tests/reiser4.results [new file with mode: 0644]
lib/blkid/tests/romfs.img.bz2 [new file with mode: 0644]
lib/blkid/tests/romfs.results [new file with mode: 0644]
lib/blkid/tests/small-fat32.img.bz2 [new file with mode: 0644]
lib/blkid/tests/small-fat32.results [new file with mode: 0644]
lib/blkid/tests/swap0.img.bz2 [new file with mode: 0644]
lib/blkid/tests/swap0.results [new file with mode: 0644]
lib/blkid/tests/swap1.img.bz2 [new file with mode: 0644]
lib/blkid/tests/swap1.results [new file with mode: 0644]
lib/blkid/tests/xfs.img.bz2 [new file with mode: 0644]
lib/blkid/tests/xfs.results [new file with mode: 0644]

index 9f7cffb..2fc589c 100644 (file)
@@ -121,8 +121,16 @@ blkid: ../../misc/blkid.o libblkid.a $(DEPLIBUUID)
        @echo " LD $@"
        @$(CC) -o blkid ../../misc/blkid.o libblkid.a $(LIBUUID)
 
+test_probe: test_probe.in Makefile
+       @echo "Creating test_probe..."
+       @echo "#!/bin/sh" > test_probe
+       @echo "SRCDIR=@srcdir@" >> test_probe
+       @cat $(srcdir)/test_probe.in >> test_probe
+       @chmod +x test_probe
+
 check:: all tst_cache tst_dev tst_devname tst_devno tst_getsize tst_probe \
- tst_read tst_resolve tst_save tst_tag
+ tst_read tst_resolve tst_save tst_tag test_probe
+       ./test_probe
 
 blkid.pc: $(srcdir)/blkid.pc.in $(top_builddir)/config.status
        @echo " CONFIG.STATUS $@"
@@ -162,9 +170,11 @@ uninstall::
        done
 
 clean::
-       $(RM) -f \#* *.s *.o *.orig *.a *~ *.bak tst_* core profiled/* \
+       $(RM) -f \#* *.s *.o *.orig *.a *~ *.bak tst_* tests/*.out tests/*.ok \
+               tests/*.img results test_probe core profiled/* \
                checker/* blkid_types.h ../libblkid.a ../libblkid_p.a \
                $(SMANPAGES) blkid
+       -rmdir tests
 
 mostlyclean:: clean
 distclean:: clean
index 2e2ad2e..2236d54 100644 (file)
@@ -800,7 +800,6 @@ int main(int argc, char **argv)
        blkid_cache cache;
        int ret;
 
-       blkid_debug_mask = DEBUG_ALL;
        if (argc != 2) {
                fprintf(stderr, "Usage: %s device\n"
                        "Probe a single device to determine type\n", argv[0]);
@@ -816,12 +815,11 @@ int main(int argc, char **argv)
                printf("%s: %s has an unsupported type\n", argv[0], argv[1]);
                return (1);
        }
-       printf("%s is type %s\n", argv[1], dev->bid_type ?
-               dev->bid_type : "(null)");
+       printf("TYPE='%s'\n", dev->bid_type ? dev->bid_type : "(null)");
        if (dev->bid_label)
-               printf("\tlabel is '%s'\n", dev->bid_label);
+               printf("LABEL='%s'\n", dev->bid_label);
        if (dev->bid_uuid)
-               printf("\tuuid is %s\n", dev->bid_uuid);
+               printf("UUID='%s'\n", dev->bid_uuid);
        
        blkid_free_dev(dev);
        return (0);
diff --git a/lib/blkid/test_probe.in b/lib/blkid/test_probe.in
new file mode 100644 (file)
index 0000000..31ddf29
--- /dev/null
@@ -0,0 +1,40 @@
+
+TESTS=$*
+
+if test "$TESTS"x = x ; then
+       for i in $SRCDIR/tests/*.img.bz2
+       do
+               TESTS="$TESTS `basename $i .img.bz2`"
+       done
+fi
+
+mkdir -p tests
+
+for i in $TESTS
+do
+       echo -n "$i: "
+       if test ! -f $SRCDIR/tests/$i.img.bz2 -a \
+               ! -f $SRCDIR/tests/$i.results ; 
+       then
+               echo "non-existent"
+               continue
+       fi
+       bunzip2 < $SRCDIR/tests/$i.img.bz2 > /tmp/test.img.$$
+       ./tst_probe /tmp/test.img.$$ > tests/$i.out
+       /bin/rm -f /tmp/test.img.$$ tests/$i.ok tests/$i.failed
+       cmp -s tests/$i.out $SRCDIR/tests/$i.results
+       if [ $? = 0 ];  then
+               echo ok
+               touch tests/$i.ok
+       else    
+               echo failed
+               diff -c tests/$i.out $SRCDIR/tests/$i.results > tests/$i.failed
+       fi
+done
+
+num_ok=`ls tests/*.ok 2>/dev/null | wc -l`
+num_failed=`ls tests/*.failed 2>/dev/null | wc -l`
+
+echo "$num_ok tests succeeded  $num_failed tests failed"
+
+test "$num_failed" -eq 0 || exit 1
diff --git a/lib/blkid/tests/cramfs.img.bz2 b/lib/blkid/tests/cramfs.img.bz2
new file mode 100644 (file)
index 0000000..d638116
Binary files /dev/null and b/lib/blkid/tests/cramfs.img.bz2 differ
diff --git a/lib/blkid/tests/cramfs.results b/lib/blkid/tests/cramfs.results
new file mode 100644 (file)
index 0000000..984d9e2
--- /dev/null
@@ -0,0 +1,2 @@
+TYPE='cramfs'
+LABEL='test-cram'
diff --git a/lib/blkid/tests/ext2.img.bz2 b/lib/blkid/tests/ext2.img.bz2
new file mode 100644 (file)
index 0000000..d1811ce
Binary files /dev/null and b/lib/blkid/tests/ext2.img.bz2 differ
diff --git a/lib/blkid/tests/ext2.results b/lib/blkid/tests/ext2.results
new file mode 100644 (file)
index 0000000..4fa7a2a
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='ext2'
+LABEL='test-ext2'
+UUID='22f0eac3-5c89-4ec1-9076-60799119aaea'
diff --git a/lib/blkid/tests/ext3.img.bz2 b/lib/blkid/tests/ext3.img.bz2
new file mode 100644 (file)
index 0000000..5394598
Binary files /dev/null and b/lib/blkid/tests/ext3.img.bz2 differ
diff --git a/lib/blkid/tests/ext3.results b/lib/blkid/tests/ext3.results
new file mode 100644 (file)
index 0000000..4dc2252
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='ext3'
+LABEL='test-ext3'
+UUID='35f66dab-477e-4090-a872-95ee0e493ad6'
diff --git a/lib/blkid/tests/fat.img.bz2 b/lib/blkid/tests/fat.img.bz2
new file mode 100644 (file)
index 0000000..1fa7f2d
Binary files /dev/null and b/lib/blkid/tests/fat.img.bz2 differ
diff --git a/lib/blkid/tests/fat.results b/lib/blkid/tests/fat.results
new file mode 100644 (file)
index 0000000..7441872
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='vfat'
+LABEL='TEST-FAT'
+UUID='DEAD-BEEF'
diff --git a/lib/blkid/tests/fat32_label_64MB.img.bz2 b/lib/blkid/tests/fat32_label_64MB.img.bz2
new file mode 100644 (file)
index 0000000..ca76293
Binary files /dev/null and b/lib/blkid/tests/fat32_label_64MB.img.bz2 differ
diff --git a/lib/blkid/tests/fat32_label_64MB.results b/lib/blkid/tests/fat32_label_64MB.results
new file mode 100644 (file)
index 0000000..85c86bf
--- /dev/null
@@ -0,0 +1,2 @@
+TYPE='vfat'
+UUID='8CB5-BA49'
diff --git a/lib/blkid/tests/iso.img.bz2 b/lib/blkid/tests/iso.img.bz2
new file mode 100644 (file)
index 0000000..4efb6ad
Binary files /dev/null and b/lib/blkid/tests/iso.img.bz2 differ
diff --git a/lib/blkid/tests/iso.results b/lib/blkid/tests/iso.results
new file mode 100644 (file)
index 0000000..6a5d1dc
--- /dev/null
@@ -0,0 +1,2 @@
+TYPE='iso9660'
+LABEL='test-iso'
diff --git a/lib/blkid/tests/jbd.img.bz2 b/lib/blkid/tests/jbd.img.bz2
new file mode 100644 (file)
index 0000000..f0d7f91
Binary files /dev/null and b/lib/blkid/tests/jbd.img.bz2 differ
diff --git a/lib/blkid/tests/jbd.results b/lib/blkid/tests/jbd.results
new file mode 100644 (file)
index 0000000..2a43089
--- /dev/null
@@ -0,0 +1,2 @@
+TYPE='jbd'
+UUID='0d7a07df-7b06-4829-bce7-3b9c3ece570c'
diff --git a/lib/blkid/tests/jfs.img.bz2 b/lib/blkid/tests/jfs.img.bz2
new file mode 100644 (file)
index 0000000..1d4d249
Binary files /dev/null and b/lib/blkid/tests/jfs.img.bz2 differ
diff --git a/lib/blkid/tests/jfs.results b/lib/blkid/tests/jfs.results
new file mode 100644 (file)
index 0000000..5d752a3
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='jfs'
+LABEL='test-jfs'
+UUID='9bf7b82e-7583-4c74-99a4-189a691f27b5'
diff --git a/lib/blkid/tests/minix.img.bz2 b/lib/blkid/tests/minix.img.bz2
new file mode 100644 (file)
index 0000000..d11f3a8
Binary files /dev/null and b/lib/blkid/tests/minix.img.bz2 differ
diff --git a/lib/blkid/tests/minix.results b/lib/blkid/tests/minix.results
new file mode 100644 (file)
index 0000000..d0b448f
--- /dev/null
@@ -0,0 +1 @@
+TYPE='minix'
diff --git a/lib/blkid/tests/ocfs2.img.bz2 b/lib/blkid/tests/ocfs2.img.bz2
new file mode 100644 (file)
index 0000000..0bad915
Binary files /dev/null and b/lib/blkid/tests/ocfs2.img.bz2 differ
diff --git a/lib/blkid/tests/ocfs2.results b/lib/blkid/tests/ocfs2.results
new file mode 100644 (file)
index 0000000..918afa3
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='ocfs2'
+LABEL='test-ocfs2'
+UUID='6b6bfbea-3a79-4f0c-b166-a20776102445'
diff --git a/lib/blkid/tests/reiser3.img.bz2 b/lib/blkid/tests/reiser3.img.bz2
new file mode 100644 (file)
index 0000000..1802bc2
Binary files /dev/null and b/lib/blkid/tests/reiser3.img.bz2 differ
diff --git a/lib/blkid/tests/reiser3.results b/lib/blkid/tests/reiser3.results
new file mode 100644 (file)
index 0000000..8c3bb7c
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='reiserfs'
+LABEL='TESTREISER'
+UUID='9efe7863-b124-46dc-ad68-8ecd04230a7b'
diff --git a/lib/blkid/tests/reiser4.img.bz2 b/lib/blkid/tests/reiser4.img.bz2
new file mode 100644 (file)
index 0000000..b50d12e
Binary files /dev/null and b/lib/blkid/tests/reiser4.img.bz2 differ
diff --git a/lib/blkid/tests/reiser4.results b/lib/blkid/tests/reiser4.results
new file mode 100644 (file)
index 0000000..b312289
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='reiser4'
+LABEL='TESTR4'
+UUID='9722633c-d69a-4881-b1c8-bedecbbf39d2'
diff --git a/lib/blkid/tests/romfs.img.bz2 b/lib/blkid/tests/romfs.img.bz2
new file mode 100644 (file)
index 0000000..b5e3109
Binary files /dev/null and b/lib/blkid/tests/romfs.img.bz2 differ
diff --git a/lib/blkid/tests/romfs.results b/lib/blkid/tests/romfs.results
new file mode 100644 (file)
index 0000000..03e8622
--- /dev/null
@@ -0,0 +1,2 @@
+TYPE='romfs'
+LABEL='test-romfs'
diff --git a/lib/blkid/tests/small-fat32.img.bz2 b/lib/blkid/tests/small-fat32.img.bz2
new file mode 100644 (file)
index 0000000..8b90f9c
Binary files /dev/null and b/lib/blkid/tests/small-fat32.img.bz2 differ
diff --git a/lib/blkid/tests/small-fat32.results b/lib/blkid/tests/small-fat32.results
new file mode 100644 (file)
index 0000000..bd5ebf4
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='vfat'
+LABEL='TESTVFAT'
+UUID='1423-AAE1'
diff --git a/lib/blkid/tests/swap0.img.bz2 b/lib/blkid/tests/swap0.img.bz2
new file mode 100644 (file)
index 0000000..e61e375
Binary files /dev/null and b/lib/blkid/tests/swap0.img.bz2 differ
diff --git a/lib/blkid/tests/swap0.results b/lib/blkid/tests/swap0.results
new file mode 100644 (file)
index 0000000..8742a60
--- /dev/null
@@ -0,0 +1 @@
+TYPE='swap'
diff --git a/lib/blkid/tests/swap1.img.bz2 b/lib/blkid/tests/swap1.img.bz2
new file mode 100644 (file)
index 0000000..fbab9ed
Binary files /dev/null and b/lib/blkid/tests/swap1.img.bz2 differ
diff --git a/lib/blkid/tests/swap1.results b/lib/blkid/tests/swap1.results
new file mode 100644 (file)
index 0000000..ea04e5d
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='swap'
+LABEL='SWAP-TEST'
+UUID='8ff8e77f-8553-485e-8656-58be67a81666'
diff --git a/lib/blkid/tests/xfs.img.bz2 b/lib/blkid/tests/xfs.img.bz2
new file mode 100644 (file)
index 0000000..cf6982b
Binary files /dev/null and b/lib/blkid/tests/xfs.img.bz2 differ
diff --git a/lib/blkid/tests/xfs.results b/lib/blkid/tests/xfs.results
new file mode 100644 (file)
index 0000000..18e8d88
--- /dev/null
@@ -0,0 +1,3 @@
+TYPE='xfs'
+LABEL='test-xfs'
+UUID='8c8a0a5a-9f57-492e-9610-45a61f38f58a'