Add a rough-cut testcase for hardlink handling
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 8 Feb 2012 15:45:34 +0000 (17:45 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 8 Feb 2012 15:58:14 +0000 (17:58 +0200)
- Check that we get expected number of links in package generation,
  that all the files got installed and that the linked files are
  actually hardlinks (for our purposes, plain inode suffices)

tests/Makefile.am
tests/data/SPECS/hlinktest.spec [new file with mode: 0644]
tests/rpmbuild.at

index b919fd3..72b17ca 100644 (file)
@@ -38,6 +38,7 @@ EXTRA_DIST += data/SPECS/versiontest.spec
 EXTRA_DIST += data/SPECS/conflicttest.spec
 EXTRA_DIST += data/SPECS/configtest.spec
 EXTRA_DIST += data/SPECS/flangtest.spec
+EXTRA_DIST += data/SPECS/hlinktest.spec
 EXTRA_DIST += data/SPECS/symlinktest.spec
 EXTRA_DIST += data/SPECS/deptest.spec
 EXTRA_DIST += data/SPECS/verifyscript.spec
diff --git a/tests/data/SPECS/hlinktest.spec b/tests/data/SPECS/hlinktest.spec
new file mode 100644 (file)
index 0000000..7c22d29
--- /dev/null
@@ -0,0 +1,27 @@
+Summary:          Testing hard link behavior
+Name:             hlinktest
+Version:          1.0
+Release:          1
+License:          Testing
+Group:            Testing
+BuildArch:       noarch
+%description
+  
+%install
+rm -rf %{buildroot}
+mkdir -p $RPM_BUILD_ROOT/foo
+cat << EOF >> $RPM_BUILD_ROOT/foo/hello
+#!/bin/sh
+echo $0
+EOF
+
+cd $RPM_BUILD_ROOT/foo
+cat hello > copyllo
+chmod a+x hello copyllo
+for f in foo bar world; do
+    ln hello hello-${f}
+done
+
+%files
+%defattr(-,root,root)
+/foo/*
index 136fe46..517de72 100644 (file)
@@ -122,3 +122,33 @@ drwxrwxrwx zoot     zoot     /j/dir
 ],
 [])
 AT_CLEANUP
+
+# ------------------------------
+# hardlink tests
+AT_SETUP([rpmbuild hardlink])
+AT_KEYWORDS([build])
+AT_CHECK([
+RPMDB_CLEAR
+RPMDB_INIT
+rm -rf ${TOPDIR}
+
+runroot rpmbuild \
+  -bb --quiet /data/SPECS/hlinktest.spec
+
+runroot rpm -i "${TOPDIR}"/RPMS/noarch/hlinktest-1.0-1.noarch.rpm
+
+runroot rpm -q --qf "[[%{filenlinks} %{filenames}\n]]" hlinktest
+runroot rpm -V --nouser --nogroup hlinktest
+ls -i "${RPMTEST}"/foo/hello* | awk {'print $1'} | sort -u | wc -l
+
+],
+[0],
+[1 /foo/copyllo
+4 /foo/hello
+4 /foo/hello-bar
+4 /foo/hello-foo
+4 /foo/hello-world
+1
+],
+[])
+AT_CLEANUP