Add a test-case for various %attr and %defattr combinations
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 28 Jun 2011 07:34:13 +0000 (10:34 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 28 Jun 2011 07:34:50 +0000 (10:34 +0300)
- Currently this fails expectedly due to RhBug:681540 on the last
  directory of the test rpm.

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

index 026a0d5..6f84093 100644 (file)
@@ -30,6 +30,7 @@ TESTSUITE_AT += rpmdepmatch.at
 EXTRA_DIST += $(TESTSUITE_AT)
 
 ## testsuite data
+EXTRA_DIST += data/SPECS/attrtest.spec
 EXTRA_DIST += data/SPECS/hello.spec
 EXTRA_DIST += data/SPECS/hello-script.spec
 EXTRA_DIST += data/SPECS/foo.spec
diff --git a/tests/data/SPECS/attrtest.spec b/tests/data/SPECS/attrtest.spec
new file mode 100644 (file)
index 0000000..6f787b1
--- /dev/null
@@ -0,0 +1,58 @@
+Name:           attrtest 
+Version:        1.0
+Release:        1
+Summary:        Testing file attr behavior
+Group:          Testing
+License:        GPL
+BuildArch:     noarch
+
+%description
+%{summary}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+for x in a b c d e f g h i j; do
+    mkdir -p $RPM_BUILD_ROOT/${x}
+    mkdir -p $RPM_BUILD_ROOT/${x}/dir
+    echo "${x}" > $RPM_BUILD_ROOT/${x}/file
+    chmod 700 $RPM_BUILD_ROOT/${x}/dir
+    chmod 400 $RPM_BUILD_ROOT/${x}/file
+done
+
+%files
+/a/dir
+/a/file
+
+%attr(-,daemon,adm) /b/dir
+%attr(-,daemon,adm) /b/file
+
+%attr(750,-,adm) /c/dir
+%attr(640,daemon,-) /c/file
+
+%attr(751,daemon,bin) /d/dir
+%attr(644,bin,daemon) /d/file
+
+%defattr(-,foo,bar)
+/e/dir
+/e/file
+
+%defattr(-,bar,foo)
+%attr(770,-,-) /f/dir
+%attr(660,-,-) /f/file
+
+%defattr(-,bar,foo)
+%attr(-,adm,-) /g/dir
+%attr(-,-,adm) /g/file
+
+%defattr(644,foo,bar,755)
+/h/dir
+/h/file
+
+%defattr(4755,root,root,750)
+%attr(-,adm,-) /i/dir
+%attr(-,-,adm) /i/file
+
+%defattr(640,zoot,zoot,750)
+%attr(777,-,-) /j/dir
+%attr(222,-,-) /j/file
index 5155777..7867aeb 100644 (file)
@@ -82,3 +82,45 @@ run rpmbuild \
 [ignore],
 [ignore])
 AT_CLEANUP
+
+# ------------------------------
+# %attr/%defattr tests
+AT_SETUP([rpmbuild %attr and %defattr])
+# expected failure on RhBug:681540
+AT_XFAIL_IF([test $RPM_XFAIL -gt 0])
+AT_KEYWORDS([build])
+AT_CHECK([[
+rm -rf ${TOPDIR}
+
+runroot rpmbuild \
+  -bb --quiet /data/SPECS/attrtest.spec
+
+runroot rpm -qp --qf \
+  "\n[%{filemodes:perms} %-8{fileusername} %-8{filegroupname} %{filenames}\n]"\
+  "${TOPDIR}"/RPMS/noarch/attrtest-1.0-1.noarch.rpm
+]],
+[0],
+[
+drwx------ root     root     /a/dir
+-r-------- root     root     /a/file
+drwx------ daemon   adm      /b/dir
+-r-------- daemon   adm      /b/file
+drwxr-x--- root     adm      /c/dir
+-rw-r----- daemon   root     /c/file
+drwxr-x--x daemon   bin      /d/dir
+-rw-r--r-- bin      daemon   /d/file
+drwx------ foo      bar      /e/dir
+-r-------- foo      bar      /e/file
+drwxrwx--- bar      foo      /f/dir
+-rw-rw---- bar      foo      /f/file
+drwx------ adm      foo      /g/dir
+-r-------- bar      adm      /g/file
+drwxr-xr-x foo      bar      /h/dir
+-rw-r--r-- foo      bar      /h/file
+drwxr-x--- adm      root     /i/dir
+-rwsr-xr-x root     adm      /i/file
+drwxrwxrwx zoot     zoot     /j/dir
+--w--w--w- zoot     zoot     /j/file
+],
+[])
+AT_CLEANUP